update
This commit is contained in:
@@ -127,4 +127,50 @@ class ServiceExpiryTest extends TestCase
|
||||
// Vẫn đúng là OVERDUE — service:expiry không được đụng vào status của invoice.
|
||||
$this->assertSame(InvoiceStatus::OVERDUE->value, (int) $invoice->fresh()->status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hoá đơn gia hạn dùng lại order_id gốc. Khi nó quá hạn, cron KHÔNG được kéo đơn đang chạy
|
||||
* về PENDING — vừa hiển thị sai, vừa làm hasPendingOrder() khoá khách đặt đơn mới.
|
||||
*/
|
||||
public function test_overdue_renewal_invoice_does_not_reset_an_active_order(): void
|
||||
{
|
||||
$service = $this->createExpiringService(90_000);
|
||||
$order = $service->orderItem->order;
|
||||
$this->assertSame(OrderStatus::ACTIVE->value, (int) $order->status);
|
||||
|
||||
$this->artisan('service:expiry')->assertExitCode(0);
|
||||
Invoice::whereKey($service->refresh()->invoice_id)->update(['due_date' => now()->subDay()->toDateString()]);
|
||||
|
||||
$this->artisan('invoices:check-overdue')->assertExitCode(0);
|
||||
|
||||
$this->assertSame(OrderStatus::ACTIVE->value, (int) $order->fresh()->status);
|
||||
}
|
||||
|
||||
/** Giá gia hạn phải theo bảng giá hiện hành, không đóng băng theo giá lúc mua. */
|
||||
public function test_renewal_invoice_uses_the_current_price_list(): void
|
||||
{
|
||||
$service = $this->createExpiringService(90_000);
|
||||
|
||||
$service->orderItem->product->pricings()->create([
|
||||
'billing_cycle' => 'monthly',
|
||||
'price' => 120_000,
|
||||
'is_active' => 1,
|
||||
]);
|
||||
|
||||
$this->artisan('service:expiry')->assertExitCode(0);
|
||||
|
||||
$invoice = Invoice::find($service->refresh()->invoice_id);
|
||||
$this->assertSame(120_000, (int) $invoice->total);
|
||||
}
|
||||
|
||||
/** Không có giá hiện hành (sản phẩm ngừng bán) thì lùi về giá cũ, vẫn xuất được hoá đơn. */
|
||||
public function test_renewal_falls_back_to_the_original_price_when_no_current_price_exists(): void
|
||||
{
|
||||
$service = $this->createExpiringService(90_000);
|
||||
|
||||
$this->artisan('service:expiry')->assertExitCode(0);
|
||||
|
||||
$invoice = Invoice::find($service->refresh()->invoice_id);
|
||||
$this->assertSame(90_000, (int) $invoice->total);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user