mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor: update CreateExpensePayload, UpdateExpensePayload, and CreateExpenseRealizationPayload types
This commit is contained in:
@@ -20,7 +20,7 @@ type ExpenseFormSchemaType = {
|
||||
existing_documents?: { id: number; name: string; url: string }[];
|
||||
deleted_documents?: number[];
|
||||
documents?: File[];
|
||||
cost_per_kandangs: {
|
||||
expense_nonstocks: {
|
||||
kandang_id: number;
|
||||
cost_items: {
|
||||
nonstock?: {
|
||||
@@ -28,7 +28,7 @@ type ExpenseFormSchemaType = {
|
||||
label: string;
|
||||
};
|
||||
quantity?: number;
|
||||
total_cost?: number;
|
||||
price?: number;
|
||||
notes?: string;
|
||||
}[];
|
||||
}[];
|
||||
@@ -74,7 +74,7 @@ export const ExpenseRequestFormSchema: Yup.ObjectSchema<ExpenseFormSchemaType> =
|
||||
|
||||
documents: Yup.array().of(Yup.mixed<File>().required()).optional(),
|
||||
|
||||
cost_per_kandangs: Yup.array()
|
||||
expense_nonstocks: Yup.array()
|
||||
.of(
|
||||
Yup.object({
|
||||
kandang_id: Yup.number().min(1, 'Wajib memilih kandang!').required(),
|
||||
@@ -86,7 +86,7 @@ export const ExpenseRequestFormSchema: Yup.ObjectSchema<ExpenseFormSchemaType> =
|
||||
label: Yup.string().required(),
|
||||
}).required('Nonstock wajib diisi!'),
|
||||
quantity: Yup.number().required('Total kuantitas wajib diisi!'),
|
||||
total_cost: Yup.number().required('Total biaya wajib diisi!'),
|
||||
price: Yup.number().required('Harga satuan wajib diisi!'),
|
||||
notes: Yup.string(),
|
||||
})
|
||||
)
|
||||
@@ -128,8 +128,8 @@ export const getExpenseFormInitialValues = (
|
||||
label: initialValues.location.name,
|
||||
}
|
||||
: undefined,
|
||||
transaction_date: initialValues?.expense_date
|
||||
? formatDate(initialValues.expense_date, 'YYYY-MM-DD')
|
||||
transaction_date: initialValues?.transaction_date
|
||||
? formatDate(initialValues.transaction_date, 'YYYY-MM-DD')
|
||||
: undefined,
|
||||
kandangs: initialValues?.kandangs.map((kandang) => ({
|
||||
id: kandang.kandang_id,
|
||||
@@ -148,7 +148,7 @@ export const getExpenseFormInitialValues = (
|
||||
})),
|
||||
deleted_documents: [],
|
||||
documents: [],
|
||||
cost_per_kandangs: initialValues?.kandangs
|
||||
expense_nonstocks: initialValues?.kandangs
|
||||
? initialValues.kandangs.map((kandangExpense) => ({
|
||||
kandang_id: kandangExpense.kandang_id,
|
||||
cost_items: kandangExpense.pengajuans
|
||||
@@ -158,7 +158,7 @@ export const getExpenseFormInitialValues = (
|
||||
label: expenseItem.nonstock.name,
|
||||
},
|
||||
quantity: expenseItem.qty,
|
||||
total_cost: expenseItem.total_price,
|
||||
price: expenseItem.price,
|
||||
notes: expenseItem.note,
|
||||
}))
|
||||
: [],
|
||||
|
||||
Reference in New Issue
Block a user