diff --git a/app/DataMapper/Tax/US/Rule.php b/app/DataMapper/Tax/US/Rule.php index 24f65c9b5d..c1005a42cb 100644 --- a/app/DataMapper/Tax/US/Rule.php +++ b/app/DataMapper/Tax/US/Rule.php @@ -114,7 +114,7 @@ class Rule extends BaseRule implements RuleInterface */ public function taxService($item): self { - if($this->tax_data?->txbService == 'Y') { + if(in_array($this->tax_data?->txbService,['Y','L'])) { $this->default($item); } diff --git a/app/Http/Controllers/CompanyController.php b/app/Http/Controllers/CompanyController.php index 108d0d74ab..a7900a3f17 100644 --- a/app/Http/Controllers/CompanyController.php +++ b/app/Http/Controllers/CompanyController.php @@ -418,7 +418,7 @@ class CompanyController extends BaseController $this->saveDocuments($request->input('documents'), $company, false); } - if($request->has('e_invoice_certificate')){ + if($request->has('e_invoice_certificate') && !is_null($request->file("e_invoice_certificate"))){ $company->e_invoice_certificate = base64_encode($request->file("e_invoice_certificate")->get()); $company->save(); diff --git a/app/Http/Requests/Company/UpdateCompanyRequest.php b/app/Http/Requests/Company/UpdateCompanyRequest.php index f4070350a8..602bb3a0fe 100644 --- a/app/Http/Requests/Company/UpdateCompanyRequest.php +++ b/app/Http/Requests/Company/UpdateCompanyRequest.php @@ -54,7 +54,7 @@ class UpdateCompanyRequest extends Request $rules['work_email'] = 'email|nullable'; $rules['matomo_id'] = 'nullable|integer'; $rules['e_invoice_certificate_passphrase'] = 'sometimes|nullable'; - $rules['e_invoice_certificate'] = 'sometimes|file|mimes:p12,pfx,pem,cer,crt,der,txt,p7b,spc,bin'; + $rules['e_invoice_certificate'] = 'sometimes|nullable|file|mimes:p12,pfx,pem,cer,crt,der,txt,p7b,spc,bin'; // $rules['client_registration_fields'] = 'array'; if (isset($input['portal_mode']) && ($input['portal_mode'] == 'domain' || $input['portal_mode'] == 'iframe')) { diff --git a/tests/Feature/CompanyTest.php b/tests/Feature/CompanyTest.php index a8eb0c8e89..af02f493ea 100644 --- a/tests/Feature/CompanyTest.php +++ b/tests/Feature/CompanyTest.php @@ -143,6 +143,8 @@ class CompanyTest extends TestCase $company->settings = $settings; + nlog($company->toArray()); + $response = $this->withHeaders([ 'X-API-SECRET' => config('ninja.api_secret'), 'X-API-TOKEN' => $this->token, diff --git a/tests/Unit/Tax/TaxConfigTest.php b/tests/Unit/Tax/TaxConfigTest.php new file mode 100644 index 0000000000..df579795ad --- /dev/null +++ b/tests/Unit/Tax/TaxConfigTest.php @@ -0,0 +1,71 @@ +withoutMiddleware( + ThrottleRequests::class + ); + + $this->withoutExceptionHandling(); + + $this->makeTestData(); + + if(!config('services.tax.zip_tax.key')) + $this->markTestSkipped('No API keys to test with.'); + } + + public TaxProvider $tp; + + private function bootApi(Client $client) + { + $this->tp = new TaxProvider($this->company, $client); + } + + public function testStateResolution() + { + //infer state from zip + $client = Client::factory()->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'address1' => '400 Evelyn Pl', + 'city' =>'Beverley Hills', + 'state' =>'CA', + 'postal_code' =>90210, + 'country_id' => 840, + ]); + + $this->bootApi($client); + + $this->tp->updateClientTaxData(); + + } + +} \ No newline at end of file