check vat number prior to validation

This commit is contained in:
David Bomba 2025-08-15 10:57:35 +10:00
parent 2438bf9284
commit 7573c611cf
3 changed files with 54 additions and 28 deletions

View File

@ -31,7 +31,7 @@ class TaxService
$vat_check = (new VatNumberCheck($this->client->vat_number, $client_country_code))->run(); $vat_check = (new VatNumberCheck($this->client->vat_number, $client_country_code))->run();
nlog($vat_check); // nlog($vat_check);
if ($vat_check->isValid()) { if ($vat_check->isValid()) {

View File

@ -22,8 +22,13 @@ class VatNumberCheck
public function run() public function run()
{ {
if(strlen($this->vat_number ?? '') == ){
$this->response = ['valid' => false, 'error' => 'No VAT number provided'];
}
else{
return $this->checkvat_number(); return $this->checkvat_number();
} }
}
private function checkvat_number(): self private function checkvat_number(): self
{ {

View File

@ -1179,6 +1179,8 @@ $this->account->forceDelete();
public function testCreditJsonReport() public function testCreditJsonReport()
{ {
config(['queue.default' => 'redis']);
Credit::factory()->create([ Credit::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -1205,7 +1207,6 @@ $this->account->forceDelete();
'X-API-TOKEN' => $this->token, 'X-API-TOKEN' => $this->token,
])->postJson('/api/v1/reports/credits?output=json', $data); ])->postJson('/api/v1/reports/credits?output=json', $data);
$response->assertStatus(200); $response->assertStatus(200);
$arr = $response->json(); $arr = $response->json();
@ -1217,7 +1218,6 @@ $this->account->forceDelete();
$response->assertStatus(409); $response->assertStatus(409);
$this->account->forceDelete(); $this->account->forceDelete();
} }
@ -1285,7 +1285,7 @@ $this->account->forceDelete();
public function testInvoiceCustomColumnsCsvGeneration() public function testInvoiceCustomColumnsCsvGeneration()
{ {
\App\Models\Invoice::factory()->create([ $invoice = \App\Models\Invoice::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,
@ -1475,7 +1475,7 @@ $this->account->forceDelete();
public function testInvoiceItemsCustomColumnsCsvGeneration() public function testInvoiceItemsCustomColumnsCsvGeneration()
{ {
\App\Models\Invoice::factory()->create([ $invoice = \App\Models\Invoice::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,
@ -1642,7 +1642,6 @@ $this->account->forceDelete();
$csv = $response->body(); $csv = $response->body();
$this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Client Name')); $this->assertEquals('bob', $this->getFirstValueByColumn($csv, 'Client Name'));
$this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'Quote Number')); $this->assertEquals('1234', $this->getFirstValueByColumn($csv, 'Quote Number'));
$this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Item Quantity')); $this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Item Quantity'));
@ -1655,7 +1654,6 @@ $this->account->forceDelete();
$this->assertEquals('GST', $this->getFirstValueByColumn($csv, 'Item Tax Name 1')); $this->assertEquals('GST', $this->getFirstValueByColumn($csv, 'Item Tax Name 1'));
$this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Item Tax Rate 1')); $this->assertEquals('10', $this->getFirstValueByColumn($csv, 'Item Tax Rate 1'));
$data = [ $data = [
'date_range' => 'all', 'date_range' => 'all',
'report_keys' => $this->all_client_report_keys, 'report_keys' => $this->all_client_report_keys,
@ -1668,7 +1666,6 @@ $this->account->forceDelete();
'X-API-TOKEN' => $this->token, 'X-API-TOKEN' => $this->token,
])->post('/api/v1/reports/quote_items', $data)->assertStatus(200); ])->post('/api/v1/reports/quote_items', $data)->assertStatus(200);
$this->account->forceDelete(); $this->account->forceDelete();
} }
@ -1730,7 +1727,6 @@ $this->account->forceDelete();
$this->assertEquals('Private', $this->getFirstValueByColumn($csv, 'Purchase Order Private Notes')); $this->assertEquals('Private', $this->getFirstValueByColumn($csv, 'Purchase Order Private Notes'));
$this->assertEquals('Terms', $this->getFirstValueByColumn($csv, 'Purchase Order Terms')); $this->assertEquals('Terms', $this->getFirstValueByColumn($csv, 'Purchase Order Terms'));
$this->account->forceDelete(); $this->account->forceDelete();
} }
@ -1748,7 +1744,6 @@ $this->account->forceDelete();
] ]
); );
\App\Models\PurchaseOrder::factory()->create([ \App\Models\PurchaseOrder::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
@ -1896,11 +1891,25 @@ $this->account->forceDelete();
'balance' => 100, 'balance' => 100,
'number' => '12345', 'number' => '12345',
'status_id' => 2, 'status_id' => 2,
'discount' => 10, 'discount' => 0,
'po_number' => '1234', 'po_number' => '1234',
'public_notes' => 'Public', 'public_notes' => 'Public',
'private_notes' => 'Private', 'private_notes' => 'Private',
'terms' => 'Terms', 'terms' => 'Terms',
'tax_rate1' => 0,
'tax_rate2' => 0,
'tax_rate3' => 0,
'line_items' => [
[
'quantity' => 1,
'product_key' => 'product_key',
'notes' => 'notes',
'cost' => 100,
'custom_value1' => 'Custom 1',
'custom_value2' => 'Custom 2',
'custom_value3' => 'Custom 3',
]
]
]); ]);
$repo = new InvoiceRepository(); $repo = new InvoiceRepository();
@ -2019,6 +2028,20 @@ $this->account->forceDelete();
'public_notes' => 'Public', 'public_notes' => 'Public',
'private_notes' => 'Private', 'private_notes' => 'Private',
'terms' => 'Terms', 'terms' => 'Terms',
'tax_rate1' => 0,
'tax_rate2' => 0,
'tax_rate3' => 0,
'line_items' => [
[
'quantity' => 1,
'product_key' => 'product_key',
'notes' => 'notes',
'cost' => 110,
'custom_value1' => 'Custom 1',
'custom_value2' => 'Custom 2',
'custom_value3' => 'Custom 3',
]
]
]); ]);
$data = [ $data = [
@ -2034,8 +2057,6 @@ $this->account->forceDelete();
$response->assertStatus(200); $response->assertStatus(200);
$response->assertStatus(200);
$arr = $response->json(); $arr = $response->json();
$hash = $arr['message']; $hash = $arr['message'];
@ -2257,7 +2278,7 @@ $this->account->forceDelete();
public function testQuoteCsvGeneration() public function testQuoteCsvGeneration()
{ {
\App\Models\Quote::factory()->create([ $quote = \App\Models\Quote::factory()->create([
'user_id' => $this->user->id, 'user_id' => $this->user->id,
'company_id' => $this->company->id, 'company_id' => $this->company->id,
'client_id' => $this->client->id, 'client_id' => $this->client->id,