Merge branch 'development' of gitlab.com:mbugroup/lti-web-client into dev/restu

This commit is contained in:
rstubryan
2026-01-26 17:32:49 +07:00
5 changed files with 55 additions and 4 deletions
@@ -66,7 +66,11 @@ const FinanceDetail = ({ finance }: { finance: Finance }) => {
}, },
{ {
label: 'Nominal', label: 'Nominal',
value: formatCurrency(Math.abs(finance.nominal)), value: formatCurrency(
finance.transaction_type === 'INJECTION'
? finance.nominal
: Math.abs(finance.nominal)
),
}, },
].filter((item) => { ].filter((item) => {
// Hide party account number row if transaction type is INJECTION // Hide party account number row if transaction type is INJECTION
@@ -416,7 +416,8 @@ const FinanceTable = () => {
}, },
{ {
header: 'Pemasukan (Rp)', header: 'Pemasukan (Rp)',
accessorFn: (finance: Finance) => formatCurrency(finance.income_amount), accessorFn: (finance: Finance) =>
formatCurrency(Math.abs(finance.income_amount)),
}, },
{ {
header: 'Aksi', header: 'Aksi',
@@ -5,6 +5,7 @@ import * as Yup from 'yup';
export type InjectionFormValues = { export type InjectionFormValues = {
bank_id_option: OptionType | null; bank_id_option: OptionType | null;
adjustment_date: string; adjustment_date: string;
injection_type?: OptionType | null | undefined;
nominal: string; nominal: string;
note: string; note: string;
}; };
@@ -18,6 +19,7 @@ export const InjectionFormSchema = Yup.object<InjectionFormValues>({
(value) => value !== null && value !== undefined (value) => value !== null && value !== undefined
), ),
adjustment_date: Yup.string().required('Tanggal penyesuaian wajib diisi'), 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'), nominal: Yup.string().required('Nominal wajib diisi'),
note: Yup.string().required('Catatan 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 toast from 'react-hot-toast';
import Alert from '@/components/Alert'; import Alert from '@/components/Alert';
import { Icon } from '@iconify/react'; import { Icon } from '@iconify/react';
import {
FINANCE_INJECTION_STATUS,
FINANCE_INJECTION_TYPE_OPTIONS,
} from '@/config/constant';
interface FormFinanceInjectionProps { interface FormFinanceInjectionProps {
type?: 'add' | 'edit'; type?: 'add' | 'edit';
@@ -51,6 +55,11 @@ const FormFinanceInjection = ({
} }
: null, : null,
adjustment_date: initialValues?.payment_date || '', 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() || '', nominal: initialValues?.nominal?.toString() || '',
note: initialValues?.notes || '', note: initialValues?.notes || '',
}; };
@@ -94,7 +103,10 @@ const FormFinanceInjection = ({
return { return {
bank_id: Number(values.bank_id_option?.value) || 0, bank_id: Number(values.bank_id_option?.value) || 0,
adjustment_date: formatDate(values.adjustment_date, 'YYYY-MM-DD'), 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, notes: values.note,
}; };
}; };
@@ -203,6 +215,24 @@ const FormFinanceInjection = ({
} }
required 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 <NumberInput
label='Nominal' label='Nominal'
placeholder='Masukkan nominal' placeholder='Masukkan nominal'
@@ -216,8 +246,17 @@ const FormFinanceInjection = ({
? formik.errors.nominal ? formik.errors.nominal
: '' : ''
} }
allowNegative={true} allowNegative={false}
required required
startAdornment={
formik.values.injection_type?.value === 'POSITIVE' ? (
<Icon icon='mdi:plus' />
) : formik.values.injection_type?.value === 'NEGATIVE' ? (
<Icon icon='mdi:minus' />
) : (
''
)
}
/> />
<TextArea <TextArea
label='Catatan' label='Catatan'
+5
View File
@@ -389,6 +389,11 @@ export const FINANCE_INITIAL_BALANCE_TYPE_OPTIONS = [
{ label: 'Saldo Awal Negatif', value: 'NEGATIVE' }, { 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 = [ export const FINANCE_TRANSACTION_TYPE_OPTIONS = [
{ label: 'Pembelian', value: 'PEMBELIAN' }, { label: 'Pembelian', value: 'PEMBELIAN' },
{ label: 'Penjualan', value: 'PENJUALAN' }, { label: 'Penjualan', value: 'PENJUALAN' },