From 78256510c74a8ae7cc67b62e2954c3c916f66926 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sat, 5 Oct 2024 17:39:36 +1000 Subject: [PATCH] Helpers for new zealand --- app/Jobs/Company/CreateCompany.php | 17 +++++++++++++++++ app/Repositories/ExpenseRepository.php | 3 ++- app/Services/Company/CompanyService.php | 5 ++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/Jobs/Company/CreateCompany.php b/app/Jobs/Company/CreateCompany.php index 7189ba8e5e..9e1c52f199 100644 --- a/app/Jobs/Company/CreateCompany.php +++ b/app/Jobs/Company/CreateCompany.php @@ -84,6 +84,7 @@ class CreateCompany '724' => $company = $this->spanishSetup($company), '36' => $company = $this->australiaSetup($company), '710' => $company = $this->southAfticaSetup($company), + '554' => $company = $this->newZealandSetup($company), default => $company->save(), }; @@ -131,6 +132,22 @@ class CreateCompany } + private function newZealandSetup($company): Company + { + + $company->enabled_tax_rates = 1; + + $settings = $company->settings; + $settings->currency_id = '15'; + $settings->timezone_id = '113'; + + $company->settings = $settings; + + $company->save(); + + return $company; + } + private function spanishSetup(Company $company): Company { try { diff --git a/app/Repositories/ExpenseRepository.php b/app/Repositories/ExpenseRepository.php index 54feb00958..b42b2b3710 100644 --- a/app/Repositories/ExpenseRepository.php +++ b/app/Repositories/ExpenseRepository.php @@ -121,7 +121,8 @@ class ExpenseRepository extends BaseRepository $exchange_rate = new CurrencyApi(); $expense->exchange_rate = $exchange_rate->exchangeRate($expense_currency, $company_currency, Carbon::parse($expense->date)); - + $expense->invoice_currency_id = $company_currency; + return $expense; } diff --git a/app/Services/Company/CompanyService.php b/app/Services/Company/CompanyService.php index 7ad29590c9..d8464347b0 100644 --- a/app/Services/Company/CompanyService.php +++ b/app/Services/Company/CompanyService.php @@ -56,7 +56,10 @@ class CompanyService case '724': // Spain $taxes[] = ['name' => 'IVA', 'rate' => 21]; break; - + case '554': // New Zealand + $taxes[] = ['name' => 'GST', 'rate' => 15]; + break; + default: return; }