CRM-13973 : corrected the to_financial_account_id vals while selection changes
authorPratik Joshi <pratik.joshi@webaccess.co.in>
Tue, 21 Jan 2014 16:03:21 +0000 (21:33 +0530)
committerPratik Joshi <pratik.joshi@webaccess.co.in>
Tue, 21 Jan 2014 16:03:21 +0000 (21:33 +0530)
CRM/Event/BAO/Participant.php

index 9b6d28d18024128607559373271d22e5ec7bb00e..c3166402c0776e2c85573814ace09ad41b7c2a03 100644 (file)
@@ -1861,11 +1861,13 @@ WHERE (li.entity_table = 'civicrm_participant' AND li.entity_id = {$participantI
         CRM_Contribute_BAO_Contribution::getValues(array('id' => $contributionId), CRM_Core_DAO::$_nullArray, CRM_Core_DAO::$_nullArray);
       $prevTrxnId = CRM_Core_BAO_FinancialTrxn::getFinancialTrxnId($contributionId);
       $fetchPrevTrxn['id'] = $prevTrxnId['financialTrxnId'];
-      $prevTrxnToFinancialId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_FinancialTrxn', $prevTrxnId['financialTrxnId'], 'to_financial_account_id');
+
+      $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Accounts Receivable Account is' "));
+      $toFinancialAccount = CRM_Contribute_PseudoConstant::financialAccountType($updatedContribution->financial_type_id, $relationTypeId);
 
       $adjustedTrxnValues = array(
         'from_financial_account_id' => NULL,
-        'to_financial_account_id' => $prevTrxnToFinancialId,
+        'to_financial_account_id' => $toFinancialAccount,
         'trxn_date' => date('YmdHis'),
         'total_amount' => $balanceAmt,
         'currency' => $updatedContribution->currency,