From e6cee4a93a674b9aa12f7c76aec27dbfae4bd56f Mon Sep 17 00:00:00 2001 From: rstubryan Date: Fri, 9 Jan 2026 14:41:21 +0700 Subject: [PATCH] feat(FE): Add finance report API and customer payment types --- src/services/api/report/finance-report.ts | 45 +++++++++++++++++++++ src/types/api/report/customer-payment.d.ts | 47 ++++++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 src/services/api/report/finance-report.ts create mode 100644 src/types/api/report/customer-payment.d.ts diff --git a/src/services/api/report/finance-report.ts b/src/services/api/report/finance-report.ts new file mode 100644 index 00000000..8d9a20b8 --- /dev/null +++ b/src/services/api/report/finance-report.ts @@ -0,0 +1,45 @@ +import { BaseApiService } from '@/services/api/base'; +import { BaseApiResponse } from '@/types/api/api-general'; +import { CustomerPaymentReport } from '@/types/api/report/customer-payment'; + +export class FinanceApiService extends BaseApiService< + CustomerPaymentReport, + unknown, + unknown +> { + constructor(basePath: string) { + super(basePath); + } + + async getCustomerPaymentReport( + customer_id?: string, + sales?: string, + date_type?: 'do_date' | 'payment_date', + start_date?: string, + end_date?: string, + page?: number, + limit?: number + ): Promise | undefined> { + return await this.customRequest>( + `customer-payment`, + { + method: 'GET', + params: { + customer_id: customer_id, + sales: sales, + date_type: date_type, + start_date: start_date, + end_date: end_date, + page: page, + limit: limit, + }, + } + ); + } +} + +export const FinanceApi = new FinanceApiService('reports'); + +// export const FinanceApi = new FinanceApiService( +// 'http://localhost:4010/api/reports/finance' +// ); diff --git a/src/types/api/report/customer-payment.d.ts b/src/types/api/report/customer-payment.d.ts new file mode 100644 index 00000000..776d640d --- /dev/null +++ b/src/types/api/report/customer-payment.d.ts @@ -0,0 +1,47 @@ +import { BaseMetadata } from '@/types/api/api-general'; +import { BaseCustomer } from '@/types/api/master-data/customer'; +import { BaseProduct } from '@/types/api/master-data/product'; + +export type CustomerPaymentRow = { + no: number; + do_date: string; + payment_date: string; + realization_date: string; + aging: number; + reference: string; + vehicle_plate: string; + qty: number; + weight: number; + average_weight: number; + price: number; + credit_note: number; + final_price: number; + ppn: number; + total: number; + payment: number; + accounts_receivable: number; + notes: string; + pickup_info: string; + sales_marketing: string; + product?: BaseProduct; +}; + +export type CustomerPaymentSummary = { + total_qty: number; + total_weight: number; + total_initial_amount: number; + total_credit_note: number; + total_final_amount: number; + total_ppn: number; + total_grand_amount: number; + total_payment: number; + total_accounts_receivable: number; +}; + +export type CustomerPaymentReport = BaseMetadata & { + customer: BaseCustomer; + customer_npwp: string; + customer_address: string; + rows: CustomerPaymentRow[]; + summary: CustomerPaymentSummary; +};