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:
parent
f5bea41ccf
commit
72b5a5ca82
11 changed files with 46 additions and 22 deletions
|
|
@ -22,6 +22,7 @@ class GroupOrder < ActiveRecord::Base
|
|||
# Generate some data for the javascript methods in ordering view
|
||||
def load_data
|
||||
data = {}
|
||||
data[:account_balance] = ordergroup.account_balance
|
||||
data[:available_funds] = ordergroup.nil? ? BigDecimal.new('+Infinity') : ordergroup.get_available_funds(self)
|
||||
|
||||
# load prices and other stuff....
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ class Order < ActiveRecord::Base
|
|||
# Close the order directly, without automaticly updating ordergroups account balances
|
||||
def close_direct!(user)
|
||||
raise I18n.t('orders.model.error_closed') if closed?
|
||||
comments.create(user: user, text: I18n.t('orders.model.close_direct_message'))
|
||||
comments.create(user: user, text: I18n.t('orders.model.close_direct_message')) unless FoodsoftConfig[:charge_members_manually]
|
||||
update_attributes! state: 'closed', updated_by: user
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
.input-prepend
|
||||
%span.add-on= t 'number.currency.format.unit'
|
||||
= config_input_field form, :minimum_balance, as: :decimal, class: 'input-small'
|
||||
= config_input form, :charge_members_manually, as: :boolean
|
||||
= config_input form, :use_iban, as: :boolean
|
||||
|
||||
%h4= t '.schedule_title'
|
||||
|
|
|
|||
|
|
@ -53,13 +53,16 @@
|
|||
class: 'btn'
|
||||
.btn-group
|
||||
- unless @order.closed?
|
||||
= link_to t('.confirm_order'), confirm_finance_order_path(@order), class: 'btn btn-primary'
|
||||
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn dropdown-toggle' do
|
||||
%span.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to t('.confirm_order'), confirm_finance_order_path(@order)
|
||||
%li= link_to t('.close_direct'), close_direct_finance_order_path(@order), method: :patch,
|
||||
data: {confirm: t('.close_direct_confirm')}
|
||||
- if FoodsoftConfig[:charge_members_manually]
|
||||
= link_to t('.confirm_order'), close_direct_finance_order_path(@order), class: 'btn btn-primary', method: :patch
|
||||
- else
|
||||
= link_to t('.confirm_order'), confirm_finance_order_path(@order), class: 'btn btn-primary'
|
||||
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn dropdown-toggle' do
|
||||
%span.caret
|
||||
%ul.dropdown-menu
|
||||
%li= link_to t('.confirm_order'), confirm_finance_order_path(@order)
|
||||
%li= link_to t('.close_direct'), close_direct_finance_order_path(@order), method: :patch,
|
||||
data: {confirm: t('.close_direct_confirm')}
|
||||
|
||||
#editOrderNav.btn-group
|
||||
= link_to '#', data: {toggle: 'dropdown'}, class: 'btn dropdown-toggle' do
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -45,8 +45,13 @@
|
|||
%h2= t '.my_ordergroup.title'
|
||||
%p
|
||||
%b= current_user.ordergroup.name
|
||||
= t '.my_ordergroup.funds'
|
||||
= number_to_currency(current_user.ordergroup.get_available_funds)
|
||||
= ' | '
|
||||
- if FoodsoftConfig[:charge_members_manually]
|
||||
= heading_helper(Ordergroup, :account_balance) + ':'
|
||||
= number_to_currency(current_user.ordergroup.account_balance)
|
||||
- else
|
||||
= heading_helper(Ordergroup, :available_funds) + ':'
|
||||
= number_to_currency(current_user.ordergroup.get_available_funds)
|
||||
%small= t '.my_ordergroup.last_update', when: distance_of_time_in_words(Time.now, current_user.ordergroup.account_updated)
|
||||
%h3= t '.my_ordergroup.transactions.title'
|
||||
%table.table.table-striped
|
||||
|
|
|
|||
|
|
@ -7,8 +7,12 @@
|
|||
- unless @ordergroup.description.blank?
|
||||
%p= @ordergroup.description
|
||||
%p
|
||||
%b= heading_helper(Ordergroup, :available_funds) + ':'
|
||||
= number_to_currency(@ordergroup.get_available_funds())
|
||||
%b= heading_helper(Ordergroup, :account_balance) + ':'
|
||||
= number_to_currency(@ordergroup.account_balance)
|
||||
- unless FoodsoftConfig[:charge_members_manually]
|
||||
%p
|
||||
%b= heading_helper(Ordergroup, :available_funds) + ':'
|
||||
= number_to_currency(@ordergroup.get_available_funds())
|
||||
%p
|
||||
%b= heading_helper(Ordergroup, :user_tokens) + ':'
|
||||
= @ordergroup.memberships.map{|m| show_user m.user}.join(', ')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue