update email template

This commit is contained in:
baodev0
2026-09-09 16:56:22 +07:00
parent d3d9f76ba0
commit 2365ef72e9
210 changed files with 6335 additions and 4688 deletions
@@ -35,7 +35,7 @@ class InvoiceRepository extends BaseApiRepository implements InvoiceRepositoryIn
public function createFromOrder(Order $order): Invoice
{
$maxMonths = $order->orderItems->max(fn($item) => $this->cycleToMonths($item->billing_cycle)) ?? 1;
$maxMonths = $order->orderItems->max(fn($item) => OrderHelper::cycleToMonths($item->billing_cycle)) ?? 1;
$invoice = $this->model->create([
'invoice_number' => OrderHelper::generateOrderNumber('INV'),
@@ -57,7 +57,7 @@ class InvoiceRepository extends BaseApiRepository implements InvoiceRepositoryIn
'product_id' => $item->product_id,
'type' => 'service',
'description' => $item->product?->name ?? 'Dịch vụ',
'months' => $this->cycleToMonths($item->billing_cycle),
'months' => OrderHelper::cycleToMonths($item->billing_cycle),
'quantity' => $item->quantity ?? 1,
'unit_price' => $item->price,
'total_price' => $item->price * ($item->quantity ?? 1),
@@ -77,7 +77,7 @@ class InvoiceRepository extends BaseApiRepository implements InvoiceRepositoryIn
'product_id' => $item->product_id,
'type' => 'addon',
'description' => $label,
'months' => $this->cycleToMonths($item->billing_cycle),
'months' => OrderHelper::cycleToMonths($item->billing_cycle),
'quantity' => $qty,
'unit_price' => $price,
'total_price' => $subtotal,
@@ -92,16 +92,4 @@ class InvoiceRepository extends BaseApiRepository implements InvoiceRepositoryIn
// Helpers
// -------------------------------------------------------------------------
private function cycleToMonths(?string $cycle): int
{
return match ($cycle) {
'monthly' => 1,
'quarterly' => 3,
'semi_annually' => 6,
'annually' => 12,
'biennially' => 24,
'triennially' => 36,
default => 1,
};
}
}