Add option to create foodcoop transaction when creating a collection
This option can be used, if a kind of "double-entry accounting" is used and every transaction should have a corresponding transaction.
This commit is contained in:
parent
97b9145223
commit
3f25138997
4 changed files with 20 additions and 0 deletions
|
@ -84,6 +84,7 @@ class Finance::FinancialTransactionsController < ApplicationController
|
||||||
|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
financial_link = FinancialLink.new if params[:create_financial_link]
|
financial_link = FinancialLink.new if params[:create_financial_link]
|
||||||
|
foodcoop_amount = 0
|
||||||
|
|
||||||
params[:financial_transactions].each do |trans|
|
params[:financial_transactions].each do |trans|
|
||||||
# ignore empty amount fields ...
|
# ignore empty amount fields ...
|
||||||
|
@ -96,9 +97,21 @@ class Finance::FinancialTransactionsController < ApplicationController
|
||||||
amount -= ordergroup.financial_transaction_class_balance(type.financial_transaction_class)
|
amount -= ordergroup.financial_transaction_class_balance(type.financial_transaction_class)
|
||||||
end
|
end
|
||||||
ordergroup.add_financial_transaction!(amount, note, @current_user, type, financial_link)
|
ordergroup.add_financial_transaction!(amount, note, @current_user, type, financial_link)
|
||||||
|
foodcoop_amount -= amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if params[:create_foodcoop_transaction]
|
||||||
|
ft = FinancialTransaction.new({
|
||||||
|
financial_transaction_type: type,
|
||||||
|
user: @current_user,
|
||||||
|
amount: foodcoop_amount,
|
||||||
|
note: params[:note],
|
||||||
|
financial_link: financial_link,
|
||||||
|
})
|
||||||
|
ft.save!
|
||||||
|
end
|
||||||
|
|
||||||
financial_link.try(&:save!)
|
financial_link.try(&:save!)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,11 @@
|
||||||
%p
|
%p
|
||||||
= link_to t('.new_ordergroup'), '#', 'data-add-transaction' => true, class: 'btn'
|
= link_to t('.new_ordergroup'), '#', 'data-add-transaction' => true, class: 'btn'
|
||||||
= link_to t('.add_all_ordergroups'), '#', 'data-add-all-ordergroups' => true, class: 'btn'
|
= link_to t('.add_all_ordergroups'), '#', 'data-add-all-ordergroups' => true, class: 'btn'
|
||||||
|
- if FinancialTransaction.where(ordergroup: nil).any?
|
||||||
|
%p
|
||||||
|
%label
|
||||||
|
= check_box_tag :create_foodcoop_transaction, true, params[:create_foodcoop_transaction]
|
||||||
|
= t('.create_foodcoop_transaction')
|
||||||
- if BankAccount.any?
|
- if BankAccount.any?
|
||||||
%p
|
%p
|
||||||
%label
|
%label
|
||||||
|
|
|
@ -874,6 +874,7 @@ de:
|
||||||
add_all_ordergroups: Alle Bestellgruppen hinzufügen
|
add_all_ordergroups: Alle Bestellgruppen hinzufügen
|
||||||
add_all_ordergroups_custom_field: Alle Bestellgruppen mit %{label} hinzufügen
|
add_all_ordergroups_custom_field: Alle Bestellgruppen mit %{label} hinzufügen
|
||||||
create_financial_link: Erstelle einen gemeinsamen Finanzlink für die neuen Transaktionen.
|
create_financial_link: Erstelle einen gemeinsamen Finanzlink für die neuen Transaktionen.
|
||||||
|
create_foodcoop_transaction: Erstelle einen Transaktion mit der der invertieten Summe für die Foodcoop (für den Fall der "doppelte Buchführung")
|
||||||
new_ordergroup: Weitere Bestellgruppe hinzufügen
|
new_ordergroup: Weitere Bestellgruppe hinzufügen
|
||||||
save: Transaktionen speichern
|
save: Transaktionen speichern
|
||||||
set_balance: Setze den Kontostand der Bestellgrupppe auf den eingegebenen Betrag.
|
set_balance: Setze den Kontostand der Bestellgrupppe auf den eingegebenen Betrag.
|
||||||
|
|
|
@ -897,6 +897,7 @@ en:
|
||||||
add_all_ordergroups: Add all ordergroups
|
add_all_ordergroups: Add all ordergroups
|
||||||
add_all_ordergroups_custom_field: Add all ordergoups with %{label}
|
add_all_ordergroups_custom_field: Add all ordergoups with %{label}
|
||||||
create_financial_link: Create a common financial link for the new transactions.
|
create_financial_link: Create a common financial link for the new transactions.
|
||||||
|
create_foodcoop_transaction: Create a transaction with the inverted sum for the foodcoop (in the case of "double-entry accounting")
|
||||||
new_ordergroup: Add new ordergroup
|
new_ordergroup: Add new ordergroup
|
||||||
save: Save transaction
|
save: Save transaction
|
||||||
set_balance: Set the balance of the ordergroup to the entered amount.
|
set_balance: Set the balance of the ordergroup to the entered amount.
|
||||||
|
|
Loading…
Reference in a new issue