Assign tax_rate directly rather than looking up via financial_type
authoreileen <emcnaughton@wikimedia.org>
Mon, 22 Feb 2021 04:15:11 +0000 (17:15 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 22 Feb 2021 05:32:54 +0000 (18:32 +1300)
CRM/Member/Form/Membership.php
templates/CRM/Member/Form/Membership.tpl

index df2c662d4daee08e79421231b3fcb2713f595f96..212c0c67ba2a03ec592bd5444c2d56d56697ca95 100644 (file)
@@ -491,6 +491,7 @@ DESC limit 1");
         'total_amount' => CRM_Utils_Money::formatLocaleNumericRoundedForDefaultCurrency($totalAmount),
         'total_amount_numeric' => $totalAmount,
         'auto_renew' => $values['auto_renew'] ?? NULL,
+        'tax_rate' => $values['tax_rate'],
         'has_related' => isset($values['relationship_type_id']),
         'max_related' => $values['max_related'] ?? NULL,
       ];
index b9b252a5e3a531713f784bbf6206bf88ac97ff46..cdc3bdb7e9f6c2fa322e5f6b05ae0e1ed0851d34 100644 (file)
         // skip this for test and live modes because financial type is set automatically
         cj("#financial_type_id").val(membershipType['financial_type_id']);
         var term = cj('#num_terms').val();
-        var taxRates = {/literal}{$taxRates}{literal};
         var taxTerm = {/literal}{$taxTerm|@json_encode}{literal};
-        var taxRate = taxRates[membershipType['financial_type_id']];
         var currency = {/literal}{$currency_symbol|@json_encode}{literal};
         var taxExclusiveAmount = membershipType['total_amount_numeric'] * term;
-        var taxAmount = (taxRate/100)*taxExclusiveAmount;
+        var taxAmount = (membershipType['tax_rate']/100)*taxExclusiveAmount;
         taxAmount = isNaN (taxAmount) ? 0:taxAmount;
         cj("#total_amount").val(CRM.formatMoney(taxExclusiveAmount + taxAmount, true));
 
-        var taxMessage = taxRate!=undefined ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
+        var taxMessage = taxAmount > 0 ? 'Includes '+taxTerm+' amount of '+currency+' '+taxAmount:'';
         cj('.totaltaxAmount').html(taxMessage);
       }