Skip to content

Commit

Permalink
[REF] Minor simplification around assigning taxAmount to the template
Browse files Browse the repository at this point in the history
Just assign it based on the calculated tax amount for the contribution. If no tax then
just assign that to the tpl. Bye copy & paste
  • Loading branch information
eileenmcnaughton committed Mar 8, 2021
1 parent 2fa1dfc commit d5d1dca
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions CRM/Member/Form/Membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -1440,9 +1440,6 @@ public function submit(): void {
// This would always be true as we always add price set id into both
// quick config & non quick config price sets.
if (!empty($lineItem[$this->_priceSetId])) {
$invoicing = Civi::settings()->get('invoicing');
$taxAmount = FALSE;
$totalTaxAmount = 0;
foreach ($lineItem[$this->_priceSetId] as & $priceFieldOp) {
if (!empty($priceFieldOp['membership_type_id'])) {
$priceFieldOp['start_date'] = $membershipTypeValues[$priceFieldOp['membership_type_id']]['start_date'] ? CRM_Utils_Date::formatDateOnlyLong($membershipTypeValues[$priceFieldOp['membership_type_id']]['start_date']) : '-';
Expand All @@ -1451,12 +1448,8 @@ public function submit(): void {
else {
$priceFieldOp['start_date'] = $priceFieldOp['end_date'] = 'N/A';
}
if ($invoicing && isset($priceFieldOp['tax_amount'])) {
$taxAmount = TRUE;
$totalTaxAmount += $priceFieldOp['tax_amount'];
}
}
if ($invoicing) {
if (Civi::settings()->get('invoicing')) {
$dataArray = [];
foreach ($lineItem[$this->_priceSetId] as $key => $value) {
if (isset($value['tax_amount']) && isset($value['tax_rate'])) {
Expand All @@ -1468,11 +1461,10 @@ public function submit(): void {
}
}
}
if ($taxAmount) {
$this->assign('totalTaxAmount', $totalTaxAmount);

$this->assign('totalTaxAmount', $this->order->getTotalTaxAmount());
// Not sure why would need this on Submit.... unless it's being used when sending mails in which case this is the wrong place
$this->assign('taxTerm', $this->getSalesTaxTerm());
}
$this->assign('taxTerm', $this->getSalesTaxTerm());
$this->assign('dataArray', $dataArray);
}
}
Expand Down

0 comments on commit d5d1dca

Please sign in to comment.