mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Merge branch 'dev/hotfix/restu' into 'development'
[HOTFIX/FE] Fix Edit Realization Restriction Issue Based on Approval Line See merge request mbugroup/lti-web-client!273
This commit is contained in:
@@ -38,8 +38,8 @@ const ExpenseRealizationEditPage = () => {
|
|||||||
!isLoadingExpense &&
|
!isLoadingExpense &&
|
||||||
isResponseSuccess(expense) &&
|
isResponseSuccess(expense) &&
|
||||||
expense.data.latest_approval.action !== 'REJECTED' &&
|
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) {
|
if (!isLoadingExpense && !isExpenseRealizationCanBeEdited) {
|
||||||
router.back();
|
router.back();
|
||||||
|
|||||||
@@ -73,7 +73,14 @@ export const ExpenseRealizationFormSchema: Yup.ObjectSchema<ExpenseRealizationFo
|
|||||||
realizations: Yup.array()
|
realizations: Yup.array()
|
||||||
.of(
|
.of(
|
||||||
Yup.object({
|
Yup.object({
|
||||||
kandang_id: Yup.number().min(1, 'Wajib memilih kandang!').optional(),
|
kandang_id: Yup.number()
|
||||||
|
.optional()
|
||||||
|
.test('valid-kandang-id', 'Wajib memilih kandang!', (value) => {
|
||||||
|
if (value === undefined || value === null || value === 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return value >= 1;
|
||||||
|
}),
|
||||||
cost_items: Yup.array()
|
cost_items: Yup.array()
|
||||||
.of(
|
.of(
|
||||||
Yup.object({
|
Yup.object({
|
||||||
@@ -175,7 +182,7 @@ export const getExpenseRealizationFormInitialValues = (
|
|||||||
: [];
|
: [];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
kandang_id: kandangExpense.kandang_id,
|
kandang_id: kandangExpense.id,
|
||||||
cost_items: costItemsInitialValue,
|
cost_items: costItemsInitialValue,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -101,13 +101,23 @@ const ExpenseRealizationForm = ({
|
|||||||
|
|
||||||
values.realizations.forEach((realization) => {
|
values.realizations.forEach((realization) => {
|
||||||
realization.cost_items.forEach((costItem) => {
|
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,
|
expense_nonstock_id: costItem.nonstock?.value as number,
|
||||||
qty: parseFloat(String(costItem.quantity)) as number,
|
qty: parseFloat(String(costItem.quantity)) as number,
|
||||||
price: parseFloat(String(costItem.price)) as number,
|
price: parseFloat(String(costItem.price)) as number,
|
||||||
notes: costItem.notes ?? '',
|
notes: costItem.notes ?? '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (realization.kandang_id && realization.kandang_id > 0) {
|
||||||
|
realizationItem.kandang_id = realization.kandang_id;
|
||||||
|
}
|
||||||
|
|
||||||
realizations.push(realizationItem);
|
realizations.push(realizationItem);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user