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:
baodev0
2026-10-19 16:37:56 +07:00
co-authored by Claude Sonnet 5.5
parent ea9a53f742
commit 25f23d541e
134 changed files with 4926 additions and 185 deletions
@@ -21,6 +21,7 @@ class RenewalReminderTest extends TestCase
private const BASE = '/api/v1/administrator/services/renewal-reminders';
private User $admin;
private Customer $customer;
private Service $soon;
private Service $later;
@@ -34,10 +35,10 @@ class RenewalReminderTest extends TestCase
$this->admin = User::factory()->create();
$this->admin->assignRole('Full Administrator');
$customer = Customer::factory()->create();
$this->soon = Service::create(['customer_id' => $customer->id, 'status' => 'active', 'expires_at' => now()->addDays(5)]);
$this->later = Service::create(['customer_id' => $customer->id, 'status' => 'active', 'expires_at' => now()->addDays(40)]);
Service::create(['customer_id' => $customer->id, 'status' => 'suspended', 'expires_at' => now()->addDays(3)]);
$this->customer = Customer::factory()->create();
$this->soon = Service::create(['customer_id' => $this->customer->id, 'status' => 'active', 'expires_at' => now()->addDays(5)]);
$this->later = Service::create(['customer_id' => $this->customer->id, 'status' => 'active', 'expires_at' => now()->addDays(40)]);
Service::create(['customer_id' => $this->customer->id, 'status' => 'suspended', 'expires_at' => now()->addDays(3)]);
}
public function test_lists_active_services_expiring_within_days(): void
@@ -75,4 +76,21 @@ class RenewalReminderTest extends TestCase
Mail::assertNothingQueued();
}
public function test_customer_service_reminder_queues_mail_and_records_log(): void
{
Mail::fake();
$this->actingAs($this->admin, 'admin')
->postJson("/api/v1/administrator/customers/{$this->customer->uuid}/services/{$this->soon->id}/notify-renew")
->assertOk()
->assertJsonPath('error', false);
Mail::assertQueued(ServiceRenewalReminderMail::class, 1);
$this->assertDatabaseHas('mail', [
'customer_id' => $this->customer->id,
'sent_by' => $this->admin->id,
'to' => $this->customer->email,
]);
}
}