PR 14763 moves the issue forward, adds tests and fixes (for the most part) adding additional items to event registrations.
This issue is to track what work needs to be done to correct refunds and other issues we have uncovered.
After PR 14763 is merged the gaps expected are:
receive date is updated for all line items not just the affected line items
refunds still need to be handled
null accounts in bookkeeping report
test with taxes
test with live Payment processor to reflect fees
This is a ample bookig report that shows the issue with Null Accounts:
The event/participantListing report shows:
All 3 scenarios should have the restult: amount 100, already paid 50, balance due 50
(When I edit all 3 contributions this shows perfectly, only the report is off)
I know this wrong reporting is not the topic here, I wanted to post because I also get the empty account codes and missing financial type records in the bookkeeping report, as shown in my first screenshot.
@magnolia61 Did the PR introduce any new issues/regressions? I found it solved the allocation issue when adding to an event (additional payment needed), while not solving the issues mentioned at the top of this issue.
I did not find any regressions, but if you did please let us know.
It would be useful to create a clean-up procedure for payments already made and the extraneous items that were created. Please think along if the flowing is legit:
Firstly this query:
SELECT * FROM civicrm_financial_trxn ft LEFT JOIN civicrm_entity_financial_trxn eft ON ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_financial_item' WHERE eft.id IS NULL AND ft.is_payment = 1;
and to delete those:
DELETE ft FROM civicrm_financial_trxn ft LEFT JOIN civicrm_entity_financial_trxn eftON ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_financial_item' WHERE eft.id IS NULL AND ft.is_payment = 1;
After that I noticed more 'ghost' financial transactions without trnx_id.
SELECT *FROM `civicrm_entity_financial_trxn`WHERE `financial_trxn_id` IS NULL;
and to delete those:
DELETEFROM `civicrm_entity_financial_trxn`WHERE `financial_trxn_id` IS NULL;
I am wondering if we have rogue 'amount = 0' items that also clutter the bookkeeping.
These were created during canceled registrations and refunds.
SELECT * FROM civicrm_financial_trxn ft LEFT JOIN civicrm_entity_financial_trxn eft ON ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_financial_item' WHERE ft.total_amount = 0 AND ft.is_payment = 1;
DELETE ft FROM civicrm_financial_trxn ft LEFT JOIN civicrm_entity_financial_trxn eft ON ft.id = eft.financial_trxn_id AND eft.entity_table = 'civicrm_financial_item' WHERE ft.total_amount = 0 AND ft.is_payment = 1;
WARNING: Of all these repair queries I am not sure yet if they are valid. Please comment and help come up with something solid. :-)
@eileen@kcristiano How about the mysql cleanup for civicrm_financial_trxn and civicrm_entity_financial_trxn? Would it be wise to include this in the update script or would another way of offering this cleanup be better?
@magnolia61 I guess we could add a status check for them. I think that is just the extraneous ones we can clean up - not all the other variants of problems here