2023-03-19 05:09:50 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2023. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Services\Tax;
|
|
|
|
|
2023-03-21 22:00:20 +01:00
|
|
|
use App\Models\Client;
|
|
|
|
use App\Models\Company;
|
2023-03-26 22:14:10 +02:00
|
|
|
use App\Services\Tax\Providers\ZipTax;
|
2023-03-21 22:00:20 +01:00
|
|
|
|
2023-03-19 05:09:50 +01:00
|
|
|
|
|
|
|
class TaxService
|
|
|
|
{
|
|
|
|
|
|
|
|
public function __construct(protected Company $company, protected Client $client)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-03-29 05:23:06 +02:00
|
|
|
private function validateVat(): self
|
|
|
|
{
|
|
|
|
$client_country_code = $this->client->shipping_country ? $this->client->shipping_country->iso_3166_2 : $this->client->country->iso_3166_2;
|
|
|
|
|
|
|
|
$vat_check = (new VatNumberCheck($this->client->vat_number, $client_country_code))->run();
|
|
|
|
|
|
|
|
$this->client->has_valid_vat_number = $vat_check->isValid();
|
|
|
|
$this->client->saveQuietly();
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
}
|
2023-03-19 05:09:50 +01:00
|
|
|
}
|