mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
Merge branch 'fix/finance' into 'development'
[FIX/FE] Adding Select Input Injection Type for Negative or Positive Value See merge request mbugroup/lti-web-client!257
This commit is contained in:
@@ -66,7 +66,11 @@ const FinanceDetail = ({ finance }: { finance: Finance }) => {
|
||||
},
|
||||
{
|
||||
label: 'Nominal',
|
||||
value: formatCurrency(Math.abs(finance.nominal)),
|
||||
value: formatCurrency(
|
||||
finance.transaction_type === 'INJECTION'
|
||||
? finance.nominal
|
||||
: Math.abs(finance.nominal)
|
||||
),
|
||||
},
|
||||
].filter((item) => {
|
||||
// Hide party account number row if transaction type is INJECTION
|
||||
|
||||
@@ -416,7 +416,8 @@ const FinanceTable = () => {
|
||||
},
|
||||
{
|
||||
header: 'Pemasukan (Rp)',
|
||||
accessorFn: (finance: Finance) => formatCurrency(finance.income_amount),
|
||||
accessorFn: (finance: Finance) =>
|
||||
formatCurrency(Math.abs(finance.income_amount)),
|
||||
},
|
||||
{
|
||||
header: 'Aksi',
|
||||
|
||||
@@ -5,6 +5,7 @@ import * as Yup from 'yup';
|
||||
export type InjectionFormValues = {
|
||||
bank_id_option: OptionType | null;
|
||||
adjustment_date: string;
|
||||
injection_type?: OptionType | null | undefined;
|
||||
nominal: string;
|
||||
note: string;
|
||||
};
|
||||
@@ -18,6 +19,7 @@ export const InjectionFormSchema = Yup.object<InjectionFormValues>({
|
||||
(value) => value !== null && value !== undefined
|
||||
),
|
||||
adjustment_date: Yup.string().required('Tanggal penyesuaian wajib diisi'),
|
||||
injection_type: Yup.mixed().nullable().required('Tipe injeksi wajib diisi'),
|
||||
nominal: Yup.string().required('Nominal wajib diisi'),
|
||||
note: Yup.string().required('Catatan wajib diisi'),
|
||||
});
|
||||
|
||||
@@ -28,6 +28,10 @@ import { useCallback, useMemo, useState } from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import Alert from '@/components/Alert';
|
||||
import { Icon } from '@iconify/react';
|
||||
import {
|
||||
FINANCE_INJECTION_STATUS,
|
||||
FINANCE_INJECTION_TYPE_OPTIONS,
|
||||
} from '@/config/constant';
|
||||
|
||||
interface FormFinanceInjectionProps {
|
||||
type?: 'add' | 'edit';
|
||||
@@ -51,6 +55,11 @@ const FormFinanceInjection = ({
|
||||
}
|
||||
: null,
|
||||
adjustment_date: initialValues?.payment_date || '',
|
||||
injection_type: initialValues?.nominal
|
||||
? initialValues.nominal < 0
|
||||
? FINANCE_INJECTION_TYPE_OPTIONS[1]
|
||||
: FINANCE_INJECTION_TYPE_OPTIONS[0]
|
||||
: FINANCE_INJECTION_TYPE_OPTIONS[0],
|
||||
nominal: initialValues?.nominal?.toString() || '',
|
||||
note: initialValues?.notes || '',
|
||||
};
|
||||
@@ -94,7 +103,10 @@ const FormFinanceInjection = ({
|
||||
return {
|
||||
bank_id: Number(values.bank_id_option?.value) || 0,
|
||||
adjustment_date: formatDate(values.adjustment_date, 'YYYY-MM-DD'),
|
||||
nominal: isNaN(Number(values.nominal)) ? 0 : Number(values.nominal),
|
||||
nominal:
|
||||
values.injection_type?.value == 'POSITIVE'
|
||||
? Math.abs(Number(values.nominal))
|
||||
: -Math.abs(Number(values.nominal)),
|
||||
notes: values.note,
|
||||
};
|
||||
};
|
||||
@@ -203,6 +215,24 @@ const FormFinanceInjection = ({
|
||||
}
|
||||
required
|
||||
/>
|
||||
<SelectInput
|
||||
label='Tipe Injeksi'
|
||||
placeholder='Pilih tipe injeksi'
|
||||
options={FINANCE_INJECTION_TYPE_OPTIONS}
|
||||
value={formik.values.injection_type}
|
||||
onChange={(value) => {
|
||||
formik.setFieldValue('injection_type', value);
|
||||
}}
|
||||
isError={Boolean(
|
||||
formik.touched.injection_type && formik.errors.injection_type
|
||||
)}
|
||||
errorMessage={
|
||||
formik.touched.injection_type && formik.errors.injection_type
|
||||
? formik.errors.injection_type
|
||||
: ''
|
||||
}
|
||||
required
|
||||
/>
|
||||
<NumberInput
|
||||
label='Nominal'
|
||||
placeholder='Masukkan nominal'
|
||||
@@ -216,8 +246,17 @@ const FormFinanceInjection = ({
|
||||
? formik.errors.nominal
|
||||
: ''
|
||||
}
|
||||
allowNegative={true}
|
||||
allowNegative={false}
|
||||
required
|
||||
startAdornment={
|
||||
formik.values.injection_type?.value === 'POSITIVE' ? (
|
||||
<Icon icon='mdi:plus' />
|
||||
) : formik.values.injection_type?.value === 'NEGATIVE' ? (
|
||||
<Icon icon='mdi:minus' />
|
||||
) : (
|
||||
''
|
||||
)
|
||||
}
|
||||
/>
|
||||
<TextArea
|
||||
label='Catatan'
|
||||
|
||||
@@ -389,6 +389,11 @@ export const FINANCE_INITIAL_BALANCE_TYPE_OPTIONS = [
|
||||
{ label: 'Saldo Awal Negatif', value: 'NEGATIVE' },
|
||||
];
|
||||
|
||||
export const FINANCE_INJECTION_TYPE_OPTIONS = [
|
||||
{ label: 'Saldo Injection Positif', value: 'POSITIVE' },
|
||||
{ label: 'Saldo Injection Negatif', value: 'NEGATIVE' },
|
||||
];
|
||||
|
||||
export const FINANCE_TRANSACTION_TYPE_OPTIONS = [
|
||||
{ label: 'Pembelian', value: 'PEMBELIAN' },
|
||||
{ label: 'Penjualan', value: 'PENJUALAN' },
|
||||
|
||||
Reference in New Issue
Block a user