From 721bc60f64ca25d00b110db9e1f7955a4e0c2a0b Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 9 Aug 2023 10:26:47 +1000 Subject: [PATCH] Update texts for tax info placeholders --- app/Models/Client.php | 2 +- app/Models/Company.php | 2 +- app/Utils/HtmlEngine.php | 37 ++++++++++++++++++++++++++++++++++++- lang/en/texts.php | 3 +++ 4 files changed, 41 insertions(+), 3 deletions(-) diff --git a/app/Models/Client.php b/app/Models/Client.php index 570e497ebc2d..9f69bfc0d1a3 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -58,7 +58,7 @@ use Illuminate\Contracts\Translation\HasLocalePreference; * @property string|null $city * @property string|null $state * @property string|null $postal_code - * @property string|null $country_id + * @property int|null $country_id * @property string|null $custom_value1 * @property string|null $custom_value2 * @property string|null $custom_value3 diff --git a/app/Models/Company.php b/app/Models/Company.php index 5fb8a4477791..0c8ac30a5990 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -58,7 +58,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo; * @property string|null $portal_domain * @property int $enable_modules * @property object $custom_fields - * @property object $settings + * @property \App\DataMapper\CompanySettings $settings * @property string $slack_webhook_url * @property string $google_analytics_key * @property int|null $created_at diff --git a/app/Utils/HtmlEngine.php b/app/Utils/HtmlEngine.php index 621568d2d0f2..01e4efd532c4 100644 --- a/app/Utils/HtmlEngine.php +++ b/app/Utils/HtmlEngine.php @@ -35,16 +35,22 @@ class HtmlEngine use MakesHash; use DesignCalculator; + /** @var \App\Models\Invoice | \App\Models\Credit | \App\Models\RecurringInvoice | \App\Models\Quote $entity **/ public $entity; + /** @var \App\Models\CreditInvitation | CreditInvitation | \App\Models\RecurringInvoiceInvitation | \App\Models\QuoteInvitation $invitation **/ public $invitation; + /** @var \App\Models\Client $client */ public $client; + /** @var \App\Models\ClientContact $contact */ public $contact; + /** @var \App\Models\Company $company */ public $company; + /** @var \App\DataMapper\CompanySettings $settings **/ public $settings; public $entity_calc; @@ -53,6 +59,13 @@ class HtmlEngine private $helpers; + + /** + * __construct + * + * @param InvoiceInvitation | CreditInvitation | RecurringInvoiceInvitation | QuoteInvitation $invitation + * @return void + */ public function __construct($invitation) { $this->invitation = $invitation; @@ -150,7 +163,9 @@ class HtmlEngine $data['$payment_link'] = ['value' => $this->invitation->getPaymentLink(), 'label' => ctrans('texts.pay_now')]; $data['$payment_qrcode'] = ['value' => $this->invitation->getPaymentQrCode(), 'label' => ctrans('texts.pay_now')]; $data['$exchange_rate'] = ['value' => $this->entity->exchange_rate ?: ' ', 'label' => ctrans('texts.exchange_rate')]; - + $data['$triangular_tax'] = ['value' => ctrans('texts.triangular_tax'), 'label' => '']; + $data['$tax_info'] = ['value' => $this->taxLabel(), 'label' => '']; + if ($this->entity_string == 'invoice' || $this->entity_string == 'recurring_invoice') { $data['$entity'] = ['value' => ctrans('texts.invoice'), 'label' => ctrans('texts.invoice')]; $data['$number'] = ['value' => $this->entity->number ?: ' ', 'label' => ctrans('texts.invoice_number')]; @@ -676,6 +691,26 @@ class HtmlEngine return $data; } + + /** + * Returns a localized string for tax compliance purposes + * + * @return string + */ + private function taxLabel(): string + { + $tax_label = ''; + + if (collect($this->entity->line_items)->contains('tax_id', \App\Models\Product::PRODUCT_TYPE_REVERSE_TAX)) { + $tax_label .= ctrans('texts.reverse_tax_info') . "\n"; + } + + if($this->client->country_id !== (int)$this->company->settings->country_id){ + $tax_label .= ctrans('texts.tax_info') . "\n"; + } + + return $tax_label; + } private function getBalance() { diff --git a/lang/en/texts.php b/lang/en/texts.php index d75fe8f3bbda..01cd88c8b0df 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5143,6 +5143,9 @@ $LANG = array( 'is_tax_exempt' => 'Tax Exempt', 'drop_files_here' => 'Drop files here', 'upload_files' => 'Upload Files', + 'triangular_tax_info' => 'Intra-community triangular transaction', + 'intracommunity_tax_info' => 'Tax-free intra-community delivery', + 'reverse_tax_info' => 'Please note that this supply is subject to reverse charge', ); return $LANG;