mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 21:41:57 +00:00
feat(FE-311): Use latest_approval for purchase approvals
This commit is contained in:
@@ -156,9 +156,9 @@ const PurchaseOrderDetail = ({
|
||||
}, [goodsReceiptItems]);
|
||||
|
||||
const approvalStep = useMemo(() => {
|
||||
if (!initialValues?.approval) return null;
|
||||
return initialValues.approval.step_number;
|
||||
}, [initialValues?.approval]);
|
||||
if (!initialValues?.latest_approval) return null;
|
||||
return initialValues.latest_approval.step_number;
|
||||
}, [initialValues?.latest_approval]);
|
||||
|
||||
const {
|
||||
approvals,
|
||||
@@ -166,7 +166,7 @@ const PurchaseOrderDetail = ({
|
||||
rawDataApprovals,
|
||||
refresh: refreshApprovals,
|
||||
} = useApprovalSteps({
|
||||
latestApproval: initialValues?.approval,
|
||||
latestApproval: initialValues?.latest_approval,
|
||||
approvalLines: PURCHASE_ORDER_APPROVAL_LINE,
|
||||
moduleName: 'PURCHASES',
|
||||
moduleId: initialValues?.id?.toString() ?? '',
|
||||
@@ -180,16 +180,16 @@ const PurchaseOrderDetail = ({
|
||||
approvalStep !== null && approvalStep >= 1 && approvalStep <= 3;
|
||||
|
||||
const canDeleteItems = useMemo(() => {
|
||||
if (!initialValues?.approval) return false;
|
||||
if (!initialValues?.latest_approval) return false;
|
||||
|
||||
const currentStep = initialValues.approval.step_number;
|
||||
const currentStep = initialValues.latest_approval.step_number;
|
||||
|
||||
const hasReachedStep5 = rawDataApprovals?.some(
|
||||
(approval) => approval.step_number === 5
|
||||
);
|
||||
|
||||
return currentStep === 3 && !hasReachedStep5;
|
||||
}, [initialValues?.approval, rawDataApprovals]);
|
||||
}, [initialValues?.latest_approval, rawDataApprovals]);
|
||||
|
||||
const handleApprovalClick = () => {
|
||||
if (!approvalStep) return;
|
||||
@@ -222,18 +222,18 @@ const PurchaseOrderDetail = ({
|
||||
};
|
||||
|
||||
const canShowPurchaseOrderInvoice = useMemo(() => {
|
||||
if (!initialValues?.approval) return false;
|
||||
if (!initialValues?.latest_approval) return false;
|
||||
|
||||
const currentStep = initialValues.approval.step_number;
|
||||
const currentStep = initialValues.latest_approval.step_number;
|
||||
return currentStep >= 3;
|
||||
}, [initialValues?.approval]);
|
||||
}, [initialValues?.latest_approval]);
|
||||
|
||||
const canShowPenerimaanBarang = useMemo(() => {
|
||||
if (!initialValues?.approval) return false;
|
||||
if (!initialValues?.latest_approval) return false;
|
||||
|
||||
const currentStep = initialValues.approval.step_number;
|
||||
const currentStep = initialValues.latest_approval.step_number;
|
||||
return currentStep === 5;
|
||||
}, [initialValues?.approval]);
|
||||
}, [initialValues?.latest_approval]);
|
||||
|
||||
const totalBeforeTax = useMemo(() => {
|
||||
return purchaseOrderItems.reduce(
|
||||
|
||||
Vendored
+1
@@ -62,6 +62,7 @@ export type BasePurchase = {
|
||||
warehouse?: Warehouse;
|
||||
items?: PurchaseItem[];
|
||||
approval?: BaseApproval;
|
||||
latest_approval?: BaseApproval;
|
||||
};
|
||||
|
||||
export type Purchase = BaseMetadata & BasePurchase;
|
||||
|
||||
Reference in New Issue
Block a user