mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
fix(FE-337): fix finance input and transaction type
This commit is contained in:
@@ -39,6 +39,12 @@ interface FormFinanceAddProps {
|
|||||||
initialValues?: Finance;
|
initialValues?: Finance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface PartyCommonProps {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
account_number: string;
|
||||||
|
}
|
||||||
|
|
||||||
const FormFinanceAdd = ({
|
const FormFinanceAdd = ({
|
||||||
type = 'add',
|
type = 'add',
|
||||||
initialValues,
|
initialValues,
|
||||||
@@ -52,10 +58,12 @@ const FormFinanceAdd = ({
|
|||||||
FINANCE_PARTY_TYPE_OPTIONS.find(
|
FINANCE_PARTY_TYPE_OPTIONS.find(
|
||||||
(option) => option.value === initialValues?.party.type
|
(option) => option.value === initialValues?.party.type
|
||||||
) || null,
|
) || null,
|
||||||
party_id_option: {
|
party_id_option: initialValues?.party
|
||||||
|
? {
|
||||||
label: initialValues?.party.name || '',
|
label: initialValues?.party.name || '',
|
||||||
value: initialValues?.party.id || 0,
|
value: initialValues?.party.id || 0,
|
||||||
},
|
}
|
||||||
|
: null,
|
||||||
payment_date: initialValues?.payment_date || '',
|
payment_date: initialValues?.payment_date || '',
|
||||||
payment_method_option:
|
payment_method_option:
|
||||||
FINANCE_PAYMENT_METHOD_OPTIONS.find(
|
FINANCE_PAYMENT_METHOD_OPTIONS.find(
|
||||||
@@ -97,8 +105,11 @@ const FormFinanceAdd = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ===== Options =====
|
// ===== Options =====
|
||||||
const { options: partyOptions, isLoadingOptions: isLoadingPartyOptions } =
|
const {
|
||||||
useSelect(
|
options: partyOptions,
|
||||||
|
isLoadingOptions: isLoadingPartyOptions,
|
||||||
|
rawData: partyRawData,
|
||||||
|
} = useSelect<PartyCommonProps>(
|
||||||
formik.values.party_type_option?.value === 'CUSTOMER'
|
formik.values.party_type_option?.value === 'CUSTOMER'
|
||||||
? CustomerApi.basePath
|
? CustomerApi.basePath
|
||||||
: SupplierApi.basePath,
|
: SupplierApi.basePath,
|
||||||
@@ -204,6 +215,14 @@ const FormFinanceAdd = ({
|
|||||||
value={formik.values.party_id_option}
|
value={formik.values.party_id_option}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
formik.setFieldValue('party_id_option', value);
|
formik.setFieldValue('party_id_option', value);
|
||||||
|
if (isResponseSuccess(partyRawData) && value) {
|
||||||
|
formik.setFieldValue(
|
||||||
|
'party_account_number',
|
||||||
|
partyRawData.data?.find(
|
||||||
|
(item) => item.id === (value as OptionType)?.value
|
||||||
|
)?.account_number || ''
|
||||||
|
);
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
isLoading={isLoadingPartyOptions}
|
isLoading={isLoadingPartyOptions}
|
||||||
isError={Boolean(
|
isError={Boolean(
|
||||||
@@ -312,6 +331,7 @@ const FormFinanceAdd = ({
|
|||||||
: ''
|
: ''
|
||||||
}
|
}
|
||||||
required
|
required
|
||||||
|
readOnly
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
label='Nomor Referensi'
|
label='Nomor Referensi'
|
||||||
|
|||||||
@@ -308,7 +308,7 @@ export const FINANCE_INITIAL_BALANCE_TYPE_OPTIONS = [
|
|||||||
{ label: 'Saldo Awal Negatif', value: 'NEGATIVE' },
|
{ label: 'Saldo Awal Negatif', value: 'NEGATIVE' },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const FINANCE_TRANSACTION_STATUS = ['PENJUALAN', 'BIAYA'];
|
export const FINANCE_TRANSACTION_STATUS = ['PENJUALAN', 'PEMBELIAN'];
|
||||||
|
|
||||||
export const FINANCE_INITIAL_BALANCE_STATUS = ['SALDO_AWAL'];
|
export const FINANCE_INITIAL_BALANCE_STATUS = ['SALDO_AWAL'];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user