'Khởi tạo', 2 => 'Gia hạn', 3 => 'Nâng cấp']; public function __construct(private readonly Builder $query) {} public function title(): string { return 'Danh sách hoá đơn'; } public function query(): Builder { return $this->query->latest('id'); } public function moneyColumns(): array { return ['G', 'H', 'I', 'J', 'K', 'L']; } public function headings(): array { return [ 'Mã hoá đơn', 'Mã đơn hàng', 'Loại', 'Khách hàng', 'Email', 'Dịch vụ', 'Tạm tính', 'Giảm giá', 'Thuế', 'Tổng tiền', 'Đã thu', 'Còn nợ', 'Trạng thái', 'Phương thức thanh toán', 'Hạn thanh toán', 'Ngày thanh toán', 'Ngày tạo', ]; } /** * @param Invoice $invoice */ public function map($invoice): array { return [ $invoice->invoice_number, $invoice->order?->order_num, self::TYPE_LABELS[(int) $invoice->invoice_type] ?? $invoice->invoice_type, $invoice->customer?->fullname, $invoice->customer?->email, $this->describeServices($invoice->order), (int) $invoice->sub_total, (int) $invoice->discount_amount, (int) $invoice->tax, (int) $invoice->total, (int) $invoice->amount_paid, InvoicePaymentService::outstanding($invoice), InvoiceStatus::tryFrom((int) $invoice->status)?->label() ?? $invoice->status, $invoice->payment?->name ?? $this->paymentMethodLabel($invoice->payment_method), $this->formatDate($invoice->due_date), $this->formatDate($invoice->paid_at, 'd/m/Y H:i'), $this->formatDate($invoice->created_at, 'd/m/Y H:i'), ]; } }