CRM-16330 fix - Edit Contribution form validation on total amount is incorrect when...
authormonishdeb <monish.deb@webaccessglobal.com>
Thu, 7 May 2015 11:26:43 +0000 (16:56 +0530)
committermonishdeb <monish.deb@webaccessglobal.com>
Thu, 7 May 2015 11:26:43 +0000 (16:56 +0530)
https://issues.civicrm.org/jira/browse/CRM-16330

CRM/Contribute/Form/Contribution.php

index 77e5c21ae3b1a37be0555cf6bc018069ea61c0c8..e77e62ff4d932a2ca899d7dc8f2c79f186867492 100644 (file)
@@ -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');
       }