Add option to show account balance instead of available funds

Some foodcoops do not use the accounting feature of the foodsoft, which
results in wrong calculation of the available credit. To avoid
confusions show the current account balance instead.
This commit is contained in:
Patrick Gansterer 2017-10-10 18:20:54 +02:00
parent f5bea41ccf
commit 72b5a5ca82
11 changed files with 46 additions and 22 deletions

View file

@ -1,8 +1,9 @@
- content_for :javascript do
- group_balance = FoodsoftConfig[:charge_members_manually] ? @ordering_data[:account_balance] : @ordering_data[:available_funds]
:javascript
$(function() {
#{data_to_js(@ordering_data)}
setGroupBalance(#{@ordering_data[:available_funds]});
setGroupBalance(#{group_balance});
setMinimumBalance(#{FoodsoftConfig[:minimum_balance] or 0});
setToleranceBehaviour(#{FoodsoftConfig[:tolerance_is_costly]});
setStockit(#{@order.stockit?});
@ -45,8 +46,11 @@
%dd
= show_user(@group_order.updated_by)
(#{format_time(@group_order.updated_on)})
%dt= heading_helper Ordergroup, :available_funds
%dd= number_to_currency(@ordering_data[:available_funds])
%dt= heading_helper Ordergroup, :account_balance
%dd= number_to_currency(@ordering_data[:account_balance])
- unless FoodsoftConfig[:charge_members_manually]
%dt= heading_helper Ordergroup, :available_funds
%dd= number_to_currency(@ordering_data[:available_funds])
.well.pull-right
= close_button :alert
@ -156,13 +160,19 @@
%td.currency
%span#total_price= number_to_currency(@group_order.price)
%tr
%td= heading_helper(Ordergroup, :available_funds) + ':'
%td.currency= number_to_currency(@ordering_data[:available_funds])
- if FoodsoftConfig[:charge_members_manually]
- old_balance = @ordering_data[:account_balance]
%td= heading_helper(Ordergroup, :account_balance) + ':'
%td.currency= number_to_currency(@ordering_data[:account_balance])
- else
- old_balance = @ordering_data[:available_funds]
%td= heading_helper(Ordergroup, :available_funds) + ':'
%td.currency= number_to_currency(@ordering_data[:available_funds])
%tr
%td= t('.new_funds') + ':'
%td.currency
%strong
%span#new_balance= number_to_currency(@ordering_data[:available_funds] - @group_order.price)
%span#new_balance= number_to_currency(old_balance - @group_order.price)
#order-button
= submit_tag( t('.action_save'), id: 'submit_button', class: 'btn btn-primary' )
#{link_to t('ui.or_cancel'), group_orders_path}