feat(billing): renewals, coupons, VAT numbering, billing cycles and invoice payment tracking
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
ea9a53f742
commit
25f23d541e
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Api\Client;
|
||||
|
||||
use App\Models\Customer;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class BillingProfileTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
private function as(Customer $customer)
|
||||
{
|
||||
return $this->actingAs($customer, 'client')->withHeaders(['x-access-token' => $this->buildClientAccessToken()]);
|
||||
}
|
||||
|
||||
public function test_customer_saves_and_reads_own_billing_profile(): void
|
||||
{
|
||||
$customer = Customer::factory()->create(['status' => 1]);
|
||||
|
||||
$this->as($customer)->putJson('/v1/client/billing-profile', [
|
||||
'invoice_company' => 'Cong ty ABC',
|
||||
'tax_code' => '0312345678-001',
|
||||
'invoice_address' => '99 Nguyen Hue',
|
||||
'invoice_email' => 'ketoan@abc.vn',
|
||||
])->assertOk();
|
||||
|
||||
$this->as($customer)->getJson('/v1/client/billing-profile')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.tax_code', '0312345678-001');
|
||||
}
|
||||
|
||||
public function test_invalid_tax_code_and_missing_company_are_rejected(): void
|
||||
{
|
||||
$customer = Customer::factory()->create(['status' => 1]);
|
||||
|
||||
$this->as($customer)->putJson('/v1/client/billing-profile', ['invoice_company' => 'X', 'tax_code' => '123'])
|
||||
->assertStatus(422)->assertJsonValidationErrors('tax_code');
|
||||
$this->as($customer)->putJson('/v1/client/billing-profile', ['tax_code' => '0312345678'])
|
||||
->assertStatus(422)->assertJsonValidationErrors('invoice_company');
|
||||
}
|
||||
|
||||
public function test_empty_payload_clears_profile(): void
|
||||
{
|
||||
$customer = Customer::factory()->create(['status' => 1, 'tax_code' => '0312345678', 'invoice_company' => 'ABC']);
|
||||
|
||||
$this->as($customer)->putJson('/v1/client/billing-profile', [])->assertOk();
|
||||
|
||||
$this->assertNull($customer->fresh()->tax_code);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user