-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve access to financial link feature & add option to create link when balancing an order #860
Improve access to financial link feature & add option to create link when balancing an order #860
Conversation
show a checkbox on the balancing/confirm page (if financial links are activated) to optionally create a common financial link for the transactions and invoice (if existing)
i didn't test it, but you could use
you could add a (database) migration file for that
i don't think that linking an order with an invoice is correct. IMHO we should implement the same schematic like in foodsoft/app/controllers/finance/financial_transactions_controller.rb Lines 104 to 113 in 007ff70
when balancing an order with two groups it should result in 3 transactions: e.g. ordergroup A "-10€", ordergroup B "-20€" and ordergroup
the order.rb files gets to big (and hard to maintain). for now you could increase the maximum in the rubocop configuration: Lines 286 to 287 in 007ff70
BTW: it would be great to add tests for changes on the model |
Wouldn't that result in creating a financial link in case the config option is deactivated and the checkbox therefore not shown?
Ah, that makes sense! I'll add an option to create a foodcoop transaction. Do you think its value should be gross_amount (without margin), fc_amount (with margin) or groups_amount (the total amount the groups are actually charged)? Or perhaps gross_amount as one foodcoop transaction and, in case fc_amount varies, the difference as a another foodcoop transaction? |
depends where you put it. if you put it in the view and you don't create an
it must be the sum of the values you subtracted from the ordergroups. having a non-zero sum of a |
…t working yet) also, attach the foodcoop transaction (if checked) to the financial link instead of the invoice
user: @current_user, | ||
amount: @order.sum(:groups), | ||
note: @order.transaction_note, | ||
financial_link: @link, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you fix the RuboCop issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed it now, but I can't figure out why it still doesn't work (no foodcoop transaction is created)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transaction_note
is a private method you cannot access here
I know, that very similar code exists somewhere else in the codebase, but the same problem applies there too (and should be fixed):
this change mixes responsibilities of controller and model, which results in hard to test code. the better way would be to add two parameters to Order.close!
and call it then as @order.close!(@current_user, @type, create_financial_link: params[:create_financial_link], create_foodcoop_transaction: params[:create_foodcoop_transaction])
Then it's very easy to add tests for this change.
@@ -4,6 +4,17 @@ | |||
%p | |||
%b= heading_helper FinancialTransaction, :financial_transaction_type | |||
= select_tag :type, options_for_select(FinancialTransactionType.order(:name).map { |t| [ t.name, t.id ] }) | |||
- if FinancialTransaction.where(ordergroup: nil).any? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you think about merging both if
into if FoodsoftConfig[:use_financial_links]
? I think the check for an "foodcoop transaction" is somehow outdated now (applies to new_collection.html.haml
too). I would also prefer to make both checkboxes checked by default, since that's the common case. we can do that also in a follow up commit, if you don't want to include it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was already thinking about adding another config option "use_foodcoop_transactions", what do you think about that?
Or one option "use double-entry accounting" for both financial links and foodcoop transactions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd prefer to keep the number of options low. IMHO showing user_financial_links
as Use financial links (usable for "double-entry accounting") should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please create an independent PR for the translation changes or force-push your changes with a clean history, so I don't need to squash them and can rebase them instead when merging. it's up to you which git-workflow you want to use
@@ -4,6 +4,17 @@ | |||
%p | |||
%b= heading_helper FinancialTransaction, :financial_transaction_type | |||
= select_tag :type, options_for_select(FinancialTransactionType.order(:name).map { |t| [ t.name, t.id ] }) | |||
- if FinancialTransaction.where(ordergroup: nil).any? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd prefer to keep the number of options low. IMHO showing user_financial_links
as Use financial links (usable for "double-entry accounting") should be enough.
user: @current_user, | ||
amount: @order.sum(:groups), | ||
note: @order.transaction_note, | ||
financial_link: @link, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
transaction_note
is a private method you cannot access here
I know, that very similar code exists somewhere else in the codebase, but the same problem applies there too (and should be fixed):
this change mixes responsibilities of controller and model, which results in hard to test code. the better way would be to add two parameters to Order.close!
and call it then as @order.close!(@current_user, @type, create_financial_link: params[:create_financial_link], create_foodcoop_transaction: params[:create_foodcoop_transaction])
Then it's very easy to add tests for this change.
replaced by #1064 |
Implementation of #848
To do:
true
in case there is at least one financial link. Otherwise previously shown options would disappear until the option is activated in the admin menu. Is there a way to include this in the PR?Also I don't know what the Rubocop error (classlength) means.