diff --git a/app/Services/PdfMaker/Design.php b/app/Services/PdfMaker/Design.php index 838eb4f4daa9..b3b196d00de4 100644 --- a/app/Services/PdfMaker/Design.php +++ b/app/Services/PdfMaker/Design.php @@ -499,20 +499,6 @@ class Design extends BaseDesign $tbody = []; - // foreach ($this->payments as $payment) { - // foreach ($payment->invoices as $invoice) { - // $element = ['element' => 'tr', 'elements' => []]; - - // $element['elements'][] = ['element' => 'td', 'content' => $invoice->number]; - // $element['elements'][] = ['element' => 'td', 'content' => $this->translateDate($payment->date, $this->client->date_format(), $this->client->locale()) ?: ' ']; - // $element['elements'][] = ['element' => 'td', 'content' => $payment->type ? $payment->type->name : ctrans('texts.manual_entry')]; - // $element['elements'][] = ['element' => 'td', 'content' => Number::formatMoney($payment->amount, $this->client) ?: ' ']; - - // $tbody[] = $element; - // } - // } - - //24-03-2022 show payments per invoice foreach ($this->invoices as $invoice) { foreach ($invoice->payments as $payment) { @@ -816,7 +802,7 @@ class Design extends BaseDesign foreach ($taxes as $i => $tax) { $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' => Number::formatMoney($tax['total'], $this->client_or_vendor_entity), 'properties' => ['data-ref' => 'totals-table-total_tax_' . $i]], + ['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->entity instanceof \App\Models\PurchaseOrder ? $this->company : $this->client_or_vendor_entity), 'properties' => ['data-ref' => 'totals-table-total_tax_' . $i]], ]]; } } elseif ($variable == '$line_taxes') { @@ -829,13 +815,13 @@ class Design extends BaseDesign foreach ($taxes as $i => $tax) { $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' => Number::formatMoney($tax['total'], $this->client_or_vendor_entity), 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i]], + ['element' => 'span', 'content', 'content' => Number::formatMoney($tax['total'], $this->entity instanceof \App\Models\PurchaseOrder ? $this->company : $this->client_or_vendor_entity), 'properties' => ['data-ref' => 'totals-table-line_tax_' . $i]], ]]; } } elseif (Str::startsWith($variable, '$custom_surcharge')) { $_variable = ltrim($variable, '$'); // $custom_surcharge1 -> custom_surcharge1 - $visible = (int)$this->entity->{$_variable} > 0 || (int)$this->entity->{$_variable} < 0 || !$this->entity->{$_variable}; + $visible = intval($this->entity->{$_variable}) != 0; $elements[1]['elements'][] = ['element' => 'div', 'elements' => [ ['element' => 'span', 'content' => $variable . '_label', 'properties' => ['hidden' => !$visible, 'data-ref' => 'totals_table-' . substr($variable, 1) . '-label']], diff --git a/app/Utils/Number.php b/app/Utils/Number.php index 08777afe5bc2..7ff06174939b 100644 --- a/app/Utils/Number.php +++ b/app/Utils/Number.php @@ -13,6 +13,7 @@ namespace App\Utils; use App\Models\Company; use App\Models\Currency; +use App\Models\Vendor; /** * Class Number. @@ -118,6 +119,7 @@ class Number */ public static function formatMoney($value, $entity) :string { + $currency = $entity->currency(); $thousand = $currency->thousand_separator;