update email template
This commit is contained in:
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user