-
-
Notifications
You must be signed in to change notification settings - Fork 825
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
dev/financial#34 : Incorrect allocation of payment on an edited multi-line item event registration #13114
Conversation
(Standard links)
|
4e59d09
to
61feab9
Compare
61feab9
to
1db6762
Compare
@monishdeb failing check... |
3f07d19
to
20b31bb
Compare
@monishdeb I've just followed the steps detailed above on an existing event registration. I made a change to reduce the quantity. The event transaction looks correct (they have a quantity of 1 not 2). However the refund was pro rated against all financial types in the contribution record as oppose to applying to the financial type that was reduced. I also get a line item on the bookkeeping report with a Debit to Accounts Receivable and no credit account. If I add to the event registration, I still get the odd line item with a debit to A/R but no credit account. The additional item is recorded properly with the correct financial account and Type. Let me know what more details i can share with you so you can replicate the issue. cc @JoeMurray |
Thanks, @kcristiano for notifying that odd behavior. Will let you know after the fix. |
@monishdeb could you update here? |
20b31bb
to
fc83bdb
Compare
@kcristiano @JoeMurray sorry for the delay. I have fixed the issue on refund and updated this PR Here's a CSV file of financial entries created after doing a refund on event fee change - Financial_Transactions_2_20181205023626.csv
Please have a look. |
@monishdeb I have applied the patch and tested again. I am still not getting the desired results. The refund is allocating across all financial Types in the transaction Removing an event option (decrease): Adding an event option (decrease) |
Hi @kcristiano, thanks for your feedback. I have tried again with decreasing the event ticket by choosing the lesser amount. And I did not found the proportional allocation of the amount across financial types. Here's a screencast, which shows the database entries, esp. the financial item records where after refund only one financial record receive the refund (-$15 here) and other $0: Can you please help me replicating the refund scenario, by mentioning the steps? Please feel free to ping me (alias @Monish) in mattermost. |
The difference I can see is that I am changing the options (Price set line items) by selecting/deselecting and not changing quantities. I can provide a copy of the database(s) I am suing to test. Ping me if you want a download link. |
Thank you for continuing to test @monishdeb let me know if there is anything else I can share to help you troubleshoot. We are using Price sets with multiple items. The first item is the event registration. the rest are 'add-ons' which will have different financial types. They are part of the event and changing these (adding/removing) causes the issue. |
@kcristiano thanks for your support. I'll look into this issue and will update this PR. However I was thinking, wouldn't it be appropriate if there is a separate sub ticket in gitlab? because the original gitlab ticket is about fixing the incorrect proportional allocation of amounts after doing partial payment. And the new issue which we came to know here is a similar issue with the financial transaction after doing refund payment. So should I create a separate sub-ticket and therefore submit a new PR which will dependent on this PR to keep things simple and it would easier for core team to review? |
@monishdeb I don't think that https://lab.civicrm.org/dev/financial/issues/34 which is incorrect allocation is linked to partial payments at all. At least not my reading of this issue. The problems we have seen are due to allocations of edited items, not partial payments. |
My apologies if I am drawing the current issue into respective separate tasks based on different use-cases. As in https://lab.civicrm.org/dev/financial/issues/34 explain a use-case where, after increasing the quantity of an item, changes the original completed contribution to a partial payment, completing which leads to incorrect allocation of payments to multiple transactions. On further testing, we found another use-case where on decreasing/changing the item to a lesser amount also leads to the same issue (after paying refund). I will treat those as a common issue which is about incorrect allocations of payment after fee-change. Will let you know after I fix that last issue. Thanks! |
@monishdeb Thank you for the further testing. The issue we had did not involve a partial payment. I do see where this issue is speaking to an incorrect allocation after the contribution changes to a partial payment status. I agree that these are a common issue and based on the testing we've both done, the allocation occurs regardless of the partial payment or refund pending status. |
@monishdeb have you been able to replicate the issue we have? Please let us know if there is anything we can do to help with this. |
0ea6fb8
to
8d9ba8d
Compare
Sorry @kcristiano for the delay (as I was on vacation). I have updated the PR, can you please check now? |
@monishdeb Thank You - I will test the functionality and report back here. I do agree that the above test failure will need to be addressed. But I'll focus on the functionality. |
@monishdeb I just applied the patch and attempted to remove a line item. Rather than affect only the line item removed, the amounts were prorated. Steps: Register for an event with multiple options and a price set |
@kcristiano I have rebased this PR. Waiting for CT to merge it as the test build passed earlier. |
Thanks @monishdeb Can you check the current test failure? |
0831a6f
to
f5a6506
Compare
Jenkins test this please |
This PR is causing some pretty weird errors with the tests: https://chat.civicrm.org/civicrm/pl/z1pwd9rhrjrydp8ta8senmhfta |
CRM/Core/BAO/FinancialTrxn.php
Outdated
@@ -726,8 +726,8 @@ public static function updateFinancialAccountsOnPaymentInstrumentChange($inputPa | |||
$trxnParams = [ | |||
'total_amount' => $trxn->total_amount, | |||
'contribution_id' => $currentContribution->id, | |||
]; | |||
CRM_Contribute_BAO_Contribution::assignProportionalLineItems($trxnParams, $trxn->id, $prevContribution->total_amount); | |||
); |
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.
@monishdeb Syntax error ^
CRM/Financial/Form/PaymentEdit.php
Outdated
]; | ||
$contributionTotalAmount = CRM_Core_DAO::getFieldValue('CRM_Contribute_BAO_Contribution', $this->_contributionID, 'total_amount'); | ||
CRM_Contribute_BAO_Contribution::assignProportionalLineItems($trxnParams, $financialTrxn['id'], $contributionTotalAmount); | ||
); |
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.
^
…ine item event registration
The reason I've been staying away from this PR is the addPayments function seems like 'yet another way to add payments to a contribution that is inconsistent with other methods'. I'm not reviewing any work around payments /partial payments / financials until we resolve consolidating the back office form payment add with the api payment.create (currently stalled on this PR #13689 ) I would think after that we'd want to try to get addPayments to call payment.create |
Jenkins test this please |
@eileenmcnaughton as #13689 has been merged, what is the status of this PR. We've had this in production for about 3 months (5.10.x) and it's critical to our clients. |
@eileenmcnaughton Just updating here based on our conversation. The issue we have with clients is that with a price set where Financial Types/Accounts are different for each line item (which seems to be common for our use cases) the following happens on editing say an event registration
Obviously this PR must now be rebased, but beyond that, what needs to be done to be merge ready? |
We're highly interested in moving this forward. |
Very interested on our end as well :) |
This has some content from this PR (ie from the test) #14589 |
@JoeMurray The changes through #14589 (comment) have made this PR "unmergable" #14589 moves us forward. I think that we may want to look at what needs to be done based on that PR in order to move this forward |
@kcristiano @JoeMurray I think the related changes have got a clear path through to completion - I've been chipping away at . it - but only as fast as I've been able to get review on the pieces along the way - but basically we get Payment.create right and then call that from the additional payment form |
Current movement on this issue is in #14763 - agreed with @kcristiano to close this one |
Overview
Edit of one line item previously led to changed allocations on more than one line item. This has been fixed so only the edited line item has new financial entries associated with it.
Steps to replicate:
Before
At Contributions > Accounting Batches > Open Batches, select the batch just created and export as csv, open and view the resulting transactions: Financial_Transactions_3_20180807210702
After
Financial_Transactions_3_20181119192008.csv
RESULT: If you compare both the CSV results, each file show same number of records in which first two records represent the financial entries for respective tickets ($25 and $10), third entry is the financial entry created to indicate the outstanding balance of $40 and is payable (i.e. is_payment = FALSE). For the last two entries the amount differ whereas now after the fix $40 is being assigned to Ticket2 (as qty is changed from 1 to 5, thus amount $10 is changed to $50) and $0 to Ticket 1 unlike earlier where amount is proportionally distributed to two tickets on basis of total contribution amount, instead of financial item's amount
Technical Details
I have changed the algorithm to do allocation on basis of financial_item.amount. Ensured that proportional allocation of financial items, in case of partial payment is not changed and we already have existing UTs for this.
In addition I have made changes in various unit test which does not follow the standard approach to change amount of a existing contribution (in order to calculate proportional amount allocation to different line-items).
Comments
ping @JoeMurray @kcristiano @pradpnayak @eileenmcnaughton @mattwire