From: deb.monish Date: Wed, 7 Mar 2018 14:03:27 +0000 (+0530) Subject: CRM-21756: Freeze total amount field on Edit Contribution if related to membership... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=6bc9ca96e14e9f4f11d4a67a8ac5476a914fe907;p=civicrm-core.git CRM-21756: Freeze total amount field on Edit Contribution if related to membership or Event registration --- diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 1a3ac14f9a..8bc4c44c07 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -646,6 +646,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP $this->add('select', 'from_email_address', ts('Receipt From'), $this->_fromEmails); $component = 'contribution'; + $componentDetails = []; if ($this->_id) { $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); if (CRM_Utils_Array::value('membership', $componentDetails)) { @@ -712,7 +713,6 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP // don't allow price set for contribution if it is related to participant, or if it is a pledge payment // and if we already have line items for that participant. CRM-5095 if ($buildPriceSet && $this->_id) { - $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); $pledgePaymentId = CRM_Core_DAO::getFieldValue('CRM_Pledge_DAO_PledgePayment', $this->_id, 'id', @@ -811,23 +811,24 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP ) ); - // if status is Cancelled freeze Amount, Payment Instrument, Check #, Financial Type, - // Net and Fee Amounts are frozen in AdditionalInfo::buildAdditionalDetail - if ($this->_id && ($this->_values['contribution_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Cancelled'))) { - if ($totalAmount) { - $totalAmount->freeze(); - } - $paymentInstrument->freeze(); - $trxnId->freeze(); - $financialType->freeze(); - } - // if contribution is related to membership or participant freeze Financial Type, Amount - if ($this->_id && isset($this->_values['tax_amount'])) { + if ($this->_id) { $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($this->_id); - if (CRM_Utils_Array::value('membership', $componentDetails) || CRM_Utils_Array::value('participant', $componentDetails)) { + $isCancelledStatus = ($this->_values['contribution_status_id'] == CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'contribution_status_id', 'Cancelled')); + + if (CRM_Utils_Array::value('membership', $componentDetails) || + CRM_Utils_Array::value('participant', $componentDetails) || + // if status is Cancelled freeze Amount, Payment Instrument, Check #, Financial Type, + // Net and Fee Amounts are frozen in AdditionalInfo::buildAdditionalDetail + $isCancelledStatus + ) { if ($totalAmount) { $totalAmount->freeze(); + $this->getElement('currency')->freeze(); + } + if ($isCancelledStatus) { + $paymentInstrument->freeze(); + $trxnId->freeze(); } $financialType->freeze(); $this->assign('freezeFinancialType', TRUE); diff --git a/templates/CRM/Contribute/Form/Contribution.tpl b/templates/CRM/Contribute/Form/Contribution.tpl index 9f47e46eae..da7bb1bb8f 100644 --- a/templates/CRM/Contribute/Form/Contribution.tpl +++ b/templates/CRM/Contribute/Form/Contribution.tpl @@ -97,6 +97,9 @@ {$form.total_amount.label} {$form.currency.html|crmAddClass:eight} {$form.total_amount.html|crmAddClass:eight} + {if $freezeFinancialType} + {help id="id-total_amount"} + {/if} {if !$payNow} {if $hasPriceSets} {ts}OR{/ts} diff --git a/templates/CRM/Contribute/Page/Tab.hlp b/templates/CRM/Contribute/Page/Tab.hlp index 435c41e4fa..630a0fb4c7 100644 --- a/templates/CRM/Contribute/Page/Tab.hlp +++ b/templates/CRM/Contribute/Page/Tab.hlp @@ -30,6 +30,13 @@ {ts}Optional identifier for the contribution source (campaign name, event, mailer, etc.).{/ts} {/htxt} +{htxt id="id-total_amount-title"} + {ts}Total Amount{/ts} +{/htxt} +{htxt id="id-total_amount"} +{ts 1='target="_blank" href="https://civicrm.org/extensions/line-item-editor"'}You are not allowed to change the total amount as it will lead to incorrect line item entries. You can either delete or recreate or install Line Item Editor.{/ts} +{/htxt} + {htxt id="id-financial_type-title"} {ts}Financial Type{/ts} {/htxt} @@ -78,7 +85,7 @@

{ts}When contributions are made via a Personal Campaign Page a soft credit (of type 'Personal Campaign Page') is automatically created and assigned to the 'owner' of the the Personal Campaign Page.{/ts}

-{/htxt} +{/htxt} {htxt id="adjust-payment-amount-title"} {ts}Payment Amount{/ts}