From 73e86970975e02fd0a93fc2b2950d5cc90101e7e Mon Sep 17 00:00:00 2001 From: rstubryan Date: Wed, 28 Jan 2026 11:51:07 +0700 Subject: [PATCH 1/2] refactor(FE): Allow editing at approval steps 5 and 6 --- src/app/expense/realization/edit/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/expense/realization/edit/page.tsx b/src/app/expense/realization/edit/page.tsx index 95e27eef..a46ac17c 100644 --- a/src/app/expense/realization/edit/page.tsx +++ b/src/app/expense/realization/edit/page.tsx @@ -38,8 +38,8 @@ const ExpenseRealizationEditPage = () => { !isLoadingExpense && isResponseSuccess(expense) && expense.data.latest_approval.action !== 'REJECTED' && - (expense.data.latest_approval.step_number === 4 || - expense.data.latest_approval.step_number === 5); + (expense.data.latest_approval.step_number === 5 || + expense.data.latest_approval.step_number === 6); if (!isLoadingExpense && !isExpenseRealizationCanBeEdited) { router.back(); From 8671f37ada1106189766d1a0172180312438a405 Mon Sep 17 00:00:00 2001 From: rstubryan Date: Wed, 28 Jan 2026 12:19:36 +0700 Subject: [PATCH 2/2] refactor(FE): Treat kandang_id as optional and use expense id --- .../expense/form/ExpenseRealizationForm.schema.ts | 11 +++++++++-- .../pages/expense/form/ExpenseRealizationForm.tsx | 12 +++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/components/pages/expense/form/ExpenseRealizationForm.schema.ts b/src/components/pages/expense/form/ExpenseRealizationForm.schema.ts index 94d6e38d..b5c4e469 100644 --- a/src/components/pages/expense/form/ExpenseRealizationForm.schema.ts +++ b/src/components/pages/expense/form/ExpenseRealizationForm.schema.ts @@ -73,7 +73,14 @@ export const ExpenseRealizationFormSchema: Yup.ObjectSchema { + if (value === undefined || value === null || value === 0) { + return true; + } + return value >= 1; + }), cost_items: Yup.array() .of( Yup.object({ @@ -175,7 +182,7 @@ export const getExpenseRealizationFormInitialValues = ( : []; return { - kandang_id: kandangExpense.kandang_id, + kandang_id: kandangExpense.id, cost_items: costItemsInitialValue, }; }) diff --git a/src/components/pages/expense/form/ExpenseRealizationForm.tsx b/src/components/pages/expense/form/ExpenseRealizationForm.tsx index 6117c920..acc0a393 100644 --- a/src/components/pages/expense/form/ExpenseRealizationForm.tsx +++ b/src/components/pages/expense/form/ExpenseRealizationForm.tsx @@ -101,13 +101,23 @@ const ExpenseRealizationForm = ({ values.realizations.forEach((realization) => { realization.cost_items.forEach((costItem) => { - const realizationItem = { + const realizationItem: { + expense_nonstock_id: number; + qty: number; + price: number; + notes: string; + kandang_id?: number; + } = { expense_nonstock_id: costItem.nonstock?.value as number, qty: parseFloat(String(costItem.quantity)) as number, price: parseFloat(String(costItem.price)) as number, notes: costItem.notes ?? '', }; + if (realization.kandang_id && realization.kandang_id > 0) { + realizationItem.kandang_id = realization.kandang_id; + } + realizations.push(realizationItem); }); });