refactor(FE): Adapt customer payment report types and exports

This commit is contained in:
rstubryan
2026-01-12 21:39:22 +07:00
parent 96a5eb1be5
commit e1c0701629
5 changed files with 24 additions and 24 deletions
@@ -161,10 +161,7 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => {
{customerReport.customer.name}
</Text>
<Text style={pdfStyles.supplierInfo}>
{customerReport.customer_address || ''}
</Text>
<Text style={pdfStyles.supplierInfo}>
NPWP: {customerReport.customer_npwp || '-'}
{customerReport.customer.address || ''}
</Text>
{customerReport.summary && (
<Text style={pdfStyles.supplierInfo}>
@@ -266,7 +263,9 @@ const createPDFDocument = (params: CustomerPaymentExportPDFParams) => {
</Text>
</View>
<View style={[pdfStyles.tableCellCenter, { flex: 0.8 }]}>
<Text>{formatNumber(item.aging)} hari</Text>
<Text>
{item.aging_day ? formatNumber(item.aging_day) : '-'} hari
</Text>
</View>
<View style={[pdfStyles.tableCell, { flex: 1 }]}>
<Text>{item.reference || '-'}</Text>
@@ -30,9 +30,11 @@ export const generateCustomerPaymentExcel = (
'Tanggal Realisasi': item.realization_date
? formatDate(item.realization_date, 'DD MMM YYYY')
: '',
Aging: formatNumber(item.aging || 0),
Aging: formatNumber(item.aging_day || 0),
Referensi: item.reference || '',
'Nomor Polisi': item.vehicle_plate || '',
'Nomor Polisi': Array.isArray(item.vehicle_plate)
? item.vehicle_plate.join(', ')
: '',
'Ekor/Qty': formatNumber(item.qty || 0),
'Berat (Kg)': formatNumber(item.weight || 0),
AVG: formatNumber(item.average_weight || 0),
@@ -279,10 +279,14 @@ const CustomerPaymentTab = () => {
{
id: 'aging',
header: 'Aging',
accessorKey: 'aging',
accessorKey: 'aging_day',
cell: (props) => {
const value = props.row.original.aging;
return <div className='text-center'>{formatNumber(value)} hari</div>;
const value = props.row.original.aging_day;
return (
<div className='text-center'>
{value ? formatNumber(value) : '-'} hari
</div>
);
},
},
{
@@ -662,7 +666,7 @@ const CustomerPaymentTab = () => {
<Card
key={customerReport.customer.id}
title={customerReport.customer.name}
subtitle={`NPWP: ${customerReport.customer_npwp || '-'} | ${customerReport.customer_address || ''}\nSaldo Piutang: ${formatCurrency(totalAccountsReceivable)}`}
subtitle={`${customerReport.customer.address || ''}\nSaldo Piutang: ${formatCurrency(totalAccountsReceivable)}`}
className={{ wrapper: 'w-full' }}
variant='bordered'
collapsible={true}
+4 -4
View File
@@ -63,8 +63,8 @@ export class FinanceApiService extends BaseApiService<
}
}
export const FinanceApi = new FinanceApiService('reports');
// export const FinanceApi = new FinanceApiService('reports');
// export const FinanceApi = new FinanceApiService(
// 'http://localhost:4010/api/reports/finance'
// );
export const FinanceApi = new FinanceApiService(
'http://localhost:4010/api/reports/finance'
);
+4 -9
View File
@@ -1,15 +1,13 @@
import { BaseMetadata } from '@/types/api/api-general';
import { BaseCustomer } from '@/types/api/master-data/customer';
import { BaseProduct } from '@/types/api/master-data/product';
import { BaseMetadata } from '@/types/api/api-general';
export type CustomerPaymentRow = {
no: number;
id: number;
do_date: string;
payment_date: string;
realization_date: string;
aging: number;
aging_day: number | null;
reference: string;
vehicle_plate: string;
vehicle_plate: string[];
qty: number;
weight: number;
average_weight: number;
@@ -23,7 +21,6 @@ export type CustomerPaymentRow = {
notes: string;
pickup_info: string;
sales_marketing: string;
product?: BaseProduct;
};
export type CustomerPaymentSummary = {
@@ -40,8 +37,6 @@ export type CustomerPaymentSummary = {
export type CustomerPaymentReport = BaseMetadata & {
customer: BaseCustomer;
customer_npwp: string;
customer_address: string;
rows: CustomerPaymentRow[];
summary: CustomerPaymentSummary;
};