From 352cae98083e8b0f0276a796ce07ddcd74916c15 Mon Sep 17 00:00:00 2001 From: Pradeep Nayak Date: Fri, 26 Aug 2016 03:37:53 +0530 Subject: [PATCH] CRM-16189, added condition to create account receivable entry for completed contribution ---------------------------------------- * CRM-16189: https://issues.civicrm.org/jira/browse/CRM-16189 --- CRM/Contribute/BAO/Contribution.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index 8cf69fa347..8da6c326fe 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -5323,10 +5323,16 @@ LEFT JOIN civicrm_contribution on (civicrm_contribution.contact_id = civicrm_co $statusId = $contributionParams['contribution']->contribution_status_id; $contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name'); $contributionStatus = empty($statusId) ? NULL : $contributionStatuses[$statusId]; + $previousContributionStatus = empty($contributionParams['prevContribution']) ? NULL : $contributionStatuses[$contributionParams['prevContribution']->contribution_status_id]; // Return if contribution status is not completed. - if ($contributionStatus != 'Completed') { + if (!($contributionStatus == 'Completed' && (empty($previousContributionStatus) + || (!empty($previousContributionStatus) && $previousContributionStatus == 'Pending' + && $contributionParams['prevContribution']->is_pay_later == 0 + ))) + ) { return NULL; } + $params = $trxnParams; $financialTypeID = CRM_Utils_Array::value('financial_type_id', $contributionParams) ? $contributionParams['financial_type_id'] : $contributionParams['prevContribution']->financial_type_id; $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' ")); -- 2.25.1