From 636b20c5836f3128c729b6f29bf4cb810b42ab26 Mon Sep 17 00:00:00 2001 From: eileen Date: Fri, 5 Feb 2016 00:33:33 +1300 Subject: [PATCH] CRM-17951 modify transaction view to show the financial account of the transaction Previously it was showing the financial type of the contribution - but the payment could have a different financial account, although that would not be the norm and for most users no difference would be apparent. I added a group_concat in case there are multiple accounts associated with a transaction now, or in the future. Note we have separately discussed exposing line item detail - this got stalled on how to make it look tidy in the UI --- CRM/Contribute/BAO/Contribution.php | 26 +++++++++++++------ .../CRM/Contribute/Form/AdditionalPayment.tpl | 7 +---- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CRM/Contribute/BAO/Contribution.php b/CRM/Contribute/BAO/Contribution.php index e49d8a7b87..3dd2642661 100644 --- a/CRM/Contribute/BAO/Contribution.php +++ b/CRM/Contribute/BAO/Contribution.php @@ -3959,12 +3959,22 @@ WHERE eft.financial_trxn_id IN ({$trxnId}, {$baseTrxnId['financialTrxnId']}) if ($getTrxnInfo && $baseTrxnId) { // Need to exclude fee trxn rows so filter out rows where TO FINANCIAL ACCOUNT is expense account $sql = " -SELECT ft.total_amount, con.financial_type_id, ft.payment_instrument_id, ft.trxn_date, ft.trxn_id, ft.status_id, ft.check_number -FROM civicrm_contribution con - LEFT JOIN civicrm_entity_financial_trxn eft ON (eft.entity_id = con.id AND eft.entity_table = 'civicrm_contribution') - INNER JOIN civicrm_financial_trxn ft ON ft.id = eft.financial_trxn_id AND ft.to_financial_account_id != {$feeFinancialAccount} -WHERE con.id = {$contributionId} -"; + SELECT GROUP_CONCAT(fa.`name`) as financial_account, + ft.total_amount, + ft.payment_instrument_id, + ft.trxn_date, ft.trxn_id, ft.status_id, ft.check_number + + FROM civicrm_contribution con + LEFT JOIN civicrm_entity_financial_trxn eft ON (eft.entity_id = con.id AND eft.entity_table = 'civicrm_contribution') + INNER JOIN civicrm_financial_trxn ft ON ft.id = eft.financial_trxn_id + AND ft.to_financial_account_id != {$feeFinancialAccount} + INNER JOIN civicrm_entity_financial_trxn ef ON (ef.financial_trxn_id = ft.id AND ef.entity_table = 'civicrm_financial_item') + LEFT JOIN civicrm_financial_item fi ON fi.id = ef.entity_id + INNER JOIN civicrm_financial_account fa ON fa.id = fi.financial_account_id + + WHERE con.id = {$contributionId} + GROUP BY ft.id + "; // conditioned WHERE clause if ($isBalance) { @@ -3974,13 +3984,13 @@ WHERE con.id = {$contributionId} $resultDAO = CRM_Core_DAO::executeQuery($sql); $statuses = CRM_Contribute_PseudoConstant::contributionStatus(); - $financialTypes = CRM_Contribute_PseudoConstant::financialType(); + while ($resultDAO->fetch()) { $paidByLabel = CRM_Core_PseudoConstant::getLabel('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id); $paidByName = CRM_Core_PseudoConstant::getName('CRM_Core_BAO_FinancialTrxn', 'payment_instrument_id', $resultDAO->payment_instrument_id); $val = array( 'total_amount' => $resultDAO->total_amount, - 'financial_type' => $financialTypes[$resultDAO->financial_type_id], + 'financial_type' => $resultDAO->financial_account, 'payment_instrument' => $paidByLabel, 'receive_date' => $resultDAO->trxn_date, 'trxn_id' => $resultDAO->trxn_id, diff --git a/templates/CRM/Contribute/Form/AdditionalPayment.tpl b/templates/CRM/Contribute/Form/AdditionalPayment.tpl index 2619a88aa9..b28af1edfe 100644 --- a/templates/CRM/Contribute/Form/AdditionalPayment.tpl +++ b/templates/CRM/Contribute/Form/AdditionalPayment.tpl @@ -51,12 +51,7 @@ {else} {assign var='entity' value=$component} {/if} - {if $suppressPaymentFormButtons} - {ts 1=$entity}No payments found for this %1 record{/ts} - {else} - {* Am unsure where this appears so unsure if above text could apply *} - {ts 1=$entity}No Additional payments found for this %1 record{/ts} - {/if} + {ts 1=$entity}No payments found for this %1 record{/ts} {/if} {if !$suppressPaymentFormButtons}
-- 2.25.1