dev/financial/issues/56, Fixed Financial item entries
authorPradeep Nayak <pradpnayak@gmail.com>
Wed, 22 May 2019 23:52:47 +0000 (00:52 +0100)
committerPradeep Nayak <pradpnayak@gmail.com>
Wed, 22 May 2019 23:58:22 +0000 (00:58 +0100)
CRM/Contribute/BAO/Contribution.php

index 6b7ae24cf49da5e35fce1f2f97fb281ed2515b03..a057a9674bd90de1fdd523286c4dbe31c846debf 100644 (file)
@@ -3788,15 +3788,17 @@ INNER JOIN civicrm_activity ON civicrm_activity_contact.activity_id = civicrm_ac
             elseif ($previousLineItemTotal != $lineItemDetails['line_total']) {
               $taxAmount -= CRM_Utils_Array::value('tax_amount', CRM_Utils_Array::value($fieldValueId, $previousLineItems), 0);
             }
-            $itemParams['amount'] = self::getMultiplier($params['contribution']->contribution_status_id, $context) * $taxAmount;
-            $itemParams['description'] = $taxTerm;
-            if ($lineItemDetails['financial_type_id']) {
-              $itemParams['financial_account_id'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount(
-                $lineItemDetails['financial_type_id'],
-                'Sales Tax Account is'
-              );
+            if ($taxAmount != 0) {
+              $itemParams['amount'] = self::getMultiplier($params['contribution']->contribution_status_id, $context) * $taxAmount;
+              $itemParams['description'] = $taxTerm;
+              if ($lineItemDetails['financial_type_id']) {
+                $itemParams['financial_account_id'] = CRM_Contribute_PseudoConstant::getRelationalFinancialAccount(
+                  $lineItemDetails['financial_type_id'],
+                  'Sales Tax Account is'
+                );
+              }
+              CRM_Financial_BAO_FinancialItem::create($itemParams, NULL, $trxnIds);
             }
-            CRM_Financial_BAO_FinancialItem::create($itemParams, NULL, $trxnIds);
           }
         }
       }