diff --git a/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx b/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx index 5a656e7a..d1092e22 100644 --- a/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx +++ b/src/components/pages/report/finance/export/CustomerPaymentExportPDF.tsx @@ -347,13 +347,15 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { - {item.do_date ? formatDate(item.do_date, 'DD MMM YY') : '-'} + {item.trans_date + ? formatDate(item.trans_date, 'DD MMM YY') + : '-'} - {item.realization_date - ? formatDate(item.realization_date, 'DD MMM YY') + {item.delivery_date + ? formatDate(item.delivery_date, 'DD MMM YY') : '-'} @@ -366,7 +368,7 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { {item.reference || '-'} - {item.vehicle_plate || '-'} + {item.vehicle_numbers || '-'} {formatNumber(item.qty)} @@ -390,10 +392,10 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { {formatNumber(item.ppn)}% - {formatCurrency(item.total)} + {formatCurrency(item.total_price)} - {formatCurrency(item.payment)} + {formatCurrency(item.payment_amount)} @@ -401,30 +403,28 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => { - {item.notes ? ( - {item.notes} - ) : ( + {item.status ? ( - {item.accounts_receivable === 0 - ? 'Lunas' - : 'Belum Lunas'} + {item.status === 'LUNAS' ? 'Lunas' : 'Belum Lunas'} + ) : ( + - )} {item.pickup_info || '-'} - {item.sales_marketing || '-'} + {item.sales_person || '-'} ))} diff --git a/src/components/pages/report/finance/export/CustomerPaymentExportXLSX.tsx b/src/components/pages/report/finance/export/CustomerPaymentExportXLSX.tsx index d51aa3b7..ea7cfd77 100644 --- a/src/components/pages/report/finance/export/CustomerPaymentExportXLSX.tsx +++ b/src/components/pages/report/finance/export/CustomerPaymentExportXLSX.tsx @@ -24,17 +24,15 @@ export const generateCustomerPaymentExcel = ( const excelData: { [key: string]: string | number }[] = customerData.map( (item, index) => ({ No: index + 1, - 'Tanggal DO/Bayar': item.do_date - ? formatDate(item.do_date, 'DD MMM YYYY') + 'Tanggal DO/Bayar': item.trans_date + ? formatDate(item.trans_date, 'DD MMM YYYY') : '', - 'Tanggal Realisasi': item.realization_date - ? formatDate(item.realization_date, 'DD MMM YYYY') + 'Tanggal Realisasi': item.delivery_date + ? formatDate(item.delivery_date, 'DD MMM YYYY') : '', Aging: formatNumber(item.aging_day || 0), Referensi: item.reference || '', - 'Nomor Polisi': Array.isArray(item.vehicle_plate) - ? item.vehicle_plate.join(', ') - : '', + 'Nomor Polisi': item.vehicle_numbers || '', 'Ekor/Qty': formatNumber(item.qty || 0), 'Berat (Kg)': formatNumber(item.weight || 0), AVG: formatNumber(item.average_weight || 0), @@ -42,12 +40,12 @@ export const generateCustomerPaymentExcel = ( CN: formatCurrency(item.credit_note || 0), 'Harga Akhir': formatCurrency(item.final_price || 0), 'PPN (%)': formatNumber(item.ppn || 0), - Total: formatCurrency(item.total || 0), - Pembayaran: formatCurrency(item.payment || 0), + Total: formatCurrency(item.total_price || 0), + Pembayaran: formatCurrency(item.payment_amount || 0), 'Saldo Piutang': formatCurrency(item.accounts_receivable || 0), - Keterangan: item.notes || '', + Keterangan: item.status || '', Pengambilan: item.pickup_info || '', - 'Sales/Marketing': item.sales_marketing || '', + 'Sales/Marketing': item.sales_person || '', }) ); diff --git a/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx b/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx index f0b5850c..ef320c15 100644 --- a/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx +++ b/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx @@ -302,24 +302,37 @@ const CustomerPaymentTab = () => { { id: 'no', header: 'No', - cell: (props) => props.row.index + 1, + cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + return isInitialBalanceRow ? 'Saldo Awal' : props.row.index; + }, footer: () =>
Total
, }, { id: 'do_date_or_payment_date', header: 'Tanggal DO/Bayar', - accessorKey: 'do_date', + accessorKey: 'trans_date', cell: (props) => { - const value = props.row.original.do_date; + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return '-'; + const value = props.row.original.trans_date; return formatDate(value, 'DD MMM YYYY'); }, }, { id: 'realization_date', header: 'Tanggal Realisasi', - accessorKey: 'realization_date', + accessorKey: 'delivery_date', cell: (props) => { - const value = props.row.original.realization_date; + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return '-'; + const value = props.row.original.delivery_date; return formatDate(value, 'DD MMM YYYY'); }, }, @@ -328,6 +341,10 @@ const CustomerPaymentTab = () => { header: 'Aging', accessorKey: 'aging_day', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return '-'; const value = props.row.original.aging_day; return (
@@ -341,6 +358,10 @@ const CustomerPaymentTab = () => { header: 'Referensi', accessorKey: 'reference', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return '-'; const value = props.row.original.reference; return value || '-'; }, @@ -348,9 +369,13 @@ const CustomerPaymentTab = () => { { id: 'vehicle_plate', header: 'Nomor Polisi', - accessorKey: 'vehicle_plate', + accessorKey: 'vehicle_numbers', cell: (props) => { - const value = props.row.original.vehicle_plate; + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return '-'; + const value = props.row.original.vehicle_numbers; return value || '-'; }, }, @@ -359,6 +384,10 @@ const CustomerPaymentTab = () => { header: 'Ekor/Qty', accessorKey: 'qty', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return
-
; const value = props.row.original.qty; return
{formatNumber(value)}
; }, @@ -373,6 +402,10 @@ const CustomerPaymentTab = () => { header: 'Berat (Kg)', accessorKey: 'weight', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return
-
; const value = props.row.original.weight; return
{formatNumber(value)}
; }, @@ -387,6 +420,10 @@ const CustomerPaymentTab = () => { header: 'AVG', accessorKey: 'average_weight', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return
-
; const value = props.row.original.average_weight; return
{formatNumber(value)}
; }, @@ -399,6 +436,10 @@ const CustomerPaymentTab = () => { header: 'Harga Awal', accessorKey: 'price', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return
-
; const value = props.row.original.price; return
{formatCurrency(value)}
; }, @@ -413,6 +454,10 @@ const CustomerPaymentTab = () => { header: 'CN', accessorKey: 'credit_note', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return
-
; const value = props.row.original.credit_note; return
{formatCurrency(value)}
; }, @@ -427,6 +472,10 @@ const CustomerPaymentTab = () => { header: 'Harga Akhir', accessorKey: 'final_price', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return
-
; const value = props.row.original.final_price; return
{formatCurrency(value)}
; }, @@ -441,6 +490,10 @@ const CustomerPaymentTab = () => { header: 'PPN (%)', accessorKey: 'ppn', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return
-
; const value = props.row.original.ppn; return
{formatNumber(value)}%
; }, @@ -451,9 +504,13 @@ const CustomerPaymentTab = () => { { id: 'total', header: 'Total', - accessorKey: 'total', + accessorKey: 'total_price', cell: (props) => { - const value = props.row.original.total; + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return
-
; + const value = props.row.original.total_price; return
{formatCurrency(value)}
; }, footer: () => ( @@ -465,9 +522,13 @@ const CustomerPaymentTab = () => { { id: 'payment', header: 'Pembayaran', - accessorKey: 'payment', + accessorKey: 'payment_amount', cell: (props) => { - const value = props.row.original.payment; + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return
-
; + const value = props.row.original.payment_amount; return
{formatCurrency(value)}
; }, footer: () => ( @@ -495,9 +556,13 @@ const CustomerPaymentTab = () => { { id: 'notes', header: 'Keterangan', - accessorKey: 'notes', + accessorKey: 'status', cell: (props) => { - const value = props.row.original.notes; + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return '-'; + const value = props.row.original.status; if (!value) { return '-'; @@ -522,6 +587,10 @@ const CustomerPaymentTab = () => { header: 'Pengambilan', accessorKey: 'pickup_info', cell: (props) => { + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return '-'; const value = props.row.original.pickup_info; return value || '-'; }, @@ -529,9 +598,13 @@ const CustomerPaymentTab = () => { { id: 'sales_marketing', header: 'Sales/Marketing', - accessorKey: 'sales_marketing', + accessorKey: 'sales_person', cell: (props) => { - const value = props.row.original.sales_marketing; + const isInitialBalanceRow = + Object.keys(props.row.original).length === 1 && + 'accounts_receivable' in props.row.original; + if (isInitialBalanceRow) return '-'; + const value = props.row.original.sales_person; return value || '-'; }, }, @@ -754,9 +827,14 @@ const CustomerPaymentTab = () => { collapsible={true} > 0} className={{ containerClassName: 'w-full', diff --git a/src/types/api/report/customer-payment.d.ts b/src/types/api/report/customer-payment.d.ts index bfa059c9..8c648cb9 100644 --- a/src/types/api/report/customer-payment.d.ts +++ b/src/types/api/report/customer-payment.d.ts @@ -2,12 +2,12 @@ import { BaseCustomer } from '@/types/api/master-data/customer'; import { BaseMetadata } from '@/types/api/api-general'; export type CustomerPaymentRow = { - id: number; - do_date: string; - realization_date: string; - aging_day: number | null; + transaction_type: string; + transaction_id: number; + trans_date: string; + delivery_date: string | null; reference: string; - vehicle_plate: string[]; + vehicle_numbers: string; qty: number; weight: number; average_weight: number; @@ -15,12 +15,13 @@ export type CustomerPaymentRow = { credit_note: number; final_price: number; ppn: number; - total: number; - payment: number; + total_price: number; + payment_amount: number; accounts_receivable: number; - notes: string; + aging_day: number; + status: string; pickup_info: string; - sales_marketing: string; + sales_person: string; }; export type CustomerPaymentSummary = { @@ -37,6 +38,7 @@ export type CustomerPaymentSummary = { export type CustomerPaymentReport = BaseMetadata & { customer: BaseCustomer; + initial_balance: number; rows: CustomerPaymentRow[]; summary: CustomerPaymentSummary; };