-
-
Notifications
You must be signed in to change notification settings - Fork 824
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
Stop adding a refund payment from creating extraneous financial items #15143
Conversation
(Standard links)
|
Looking closely from your attached image in description it looks like the data are stored incorrectly in some tables
a . Entries for trxn_id = 2 is missing.
Hope my points make sense. |
Thanks @pradpnayak and thanks for your guidance on the other issue. I'll read through them later and mull them |
Per civicrm#15143 (comment) and https://github.com/civicrm/civicrm-core/pull/13114/files#diff-8967f6e57d6209aa277ded6512413608L326 it seems agreed the financial items should not be created on refund. This removes them & updates the test
@monishdeb @pradpnayak based on the above conversation (& elsewhere) I have updated this PR to remove the extraneous line item creations. This was actually originally proposed by @monishdeb as part of 'the larger change' - but in this context I think it stands alone & is mergeable as an agreed change & simplifies the larger change Note I have NOT addressed all @pradpnayak's points above here - just this one as it appears to be separable from the others |
I agree with this rightful change and does avoid creating those extraneous items. I am marking with MoP tag. |
This is a very significant change. Before we move away from doing reversal transactions followed by posting of new transaction, I think we need:
My sense is that this is likely the right direction, but it is wrong to treat this as just a small change that can be discussed by developers on a pull request. @lcdservices who do you think could help with the discussion regarding accounting? |
@KarinG ^ |
Does anyone know if Jamie Novick has a nick here in github so we can reference him? |
Here is a site that suggests when it is appropriate to use an adjusting entry (which we have called a difference transaction) and when it is more appropriate from an accounting perspective to use a reversal transaction followed by a new transaction: I think most of our changes are not related to correcting entries but to posting changes to the transaction in the regular course of its lifecycle. |
@JoeMurray in what way is not creating financial items on adding a refund payment a significant change? It was included in the earlier PR by @monishdeb as a minor sub part, it doesn't happen on payment, only refund and after reviewing the spec after reading @pradpnayak's comments I looked at the confluence page (which one again I've lost the link to) and it talks about updating the status of financial items when a refund is received, not adding new ones - so this seems to bring us to the behaviour described in confluence rather than be a signficant change |
Note that your discussion is all about financial transactions - this PR does not change financial transaction creation |
By financial transaction in this context, I meant bookkeeping entries in civicrm_financial_trxn, civicrm_financial_item and related tables including civicrm_entity_financial_trxn. I relied on @monishdeb 's explanation that due to refactoring that has occurred, what was being discussed would modify how Civi handles any change to a bookkeeping entry so that there would be no more reversal of old (ie backing out the current status of the bookkeeping entry) followed by insertion of new, but instead a single insertion of difference transaction. Are you referring to https://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Data+Flow ? The pattern at one time in 4.2 was to do 'difference' transactions only. Then dgg pushed successfully for us to always do reversal and post new. That was the general pattern, except for this recently noticed outlier that did a difference transaction. |
@JoeMurray thanks - if you look at the code & overview this is about financial items |
@JoeMurray yes we are referring https://wiki.civicrm.org/confluence/display/CRM/CiviAccounts+Data+Flow here. And this PR is fixing a bug we encountered during the refund, which records few extraneous financial item that is causing an issue in bookkeeping entry (shown under Before section in 'financial_item' records ) Also an existing UT is extended to ensure the fix made in this PR We are also ensuring there is a reversal amount recorded whenever the price-option is changed that leads to refund (if its a lower price option then earlier) or partial payment (if its a higher price option then earlier) or financial type change as per dataflow |
I did r-run again and happy with the patch. Merging now. |
Per civicrm#15143 (comment) and https://github.com/civicrm/civicrm-core/pull/13114/files#diff-8967f6e57d6209aa277ded6512413608L326 it seems agreed the financial items should not be created on refund. This removes them & updates the test
Overview
Before
Financial items created when adding a refund to a contribution but @monishdeb - see https://github.com/civicrm/civicrm-core/pull/13114/files#diff-8967f6e57d6209aa277ded6512413608L326 and @pradpnayak - see comment below - have both said they should not be.
In this test we have the following events
These payments look as expected -
civicrm_financial_trxn
The final outcome is that the allocation in the civicrm_financial_item table is equal to the sum of payments $250 and the total of the entity_financial_trxns for this exceeds the amount paid
civicrm_financial_item
However, BEFORE we started adding payments the allocation was actually equal to the sum of the contribution.
civicrm_entity_financial_trxn - entity_table = civicrm_financial_item
civicrm_entity_financial_trxn - entity_table = civicrm_contribution
So prior to adding payments the financial_items allocated the total amount to pay (paid and unpaid) to the line items via financial items but in the end we would up with only the amount paid allocated. This feels wonky.
After
Only the original 2 financial items created. Test locks this change in.
Technical Details
Comments