diff --git a/app/Jobs/Account/CreateAccount.php b/app/Jobs/Account/CreateAccount.php index 4c04ffd8d27a..7c487ca8fe24 100644 --- a/app/Jobs/Account/CreateAccount.php +++ b/app/Jobs/Account/CreateAccount.php @@ -92,6 +92,8 @@ class CreateAccount $spaa9f78 = (new CreateUser($this->request, $sp794f3f, $sp035a66, true))->handle(); + $sp035a66->service()->localizeCompany($spaa9f78); + (new CreateCompanyPaymentTerms($sp035a66, $spaa9f78))->handle(); (new CreateCompanyTaskStatuses($sp035a66, $spaa9f78))->handle(); diff --git a/app/Jobs/Company/CreateCompany.php b/app/Jobs/Company/CreateCompany.php index bef3d17e4a1e..984c29993cd2 100644 --- a/app/Jobs/Company/CreateCompany.php +++ b/app/Jobs/Company/CreateCompany.php @@ -104,7 +104,7 @@ class CreateCompany if(request()->hasHeader('cf-ipcountry')) { - $c = Country::where('iso_3166_2', request()->header('cf-ipcountry'))->first(); + $c = Country::query()->where('iso_3166_2', request()->header('cf-ipcountry'))->first(); if($c) { return (string)$c->id; @@ -116,7 +116,7 @@ class CreateCompany if($details && property_exists($details, 'countryCode')) { - $c = Country::where('iso_3166_2', $details->countryCode)->first(); + $c = Country::query()->where('iso_3166_2', $details->countryCode)->first(); if($c) { return (string)$c->id; diff --git a/app/Models/Company.php b/app/Models/Company.php index d177a8108fc8..9b3096be8bff 100644 --- a/app/Models/Company.php +++ b/app/Models/Company.php @@ -23,6 +23,7 @@ use Laracasts\Presenter\PresentableTrait; use App\Utils\Traits\CompanySettingsSaver; use Illuminate\Notifications\Notification; use App\Models\Presenters\CompanyPresenter; +use App\Services\Company\CompanyService; use App\Services\Notification\NotificationService; use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\BelongsTo; @@ -974,4 +975,9 @@ class Company extends BaseModel return $this->e_invoice_certificate_passphrase; } + public function service(): CompanyService + { + return new CompanyService($this); + } + } diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index 6cfc427d9271..6204e86ad835 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -11,18 +11,19 @@ namespace Tests\Feature; -use App\DataMapper\CompanySettings; -use App\Http\Middleware\PasswordProtection; +use Tests\TestCase; use App\Models\Company; +use App\Models\TaxRate; +use Tests\MockAccountData; use App\Models\CompanyToken; use App\Utils\Traits\MakesHash; -use Illuminate\Database\Eloquent\Model; -use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Http\UploadedFile; +use App\DataMapper\CompanySettings; use Illuminate\Support\Facades\Log; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Facades\Session; -use Tests\MockAccountData; -use Tests\TestCase; +use App\Http\Middleware\PasswordProtection; +use Illuminate\Foundation\Testing\DatabaseTransactions; /** * @test @@ -49,6 +50,18 @@ class CompanyTest extends TestCase $this->makeTestData(); } + public function testCompanyTaxInit() + { + TaxRate::query()->delete(); + + $settings = $this->company->settings; + $settings->country_id = '40'; + $this->company->saveSettings($settings, $this->company); + + $this->company->service()->localizeCompany($this->user); + + $this->assertEquals(1, TaxRate::count()); + } public function testCompanyLogoInline() {