1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-26 19:27:12 +02:00
invoiceninja/app/Services/Tax/TaxService.php
2023-03-29 14:23:06 +11:00

37 lines
949 B
PHP

<?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;
use App\Models\Client;
use App\Models\Company;
use App\Services\Tax\Providers\ZipTax;
class TaxService
{
public function __construct(protected Company $company, protected Client $client)
{
}
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;
}
}