Fixes for surcharge visibility

This commit is contained in:
David Bomba 2022-07-01 17:51:35 +10:00
parent a20240b64f
commit af8ec95e2c
2 changed files with 7 additions and 3 deletions

View File

@ -60,6 +60,8 @@ class Design extends BaseDesign
public $company; public $company;
public $client_or_vendor_entity;
/** @var array */ /** @var array */
public $aging = []; public $aging = [];
@ -803,7 +805,7 @@ class Design extends BaseDesign
foreach ($taxes as $i => $tax) { foreach ($taxes as $i => $tax) {
$elements[1]['elements'][] = ['element' => 'div', 'elements' => [ $elements[1]['elements'][] = ['element' => 'div', 'elements' => [
['element' => 'span', 'content', 'content' => $tax['name'], 'properties' => ['data-ref' => 'totals-table-total_tax_' . $i . '-label']], ['element' => 'span', 'content', 'content' => $tax['name'], 'properties' => ['data-ref' => 'totals-table-total_tax_' . $i . '-label']],
['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->context['client']), 'properties' => ['data-ref' => 'totals-table-total_tax_' . $i]], ['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->client_or_vendor_entity), 'properties' => ['data-ref' => 'totals-table-total_tax_' . $i]],
]]; ]];
} }
} elseif ($variable == '$line_taxes') { } elseif ($variable == '$line_taxes') {
@ -816,13 +818,13 @@ class Design extends BaseDesign
foreach ($taxes as $i => $tax) { foreach ($taxes as $i => $tax) {
$elements[1]['elements'][] = ['element' => 'div', 'elements' => [ $elements[1]['elements'][] = ['element' => 'div', 'elements' => [
['element' => 'span', 'content', 'content' => $tax['name'], 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i . '-label']], ['element' => 'span', 'content', 'content' => $tax['name'], 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i . '-label']],
['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->context['client']), 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i]], ['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->client_or_vendor_entity), 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i]],
]]; ]];
} }
} elseif (Str::startsWith($variable, '$custom_surcharge')) { } elseif (Str::startsWith($variable, '$custom_surcharge')) {
$_variable = ltrim($variable, '$'); // $custom_surcharge1 -> custom_surcharge1 $_variable = ltrim($variable, '$'); // $custom_surcharge1 -> custom_surcharge1
$visible = (int)$this->entity->{$_variable} != 0 || $this->entity->{$_variable} != '0' || !$this->entity->{$_variable}; $visible = (int)$this->entity->{$_variable} > 0 || (int)$this->entity->{$_variable} < 0 || !$this->entity->{$_variable};
$elements[1]['elements'][] = ['element' => 'div', 'elements' => [ $elements[1]['elements'][] = ['element' => 'div', 'elements' => [
['element' => 'span', 'content' => $variable . '_label', 'properties' => ['hidden' => !$visible, 'data-ref' => 'totals_table-' . substr($variable, 1) . '-label']], ['element' => 'span', 'content' => $variable . '_label', 'properties' => ['hidden' => !$visible, 'data-ref' => 'totals_table-' . substr($variable, 1) . '-label']],

View File

@ -32,10 +32,12 @@ trait DesignHelpers
if (isset($this->context['vendor'])) { if (isset($this->context['vendor'])) {
$this->vendor = $this->context['vendor']; $this->vendor = $this->context['vendor'];
$this->client_or_vendor_entity = $this->context['vendor'];
} }
if (isset($this->context['client'])) { if (isset($this->context['client'])) {
$this->client = $this->context['client']; $this->client = $this->context['client'];
$this->client_or_vendor_entity = $this->context['client'];
} }
if (isset($this->context['entity'])) { if (isset($this->context['entity'])) {