From: monishdeb Date: Thu, 7 May 2015 11:26:43 +0000 (+0530) Subject: CRM-16330 fix - Edit Contribution form validation on total amount is incorrect when... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f21310d85af2b6f130bbeb46d063cc1cc73b2681;p=civicrm-core.git CRM-16330 fix - Edit Contribution form validation on total amount is incorrect when tax is included https://issues.civicrm.org/jira/browse/CRM-16330 --- diff --git a/CRM/Contribute/Form/Contribution.php b/CRM/Contribute/Form/Contribution.php index 77e5c21ae3..e77e62ff4d 100644 --- a/CRM/Contribute/Form/Contribution.php +++ b/CRM/Contribute/Form/Contribution.php @@ -940,6 +940,16 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP if (!empty($fields['total_amount']) && (!empty($fields['net_amount']) || !empty($fields['fee_amount']))) { $sum = CRM_Utils_Rule::cleanMoney($fields['net_amount']) + CRM_Utils_Rule::cleanMoney($fields['fee_amount']); + // For taxable contribution we need to deduct taxable amount from + // (net amount + fee amount) before comparing it with total amount + if (!empty($self->_values['tax_amount'])) { + $componentDetails = CRM_Contribute_BAO_Contribution::getComponentDetails($self->_id); + if (!(CRM_Utils_Array::value('membership', $componentDetails) || + CRM_Utils_Array::value('participant', $componentDetails)) + ) { + $sum = CRM_Utils_Money::format($sum - $self->_values['tax_amount'], NULL, '%a'); + } + } if (CRM_Utils_Rule::cleanMoney($fields['total_amount']) != $sum) { $errors['total_amount'] = ts('The sum of fee amount and net amount must be equal to total amount'); }