Merge pull request #21101 from eileenmcnaughton/inv3
authordemeritcowboy <demeritcowboy@hotmail.com>
Wed, 25 Aug 2021 16:24:17 +0000 (12:24 -0400)
committerGitHub <noreply@github.com>
Wed, 25 Aug 2021 16:24:17 +0000 (12:24 -0400)
[REF] Update a few references to invoicing

1  2 
CRM/Price/BAO/LineItem.php

index 2591f632e82ff0dee388415a8903b95ce3b7825a,d876651411c45f0d7fbfe72966282c8aa44e30cd..59868a458b308c4eaafb1800f212d013da723dc3
@@@ -214,8 -214,6 +214,6 @@@ WHERE li.contribution_id = %1"
      ];
  
      $getTaxDetails = FALSE;
-     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
-     $invoicing = $invoiceSettings['invoicing'] ?? NULL;
  
      $dao = CRM_Core_DAO::executeQuery("$selectClause $fromClause $whereClause $orderByClause", $params);
      while ($dao->fetch()) {
          $getTaxDetails = TRUE;
        }
      }
-     if ($invoicing) {
+     if (Civi::settings()->get('invoicing')) {
        // @todo - this is an inappropriate place to be doing form level assignments.
        $taxTerm = Civi::settings()->get('tax_term');
        $smarty = CRM_Core_Smarty::singleton();
            }
            $financialType = $values['financial_type_id'];
          }
 +        $taxRates = CRM_Core_PseudoConstant::getTaxRates();
 +        $taxRate = $taxRates[$financialType] ?? 0;
 +        $taxAmount = ($taxRate / 100) * $totalAmount / (1 + ($taxRate / 100));
          $lineItem = [
            'price_field_id' => $values['priceFieldID'],
            'price_field_value_id' => $values['priceFieldValueID'],
            'label' => $values['label'],
            'qty' => 1,
 -          'unit_price' => $totalAmount,
 -          'line_total' => $totalAmount,
 +          'unit_price' => $totalAmount - $taxAmount,
 +          'line_total' => $totalAmount - $taxAmount,
            'financial_type_id' => $financialType,
            'membership_type_id' => $values['membership_type_id'],
 +          'tax_amount' => $taxAmount,
          ];
 -        $lineItem['tax_amount'] = self::getTaxAmountForLineItem($lineItem);
          $params['line_item'][$values['setID']][$values['priceFieldID']] = $lineItem;
          break;
        }