mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Merge branch 'fix/debt-supplier' into 'development'
[FIX/FE] Delete Dummy Data and Separate Service API File See merge request mbugroup/lti-web-client!168
This commit is contained in:
@@ -13,7 +13,6 @@ import Table from '@/components/Table';
|
|||||||
import { isResponseSuccess } from '@/lib/api-helper';
|
import { isResponseSuccess } from '@/lib/api-helper';
|
||||||
import { formatCurrency, formatDate, formatNumber } from '@/lib/helper';
|
import { formatCurrency, formatDate, formatNumber } from '@/lib/helper';
|
||||||
import { SupplierApi } from '@/services/api/master-data';
|
import { SupplierApi } from '@/services/api/master-data';
|
||||||
import { FinanceApi } from '@/services/api/report/finance-report';
|
|
||||||
import { DebtRow, DebtSupplier } from '@/types/api/report/debt-supplier';
|
import { DebtRow, DebtSupplier } from '@/types/api/report/debt-supplier';
|
||||||
import { generateDebtSupplierExcel } from '@/components/pages/report/finance/export/DebtSupplierExportXLSX';
|
import { generateDebtSupplierExcel } from '@/components/pages/report/finance/export/DebtSupplierExportXLSX';
|
||||||
import { generateDebtSupplierPDF } from '@/components/pages/report/finance/export/DebtSupllierExportPDF';
|
import { generateDebtSupplierPDF } from '@/components/pages/report/finance/export/DebtSupllierExportPDF';
|
||||||
@@ -23,6 +22,7 @@ import { useCallback, useMemo, useState } from 'react';
|
|||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
import useSWR from 'swr';
|
import useSWR from 'swr';
|
||||||
import Pagination from '@/components/Pagination';
|
import Pagination from '@/components/Pagination';
|
||||||
|
import { DebtSupplierApi } from '@/services/api/report/debt-supplier';
|
||||||
|
|
||||||
const DebtSupplierTab = () => {
|
const DebtSupplierTab = () => {
|
||||||
// ===== STATE MANAGEMENT =====
|
// ===== STATE MANAGEMENT =====
|
||||||
@@ -41,7 +41,7 @@ const DebtSupplierTab = () => {
|
|||||||
const [filterSupplier, setFilterSupplier] = useState<OptionType[]>([]);
|
const [filterSupplier, setFilterSupplier] = useState<OptionType[]>([]);
|
||||||
const [filterStartDate, setFilterStartDate] = useState('');
|
const [filterStartDate, setFilterStartDate] = useState('');
|
||||||
const [filterEndDate, setFilterEndDate] = useState('');
|
const [filterEndDate, setFilterEndDate] = useState('');
|
||||||
const [filterDataType, setFilterDataType] = useState<OptionType>();
|
const [filterDateType, setFilterDateType] = useState<OptionType>();
|
||||||
const [filterErrors, setFilterErrors] = useState<Record<string, string>>({});
|
const [filterErrors, setFilterErrors] = useState<Record<string, string>>({});
|
||||||
|
|
||||||
const filterModal = useModal();
|
const filterModal = useModal();
|
||||||
@@ -96,7 +96,7 @@ const DebtSupplierTab = () => {
|
|||||||
filterSupplier.length > 0
|
filterSupplier.length > 0
|
||||||
? filterSupplier.map((v) => String(v.value)).join(',')
|
? filterSupplier.map((v) => String(v.value)).join(',')
|
||||||
: undefined,
|
: undefined,
|
||||||
filter_by: filterDataType?.value || 'received_date',
|
filter_by: filterDateType?.value,
|
||||||
start_date: filterStartDate || undefined,
|
start_date: filterStartDate || undefined,
|
||||||
end_date: filterEndDate || undefined,
|
end_date: filterEndDate || undefined,
|
||||||
page: currentPage,
|
page: currentPage,
|
||||||
@@ -107,7 +107,7 @@ const DebtSupplierTab = () => {
|
|||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
([, params]) =>
|
([, params]) =>
|
||||||
FinanceApi.getDebtSupplierReport(
|
DebtSupplierApi.getDebtSupplierReport(
|
||||||
params.supplier_ids,
|
params.supplier_ids,
|
||||||
params.filter_by?.toString(),
|
params.filter_by?.toString(),
|
||||||
params.start_date,
|
params.start_date,
|
||||||
@@ -116,9 +116,6 @@ const DebtSupplierTab = () => {
|
|||||||
params.limit
|
params.limit
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
// const { data: debtSupplier, isLoading } = useSWR(FinanceApi.basePath, () =>
|
|
||||||
// FinanceApi.getDebtSupplierReport()
|
|
||||||
// );
|
|
||||||
|
|
||||||
const data: DebtSupplier[] = useMemo(
|
const data: DebtSupplier[] = useMemo(
|
||||||
() =>
|
() =>
|
||||||
@@ -141,15 +138,15 @@ const DebtSupplierTab = () => {
|
|||||||
filterSupplier.length > 0
|
filterSupplier.length > 0
|
||||||
? filterSupplier.map((v) => String(v.value)).join(',')
|
? filterSupplier.map((v) => String(v.value)).join(',')
|
||||||
: undefined,
|
: undefined,
|
||||||
filter_by: 'received_date' as const,
|
filter_by: filterDateType?.value?.toString(),
|
||||||
start_date: filterStartDate || undefined,
|
start_date: filterStartDate || undefined,
|
||||||
end_date: filterEndDate || undefined,
|
end_date: filterEndDate || undefined,
|
||||||
date_type: filterDataType ? filterDataType.value : undefined,
|
date_type: filterDateType ? filterDateType.value : undefined,
|
||||||
limit: 100,
|
limit: 100,
|
||||||
page: 1,
|
page: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await FinanceApi.getDebtSupplierReport(
|
const response = await DebtSupplierApi.getDebtSupplierReport(
|
||||||
params.supplier_ids,
|
params.supplier_ids,
|
||||||
params.filter_by,
|
params.filter_by,
|
||||||
params.start_date,
|
params.start_date,
|
||||||
@@ -602,11 +599,12 @@ const DebtSupplierTab = () => {
|
|||||||
label='Filter Berdasarkan'
|
label='Filter Berdasarkan'
|
||||||
placeholder='Pilih Filter Berdasarkan'
|
placeholder='Pilih Filter Berdasarkan'
|
||||||
options={dataTypeOptions}
|
options={dataTypeOptions}
|
||||||
value={filterDataType}
|
value={filterDateType}
|
||||||
onChange={(val) => {
|
onChange={(val) => {
|
||||||
setFilterDataType(val ? (val as OptionType) : undefined);
|
setFilterDateType(val ? (val as OptionType) : undefined);
|
||||||
}}
|
}}
|
||||||
className={{ wrapper: 'w-full' }}
|
className={{ wrapper: 'w-full' }}
|
||||||
|
isClearable
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,292 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"supplier": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "PT CHAROEN POKPHAND INDONESIA Tbk",
|
|
||||||
"alias": "CPI",
|
|
||||||
"category": "SAPRONAK"
|
|
||||||
},
|
|
||||||
"initial_balance": -9680000,
|
|
||||||
"rows": [
|
|
||||||
{
|
|
||||||
"pr_number": "PR-TEST-202501-01",
|
|
||||||
"po_number": "PO-TEST-202501-01",
|
|
||||||
"po_date": "2025-01-15",
|
|
||||||
"received_date": "2025-01-15",
|
|
||||||
"aging": 0,
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
},
|
|
||||||
"warehouse": {
|
|
||||||
"id": 3,
|
|
||||||
"name": "Gudang Kandang Bandung 1",
|
|
||||||
"type": "KANDANG",
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"due_date": "2025-02-14",
|
|
||||||
"due_status": "Sudah Jatuh Tempo",
|
|
||||||
"total_price": 5610000,
|
|
||||||
"payment_price": 0,
|
|
||||||
"debt_price": -5610000,
|
|
||||||
"status": "Belum Lunas",
|
|
||||||
"travel_number": "-",
|
|
||||||
"balance": -15290000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PR-TEST-202501-02",
|
|
||||||
"po_number": "PO-TEST-202501-02",
|
|
||||||
"po_date": "2025-01-15",
|
|
||||||
"received_date": "2025-01-15",
|
|
||||||
"aging": 0,
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
},
|
|
||||||
"warehouse": {
|
|
||||||
"id": 4,
|
|
||||||
"name": "Gudang Kandang Bandung 2",
|
|
||||||
"type": "KANDANG",
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"due_date": "2025-02-14",
|
|
||||||
"due_status": "Sudah Jatuh Tempo",
|
|
||||||
"total_price": 5035000,
|
|
||||||
"payment_price": 0,
|
|
||||||
"debt_price": -5035000,
|
|
||||||
"status": "Belum Lunas",
|
|
||||||
"travel_number": "-",
|
|
||||||
"balance": -20325000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "INIT-90001",
|
|
||||||
"po_number": "SALDO-AWAL",
|
|
||||||
"po_date": "-",
|
|
||||||
"received_date": "2026-01-05",
|
|
||||||
"aging": 0,
|
|
||||||
"due_date": "-",
|
|
||||||
"due_status": "-",
|
|
||||||
"total_price": 0,
|
|
||||||
"payment_price": -10000000,
|
|
||||||
"debt_price": -30325000,
|
|
||||||
"status": "Pembayaran",
|
|
||||||
"travel_number": "-",
|
|
||||||
"balance": -30325000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PR-LTI-9001",
|
|
||||||
"po_number": "PO-LTI-9001",
|
|
||||||
"po_date": "2026-01-10",
|
|
||||||
"received_date": "2026-01-10",
|
|
||||||
"aging": 2,
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
},
|
|
||||||
"warehouse": {
|
|
||||||
"id": 3,
|
|
||||||
"name": "Gudang Kandang Bandung 1",
|
|
||||||
"type": "KANDANG",
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"due_date": "2026-02-09",
|
|
||||||
"due_status": "Mendekati Jatuh Tempo",
|
|
||||||
"total_price": 52500000,
|
|
||||||
"payment_price": 2000000,
|
|
||||||
"debt_price": -50500000,
|
|
||||||
"status": "Belum Lunas",
|
|
||||||
"travel_number": "SJ-9001",
|
|
||||||
"balance": -82825000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PAY-OUT-90001",
|
|
||||||
"po_number": "PO-LTI-9001",
|
|
||||||
"po_date": "-",
|
|
||||||
"received_date": "2026-01-10",
|
|
||||||
"aging": 0,
|
|
||||||
"due_date": "-",
|
|
||||||
"due_status": "-",
|
|
||||||
"total_price": 0,
|
|
||||||
"payment_price": 2000000,
|
|
||||||
"debt_price": -80825000,
|
|
||||||
"status": "Pembayaran",
|
|
||||||
"travel_number": "-",
|
|
||||||
"balance": -80825000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PR-LTI-0001",
|
|
||||||
"po_number": "PO-LTI-0001",
|
|
||||||
"po_date": "2026-01-10",
|
|
||||||
"received_date": "2026-01-10",
|
|
||||||
"aging": 2,
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
},
|
|
||||||
"warehouse": {
|
|
||||||
"id": 3,
|
|
||||||
"name": "Gudang Kandang Bandung 1",
|
|
||||||
"type": "KANDANG",
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"due_date": "2026-02-09",
|
|
||||||
"due_status": "Mendekati Jatuh Tempo",
|
|
||||||
"total_price": 52500000,
|
|
||||||
"payment_price": 1800000,
|
|
||||||
"debt_price": -50700000,
|
|
||||||
"status": "Belum Lunas",
|
|
||||||
"travel_number": "3232",
|
|
||||||
"balance": -133325000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PAY-OUT-00003",
|
|
||||||
"po_number": "PO-LTI-0001",
|
|
||||||
"po_date": "-",
|
|
||||||
"received_date": "2026-01-10",
|
|
||||||
"aging": 0,
|
|
||||||
"due_date": "-",
|
|
||||||
"due_status": "-",
|
|
||||||
"total_price": 0,
|
|
||||||
"payment_price": 2000000,
|
|
||||||
"debt_price": -131325000,
|
|
||||||
"status": "Pembayaran",
|
|
||||||
"travel_number": "-",
|
|
||||||
"balance": -131325000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PAY-OUT-90002",
|
|
||||||
"po_number": "2323",
|
|
||||||
"po_date": "-",
|
|
||||||
"received_date": "2026-01-11",
|
|
||||||
"aging": 0,
|
|
||||||
"due_date": "-",
|
|
||||||
"due_status": "-",
|
|
||||||
"total_price": 0,
|
|
||||||
"payment_price": 200000,
|
|
||||||
"debt_price": -131125000,
|
|
||||||
"status": "Pembayaran",
|
|
||||||
"travel_number": "-",
|
|
||||||
"balance": -131125000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PAY-OUT-00002",
|
|
||||||
"po_number": "2323",
|
|
||||||
"po_date": "-",
|
|
||||||
"received_date": "2026-01-11",
|
|
||||||
"aging": 0,
|
|
||||||
"due_date": "-",
|
|
||||||
"due_status": "-",
|
|
||||||
"total_price": 0,
|
|
||||||
"payment_price": 200000,
|
|
||||||
"debt_price": -130925000,
|
|
||||||
"status": "Pembayaran",
|
|
||||||
"travel_number": "-",
|
|
||||||
"balance": -130925000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "INIT-00001",
|
|
||||||
"po_number": "PO-LTI-0001",
|
|
||||||
"po_date": "-",
|
|
||||||
"received_date": "2026-01-11",
|
|
||||||
"aging": 0,
|
|
||||||
"due_date": "-",
|
|
||||||
"due_status": "-",
|
|
||||||
"total_price": 0,
|
|
||||||
"payment_price": -200000,
|
|
||||||
"debt_price": -131125000,
|
|
||||||
"status": "Pembayaran",
|
|
||||||
"travel_number": "-",
|
|
||||||
"balance": -131125000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PR-LTI-9002",
|
|
||||||
"po_number": "PO-LTI-9002",
|
|
||||||
"po_date": "2026-01-12",
|
|
||||||
"received_date": "2026-01-12",
|
|
||||||
"aging": 0,
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
},
|
|
||||||
"warehouse": {
|
|
||||||
"id": 3,
|
|
||||||
"name": "Gudang Kandang Bandung 1",
|
|
||||||
"type": "KANDANG",
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"due_date": "2026-02-11",
|
|
||||||
"due_status": "Mendekati Jatuh Tempo",
|
|
||||||
"total_price": 30000000,
|
|
||||||
"payment_price": 5000000,
|
|
||||||
"debt_price": -25000000,
|
|
||||||
"status": "Belum Lunas",
|
|
||||||
"travel_number": "SJ-9002",
|
|
||||||
"balance": -161125000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PAY-OUT-90003",
|
|
||||||
"po_number": "PO-LTI-9002",
|
|
||||||
"po_date": "-",
|
|
||||||
"received_date": "2026-01-12",
|
|
||||||
"aging": 0,
|
|
||||||
"due_date": "-",
|
|
||||||
"due_status": "-",
|
|
||||||
"total_price": 0,
|
|
||||||
"payment_price": 5000000,
|
|
||||||
"debt_price": -156125000,
|
|
||||||
"status": "Pembayaran",
|
|
||||||
"travel_number": "-",
|
|
||||||
"balance": -156125000
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"pr_number": "PR-LTI-0002",
|
|
||||||
"po_number": "PO-LTI-0002",
|
|
||||||
"po_date": "2026-01-12",
|
|
||||||
"received_date": "2026-01-12",
|
|
||||||
"aging": 0,
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
},
|
|
||||||
"warehouse": {
|
|
||||||
"id": 4,
|
|
||||||
"name": "Gudang Kandang Bandung 2",
|
|
||||||
"type": "KANDANG",
|
|
||||||
"area": {
|
|
||||||
"id": 1,
|
|
||||||
"name": "Bandung"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"due_date": "2026-02-11",
|
|
||||||
"due_status": "Mendekati Jatuh Tempo",
|
|
||||||
"total_price": 45000000,
|
|
||||||
"payment_price": 0,
|
|
||||||
"debt_price": -45000000,
|
|
||||||
"status": "Belum Lunas",
|
|
||||||
"travel_number": "232",
|
|
||||||
"balance": -201125000
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"total": {
|
|
||||||
"aging": 2,
|
|
||||||
"total_price": 190645000,
|
|
||||||
"payment_price": 8800000,
|
|
||||||
"debt_price": -181845000
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* Dummy data for DebtSupplier
|
|
||||||
* Generated from: debt-supplier.dummy.json
|
|
||||||
*
|
|
||||||
* This file is auto-generated. Do not edit manually.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { DebtSupplier } from '../../types/api/report/debt-supplier';
|
|
||||||
import { BaseApiResponse } from '@/types/api/api-general';
|
|
||||||
import dummyData from './debt-supplier.dummy.json';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get dummy DebtSupplier data
|
|
||||||
* @returns Promise with BaseApiResponse containing DebtSupplier
|
|
||||||
*/
|
|
||||||
export async function getDummyDebtSupplier(): Promise<
|
|
||||||
BaseApiResponse<DebtSupplier[]> | undefined
|
|
||||||
> {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
setTimeout(() => {
|
|
||||||
resolve({
|
|
||||||
code: 200,
|
|
||||||
status: 'success',
|
|
||||||
message: 'Data retrieved successfully',
|
|
||||||
data: dummyData as unknown as DebtSupplier[],
|
|
||||||
});
|
|
||||||
}, 500);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import { BaseApiService } from '@/services/api/base';
|
||||||
|
import { BaseApiResponse } from '@/types/api/api-general';
|
||||||
|
import { DebtSupplier } from '@/types/api/report/debt-supplier';
|
||||||
|
|
||||||
|
export class DebtSupplierApiService extends BaseApiService<
|
||||||
|
DebtSupplier,
|
||||||
|
unknown,
|
||||||
|
unknown
|
||||||
|
> {
|
||||||
|
constructor(basePath: string) {
|
||||||
|
super(basePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
async getDebtSupplierReport(
|
||||||
|
supplier_ids?: string,
|
||||||
|
filter_by?: string,
|
||||||
|
start_date?: string,
|
||||||
|
end_date?: string,
|
||||||
|
page?: number,
|
||||||
|
limit?: number
|
||||||
|
): Promise<BaseApiResponse<DebtSupplier[]> | undefined> {
|
||||||
|
return await this.customRequest<BaseApiResponse<DebtSupplier[]>>(
|
||||||
|
`debt-supplier`,
|
||||||
|
{
|
||||||
|
method: 'GET',
|
||||||
|
params: {
|
||||||
|
supplier_ids: supplier_ids,
|
||||||
|
filter_by: filter_by,
|
||||||
|
start_date: start_date,
|
||||||
|
end_date: end_date,
|
||||||
|
page: page,
|
||||||
|
limit: limit,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DebtSupplierApi = new DebtSupplierApiService('reports');
|
||||||
@@ -37,30 +37,6 @@ export class FinanceApiService extends BaseApiService<
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDebtSupplierReport(
|
|
||||||
supplier_ids?: string,
|
|
||||||
filter_by?: string,
|
|
||||||
start_date?: string,
|
|
||||||
end_date?: string,
|
|
||||||
page?: number,
|
|
||||||
limit?: number
|
|
||||||
): Promise<BaseApiResponse<DebtSupplier[]> | undefined> {
|
|
||||||
return await this.customRequest<BaseApiResponse<DebtSupplier[]>>(
|
|
||||||
`debt-supplier`,
|
|
||||||
{
|
|
||||||
method: 'GET',
|
|
||||||
params: {
|
|
||||||
supplier_ids: supplier_ids,
|
|
||||||
filter_by: filter_by,
|
|
||||||
start_date: start_date,
|
|
||||||
end_date: end_date,
|
|
||||||
page: page,
|
|
||||||
limit: limit,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// export const FinanceApi = new FinanceApiService('reports');
|
// export const FinanceApi = new FinanceApiService('reports');
|
||||||
|
|||||||
Reference in New Issue
Block a user