From a11d05e720cedbd6e83fc975caad3ac8fab0f9a9 Mon Sep 17 00:00:00 2001 From: Adnan Zahir Date: Sat, 25 Apr 2026 13:06:44 +0700 Subject: [PATCH 1/4] fix: pagination positioning --- .../report/finance/tab/CustomerPaymentTab.tsx | 44 +++++++++-------- .../report/finance/tab/DebtSupplierTab.tsx | 47 +++++++++---------- 2 files changed, 44 insertions(+), 47 deletions(-) diff --git a/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx b/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx index 8ca4a3ec..9e60b177 100644 --- a/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx +++ b/src/components/pages/report/finance/tab/CustomerPaymentTab.tsx @@ -731,29 +731,6 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => { /> )} - {!isLoading && data.length > 0 && meta && ( -
- - setCurrentPage((curr) => (curr > 1 ? curr - 1 : curr)) - } - onNextPage={() => - setCurrentPage((curr) => - meta.total_pages && curr < meta.total_pages - ? curr + 1 - : curr - ) - } - onPageChange={(pageNumber) => setCurrentPage(pageNumber)} - rowOptions={[10, 20, 50, 100]} - onRowChange={setPageSize} - /> -
- )} - {!isLoading && data.length > 0 && data.map((customerReport) => { @@ -848,6 +825,27 @@ const CustomerPaymentTab = ({ tabId }: CustomerPaymentTabProps) => { ); })} + + {!isLoading && data.length > 0 && meta && ( +
+ + setCurrentPage((curr) => (curr > 1 ? curr - 1 : curr)) + } + onNextPage={() => + setCurrentPage((curr) => + meta.total_pages && curr < meta.total_pages ? curr + 1 : curr + ) + } + onPageChange={(pageNumber) => setCurrentPage(pageNumber)} + rowOptions={[10, 20, 50, 100]} + onRowChange={setPageSize} + /> +
+ )} {/* Filter Modal */} diff --git a/src/components/pages/report/finance/tab/DebtSupplierTab.tsx b/src/components/pages/report/finance/tab/DebtSupplierTab.tsx index c9a772b4..8d760208 100644 --- a/src/components/pages/report/finance/tab/DebtSupplierTab.tsx +++ b/src/components/pages/report/finance/tab/DebtSupplierTab.tsx @@ -149,7 +149,8 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => { handleFilterModalOpenRef.current = () => { const restoredFilterBy = - dataTypeOptions.find((opt) => opt.value === filterParams.filter_by) || null; + dataTypeOptions.find((opt) => opt.value === filterParams.filter_by) || + null; const supplierIdList = filterParams.supplier_ids ? filterParams.supplier_ids.split(',') @@ -662,29 +663,6 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => { /> )} - {!isLoading && data.length > 0 && meta && ( -
- - setCurrentPage((curr) => (curr > 1 ? curr - 1 : curr)) - } - onNextPage={() => - setCurrentPage((curr) => - meta.total_pages && curr < meta.total_pages - ? curr + 1 - : curr - ) - } - onPageChange={(pageNumber) => setCurrentPage(pageNumber)} - rowOptions={[10, 20, 50, 100]} - onRowChange={setPageSize} - /> -
- )} - {!isLoading && data.length > 0 && data.map((supplierReport) => { @@ -772,6 +750,27 @@ const DebtSupplierTab = ({ tabId }: DebtSupplierTabProps) => { ); })} + + {!isLoading && data.length > 0 && meta && ( +
+ + setCurrentPage((curr) => (curr > 1 ? curr - 1 : curr)) + } + onNextPage={() => + setCurrentPage((curr) => + meta.total_pages && curr < meta.total_pages ? curr + 1 : curr + ) + } + onPageChange={(pageNumber) => setCurrentPage(pageNumber)} + rowOptions={[10, 20, 50, 100]} + onRowChange={setPageSize} + /> +
+ )} {/* Filter Modal */} From 2b3b6b9549d920a27c9aecf3bcb72730e8191323 Mon Sep 17 00:00:00 2001 From: Adnan Zahir Date: Sat, 25 Apr 2026 22:24:39 +0700 Subject: [PATCH 2/4] feat: expose received_date in laporan pembelian --- src/components/pages/purchase/PurchaseTable.tsx | 8 ++++++++ src/types/api/purchase/purchase.d.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/components/pages/purchase/PurchaseTable.tsx b/src/components/pages/purchase/PurchaseTable.tsx index ada8a62e..3cbb894f 100644 --- a/src/components/pages/purchase/PurchaseTable.tsx +++ b/src/components/pages/purchase/PurchaseTable.tsx @@ -305,6 +305,14 @@ const PurchaseTable = () => { ? formatDate(props.row.original.po_date, 'DD MMM YYYY') : '-', }, + { + accessorKey: 'received_date', + header: 'Tgl. Terima', + cell: (props) => + props.row.original.received_date + ? formatDate(props.row.original.received_date, 'DD MMM YYYY') + : '-', + }, { accessorKey: 'due_date', header: 'Jatuh Tempo', diff --git a/src/types/api/purchase/purchase.d.ts b/src/types/api/purchase/purchase.d.ts index 0fe5562e..615c2e5c 100644 --- a/src/types/api/purchase/purchase.d.ts +++ b/src/types/api/purchase/purchase.d.ts @@ -68,6 +68,7 @@ export type BasePurchase = { supplier: Supplier; credit_term?: number; due_date: string; + received_date?: string | null; notes?: string | null; deleted_at?: string | null; created_by: number; From a1a0b71814da15f76406c035bee1927f4cfd005c Mon Sep 17 00:00:00 2001 From: Adnan Zahir Date: Sat, 25 Apr 2026 22:47:59 +0700 Subject: [PATCH 3/4] feat: editable po_date --- .../purchase/order/PurchaseOrderDetail.tsx | 226 ++++++++++++++++-- src/services/api/purchase.ts | 13 + src/types/api/purchase/purchase.d.ts | 1 + 3 files changed, 219 insertions(+), 21 deletions(-) diff --git a/src/components/pages/purchase/order/PurchaseOrderDetail.tsx b/src/components/pages/purchase/order/PurchaseOrderDetail.tsx index 6706039c..2f8d5931 100644 --- a/src/components/pages/purchase/order/PurchaseOrderDetail.tsx +++ b/src/components/pages/purchase/order/PurchaseOrderDetail.tsx @@ -26,6 +26,8 @@ import PurchaseOrderAcceptApprovalForm from '@/components/pages/purchase/form/or import PurchaseOrderInvoice from '@/components/pages/purchase/order/PurchaseOrderInvoice'; import Card from '@/components/Card'; +import DateInput from '@/components/input/DateInput'; +import TextArea from '@/components/input/TextArea'; import { CreateAcceptApprovalRequestPayload, CreateManagerApprovalRequestPayload, @@ -96,6 +98,7 @@ const PurchaseOrderDetail = ({ const acceptRejectionModal = useModal(); const managerRejectionModal = useModal(); const editModal = useModal(); + const editPoDateModal = useModal(); const penerimaanBarangModal = useModal(); const deleteModal = useModal(); @@ -105,6 +108,9 @@ const PurchaseOrderDetail = ({ const [isDeleteLoading, setIsDeleteLoading] = useState(false); const [selectedItem, setSelectedItem] = useState(null); const [, setApprovalNotes] = useState(''); + const [managerApprovalNotes, setManagerApprovalNotes] = useState(''); + const [managerApprovalPoDate, setManagerApprovalPoDate] = useState(''); + const [editPoDate, setEditPoDate] = useState(''); const selectedRowIds = Object.keys(rowSelection).map((item) => parseInt(item) @@ -212,6 +218,8 @@ const PurchaseOrderDetail = ({ break; case 2: setApprovalNotes(''); + setManagerApprovalNotes(''); + setManagerApprovalPoDate(''); confirmationModalWithNotes.openModal(); break; case 3: @@ -414,17 +422,44 @@ const PurchaseOrderDetail = ({ deleteModal, ]); + const updatePoDateHandler = useCallback(async () => { + const purchaseRequestId = searchParams.get('purchaseId') + ? parseInt(searchParams.get('purchaseId')!) + : initialValues?.id || 1; + + if (!purchaseRequestId) { + toast.error('Purchase Request ID is required'); + return; + } + + const res = await PurchaseApi.updatePoDate(purchaseRequestId, { + po_date: editPoDate, + }); + + if (isResponseError(res)) { + toast.error(res.message || 'Gagal mengubah tanggal PO'); + return; + } + + toast.success('Tanggal PO berhasil diubah'); + setEditPoDate(''); + editPoDateModal.closeModal(); + refetchData?.(); + }, [initialValues?.id, searchParams, editPoDate, editPoDateModal, refetchData]); + // ===== APPROVAL/REJECTION HANDLERS ===== - const managerApprovalHandler = async (notes: string) => { + const managerApprovalHandler = async () => { const payload: CreateManagerApprovalRequestPayload = { action: 'APPROVED', - notes: notes || null, + notes: managerApprovalNotes || null, + po_date: managerApprovalPoDate || null, }; await createManagerApprovalHandler(payload); await refreshApprovals(); await refetchData?.(); - setApprovalNotes(''); + setManagerApprovalNotes(''); + setManagerApprovalPoDate(''); confirmationModalWithNotes.closeModal(); }; @@ -829,6 +864,45 @@ const PurchaseOrderDetail = ({ + {purchaseData.po_date && + !purchaseData.po_date.startsWith('0001') && ( +
+
+ + Tanggal PO + +
+ + :{' '} + {formatDate(purchaseData.po_date, 'DD MMM YYYY')} + + + + +
+
+
+ )} @@ -1016,27 +1090,78 @@ const PurchaseOrderDetail = ({ - {/* Confirmation Modal with Notes */} - { - setApprovalNotes(''); - confirmationModalWithNotes.closeModal(); - }, - }} - /> + > +
+
+

+ Konfirmasi Approval Manager +

+ +
+ +
+

+ Apakah Anda yakin ingin melanjutkan approval ini? +

+ + setManagerApprovalPoDate(e.target.value)} + /> + +