Issue Details (XML | Word | Printable)

Key: CRM-4724
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed/Completed
Priority: Trivial Trivial
Assignee: Donald A. Lobo
Reporter: Tom Kirkpatrick
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
CiviCRM

Ensure that financial details related to a contribution details are available in hook_civicrm_post

Created: 09/Jul/09 03:31 PM   Updated: 16/Jul/09 05:23 PM
Component/s: None
Affects Version/s: 2.2.8
Fix Version/s: 2.2.8

Time Tracking:
Not Specified

File Attachments: 1. Text File civicrm_2.2.7_pass_financial_data_to_hook_post.patch (2 kB)



 Description  « Hide
At the point where hook_civicrm_post is run for new contributions (through Contribute/Form/Contribution/Confirm.php), the financial data hasn't yet been saved to the financial_trxn table. $transaction->commit is called right at the end of processContribution() in Confirm.php, whereas CRM_Contribute_BAO_Contribution::add() is called midway down that function, which is where the post hook is fired and, the financial record is not written until right before the commit, after the call to the hook.

This means that the full details of the transaction are not available in hook_civicrm_post, making it impossible to for example, use this hook to send details of the transaction to another system via SOAP.

As a fix, I suggest altering processContribution in Confirm.php to pass in the extra details to CRM_Contribute_BAO_Contribution::add(). The details would still be stored in the financial_trxn table, but they would also be available immediately in the new $contribution object, and hence, in hook_civicrm_post()

 All   Comments   Work Log   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Tom Kirkpatrick added a comment - 09/Jul/09 03:51 PM
Perhaps not the best final solution, but it does work. The best thing would probably be to loose the financial_trxn table completely and move everything into the contribution table - there is currently a lot fof data duplication happening between these tables.

Donald A. Lobo added a comment - 16/Jul/09 05:23 PM

filed CRM-4752 to delete that table in a future relase