refactor(FE): Update customer payment types and exports

This commit is contained in:
rstubryan
2026-01-14 22:17:24 +07:00
parent a72fbec5ce
commit f1dba4012a
4 changed files with 16 additions and 29 deletions
@@ -284,7 +284,7 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => {
<View style={[pdfStyles.tableCellHeader, { flex: 0.8 }]}> <View style={[pdfStyles.tableCellHeader, { flex: 0.8 }]}>
<Text>Aging</Text> <Text>Aging</Text>
</View> </View>
<View style={[pdfStyles.tableCellHeader, { flex: 1 }]}> <View style={[pdfStyles.tableCellHeader, { flex: 1.5 }]}>
<Text>Referensi</Text> <Text>Referensi</Text>
</View> </View>
<View style={[pdfStyles.tableCellHeader, { flex: 1.2 }]}> <View style={[pdfStyles.tableCellHeader, { flex: 1.2 }]}>
@@ -305,9 +305,6 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => {
<View style={[pdfStyles.tableCellHeaderRight, { flex: 1.2 }]}> <View style={[pdfStyles.tableCellHeaderRight, { flex: 1.2 }]}>
<Text>Harga Akhir</Text> <Text>Harga Akhir</Text>
</View> </View>
<View style={[pdfStyles.tableCellHeaderRight, { flex: 0.8 }]}>
<Text>Pajak</Text>
</View>
<View style={[pdfStyles.tableCellHeaderRight, { flex: 1.2 }]}> <View style={[pdfStyles.tableCellHeaderRight, { flex: 1.2 }]}>
<Text>Total</Text> <Text>Total</Text>
</View> </View>
@@ -361,7 +358,7 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => {
{item.aging_day ? formatNumber(item.aging_day) : '-'} hari {item.aging_day ? formatNumber(item.aging_day) : '-'} hari
</Text> </Text>
</View> </View>
<View style={[pdfStyles.tableCell, { flex: 1 }]}> <View style={[pdfStyles.tableCell, { flex: 1.5 }]}>
<Text>{item.reference || '-'}</Text> <Text>{item.reference || '-'}</Text>
</View> </View>
<View style={[pdfStyles.tableCell, { flex: 1.2 }]}> <View style={[pdfStyles.tableCell, { flex: 1.2 }]}>
@@ -435,7 +432,7 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => {
<View style={[pdfStyles.tableCell, { flex: 0.8 }]}> <View style={[pdfStyles.tableCell, { flex: 0.8 }]}>
<Text></Text> <Text></Text>
</View> </View>
<View style={[pdfStyles.tableCell, { flex: 1 }]}> <View style={[pdfStyles.tableCell, { flex: 1.5 }]}>
<Text></Text> <Text></Text>
</View> </View>
<View style={[pdfStyles.tableCell, { flex: 1.2 }]}> <View style={[pdfStyles.tableCell, { flex: 1.2 }]}>
@@ -453,20 +450,13 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => {
<Text></Text> <Text></Text>
</View> </View>
<View style={[pdfStyles.tableCellRight, { flex: 1.2 }]}> <View style={[pdfStyles.tableCellRight, { flex: 1.2 }]}>
<Text> <Text></Text>
{formatCurrency(
customerReport.summary.total_initial_amount
)}
</Text>
</View> </View>
<View style={[pdfStyles.tableCellRight, { flex: 1.2 }]}> <View style={[pdfStyles.tableCellRight, { flex: 1.2 }]}>
<Text> <Text>
{formatCurrency(customerReport.summary.total_final_amount)} {formatCurrency(customerReport.summary.total_final_amount)}
</Text> </Text>
</View> </View>
<View style={[pdfStyles.tableCellRight, { flex: 0.8 }]}>
<Text></Text>
</View>
<View style={[pdfStyles.tableCellRight, { flex: 1.2 }]}> <View style={[pdfStyles.tableCellRight, { flex: 1.2 }]}>
<Text> <Text>
{formatCurrency(customerReport.summary.total_grand_amount)} {formatCurrency(customerReport.summary.total_grand_amount)}
@@ -32,7 +32,9 @@ export const generateCustomerPaymentExcel = (
: '', : '',
Aging: formatNumber(item.aging_day || 0), Aging: formatNumber(item.aging_day || 0),
Referensi: item.reference || '', Referensi: item.reference || '',
'Nomor Polisi': item.vehicle_numbers || '', 'Nomor Polisi': Array.isArray(item.vehicle_numbers)
? item.vehicle_numbers.join(', ')
: '',
'Ekor/Qty': formatNumber(item.qty || 0), 'Ekor/Qty': formatNumber(item.qty || 0),
'Berat (Kg)': formatNumber(item.weight || 0), 'Berat (Kg)': formatNumber(item.weight || 0),
AVG: formatNumber(item.average_weight || 0), AVG: formatNumber(item.average_weight || 0),
@@ -42,7 +44,9 @@ export const generateCustomerPaymentExcel = (
Pembayaran: formatCurrency(item.payment_amount || 0), Pembayaran: formatCurrency(item.payment_amount || 0),
'Saldo Piutang': formatCurrency(item.accounts_receivable || 0), 'Saldo Piutang': formatCurrency(item.accounts_receivable || 0),
Keterangan: item.status || '', Keterangan: item.status || '',
Pengambilan: item.pickup_info || '', Pengambilan: Array.isArray(item.pickup_info)
? item.pickup_info.join(', ')
: '',
'Sales/Marketing': item.sales_person || '', 'Sales/Marketing': item.sales_person || '',
}) })
); );
@@ -58,9 +62,7 @@ export const generateCustomerPaymentExcel = (
'Ekor/Qty': formatNumber(customerReport.summary.total_qty || 0), 'Ekor/Qty': formatNumber(customerReport.summary.total_qty || 0),
'Berat (Kg)': formatNumber(customerReport.summary.total_weight || 0), 'Berat (Kg)': formatNumber(customerReport.summary.total_weight || 0),
AVG: '', AVG: '',
'Harga Awal': formatCurrency( 'Harga Awal': '',
customerReport.summary.total_initial_amount || 0
),
'Harga Akhir': formatCurrency( 'Harga Akhir': formatCurrency(
customerReport.summary.total_final_amount || 0 customerReport.summary.total_final_amount || 0
), ),
@@ -412,9 +412,7 @@ const CustomerPaymentTab = () => {
return <div className='text-right'>{formatCurrency(value)}</div>; return <div className='text-right'>{formatCurrency(value)}</div>;
}, },
footer: () => ( footer: () => (
<div className='text-right font-semibold text-gray-900'> <div className='text-right font-semibold text-gray-900'>-</div>
{formatCurrency(summary.total_initial_amount) || '-'}
</div>
), ),
}, },
{ {
@@ -510,7 +508,7 @@ const CustomerPaymentTab = () => {
status: getPaymentStatusIndicatorColor(value), status: getPaymentStatusIndicatorColor(value),
}} }}
> >
{getPaymentStatusText(value)} <span>{getPaymentStatusText(value)}</span>
</Badge> </Badge>
); );
}, },
@@ -729,8 +727,6 @@ const CustomerPaymentTab = () => {
const summary = customerReport.summary || { const summary = customerReport.summary || {
total_qty: 0, total_qty: 0,
total_weight: 0, total_weight: 0,
total_initial_amount: 0,
total_credit_note: 0,
total_final_amount: 0, total_final_amount: 0,
total_grand_amount: 0, total_grand_amount: 0,
total_payment: 0, total_payment: 0,
+3 -4
View File
@@ -7,7 +7,7 @@ export type CustomerPaymentRow = {
trans_date: string; trans_date: string;
delivery_date: string | null; delivery_date: string | null;
reference: string; reference: string;
vehicle_numbers: string; vehicle_numbers: string[];
qty: number; qty: number;
weight: number; weight: number;
average_weight: number; average_weight: number;
@@ -16,16 +16,15 @@ export type CustomerPaymentRow = {
total_price: number; total_price: number;
payment_amount: number; payment_amount: number;
accounts_receivable: number; accounts_receivable: number;
aging_day: number; aging_day: number | null;
status: string; status: string;
pickup_info: string; pickup_info: string[];
sales_person: string; sales_person: string;
}; };
export type CustomerPaymentSummary = { export type CustomerPaymentSummary = {
total_qty: number; total_qty: number;
total_weight: number; total_weight: number;
total_initial_amount: number;
total_final_amount: number; total_final_amount: number;
total_grand_amount: number; total_grand_amount: number;
total_payment: number; total_payment: number;