Skip to content

Commit

Permalink
Merge pull request #13839 from eileenmcnaughton/invoicing
Browse files Browse the repository at this point in the history
Minor code cleanup
  • Loading branch information
seamuslee001 authored Mar 16, 2019
2 parents 65c4df9 + ec5e7bc commit 2905735
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 2 additions & 4 deletions CRM/Contribute/Form/Contribution/ThankYou.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ public function buildQuickForm() {
}

$params = $this->_params;
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$invoicing = CRM_Invoicing_Utils::isInvoicingEnabled();
// Make a copy of line items array to use for display only
$tplLineItems = $this->_lineItem;
if ($invoicing) {
$getTaxDetails = FALSE;
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
foreach ($this->_lineItem as $key => $value) {
foreach ($value as $k => $v) {
if (isset($v['tax_rate'])) {
Expand All @@ -126,7 +124,7 @@ public function buildQuickForm() {
}
}
$this->assign('getTaxDetails', $getTaxDetails);
$this->assign('taxTerm', $taxTerm);
$this->assign('taxTerm', CRM_Invoicing_Utils::getTaxTerm());
$this->assign('totalTaxAmount', $params['tax_amount']);
}

Expand Down
6 changes: 2 additions & 4 deletions CRM/Event/Form/Registration/ThankYou.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,7 @@ public function buildQuickForm() {
}
$this->assignToTemplate();

$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
$taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
$invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
$invoicing = CRM_Invoicing_Utils::isInvoicingEnabled();
$getTaxDetails = FALSE;
$taxAmount = 0;

Expand Down Expand Up @@ -129,7 +127,7 @@ public function buildQuickForm() {
if ($invoicing) {
$this->assign('getTaxDetails', $getTaxDetails);
$this->assign('totalTaxAmount', $taxAmount);
$this->assign('taxTerm', $taxTerm);
$this->assign('taxTerm', CRM_Invoicing_Utils::getTaxTerm());
}
$this->assign('totalAmount', $this->_totalAmount);

Expand Down
11 changes: 11 additions & 0 deletions CRM/Invoicing/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,15 @@ public static function getDefaultPaymentPage() {
return CRM_Utils_Array::value('default_invoice_page', $invoiceSettings);
}

/**
* Function to get the tax term.
*
* The value is nested in the contribution_invoice_settings setting - which
* is unsupported. Here we have a wrapper function to make later cleanup easier.
*/
public static function getTaxTerm() {
$invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
return CRM_Utils_Array::value('tax_term', $invoiceSettings);
}

}

0 comments on commit 2905735

Please sign in to comment.