+2
-1
@@ -870,7 +870,8 @@
|
||||
"business": "کسبوکار",
|
||||
"invoice_count": "تعداد صورتحساب",
|
||||
"water_bill": "قبض آب",
|
||||
"monthly_charge": "شارژ ماهانه"
|
||||
"monthly_charge": "شارژ ماهانه",
|
||||
"title": "عنوان"
|
||||
},
|
||||
"request": {
|
||||
"request_list": "لیست درخواست ها",
|
||||
|
||||
@@ -39,12 +39,14 @@ const CreateBill: FC = () => {
|
||||
|
||||
const formik = useFormik<CreateBillType>({
|
||||
initialValues: {
|
||||
title: '',
|
||||
waterRate: 0,
|
||||
dueDays: 0,
|
||||
values: [],
|
||||
},
|
||||
enableReinitialize: true,
|
||||
validationSchema: Yup.object({
|
||||
title: Yup.string().trim(),
|
||||
waterRate: Yup.number().min(0, 'نرخ آب باید عدد مثبت باشد').required('نرخ آب الزامی است'),
|
||||
dueDays: Yup.number().min(0, 'تعداد روز مهلت باید عدد مثبت باشد').required('تعداد روز مهلت الزامی است'),
|
||||
values: Yup.array()
|
||||
@@ -125,7 +127,7 @@ const CreateBill: FC = () => {
|
||||
return
|
||||
}
|
||||
createBillWithExcel.mutate(
|
||||
{ waterRate, dueDays, file: excelFile },
|
||||
{ title: formik.values.title?.trim() || undefined, waterRate, dueDays, file: excelFile },
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success('قبض آب با موفقیت از طریق اکسل ثبت شد')
|
||||
@@ -187,6 +189,19 @@ const CreateBill: FC = () => {
|
||||
<div className="mt-10 bg-white py-8 xl:px-10 px-4 rounded-3xl">
|
||||
<div className="text-base font-medium mb-6">اطلاعات قبض</div>
|
||||
|
||||
<div className="mt-6">
|
||||
<Input
|
||||
label="عنوان"
|
||||
name="title"
|
||||
type="text"
|
||||
value={formik.values.title ?? ''}
|
||||
onChange={formik.handleChange}
|
||||
onBlur={formik.handleBlur}
|
||||
error_text={formik.touched.title && formik.errors.title ? String(formik.errors.title) : ''}
|
||||
placeholder="عنوان اختیاری برای قبض"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="rowTwoInput mt-6">
|
||||
<Input
|
||||
label="نرخ آب (تومان)"
|
||||
|
||||
@@ -17,10 +17,12 @@ const CreateCharge: FC = () => {
|
||||
|
||||
const formik = useFormik<CreateBillChargeType>({
|
||||
initialValues: {
|
||||
title: '',
|
||||
chargeRate: 0,
|
||||
dueDays: 0,
|
||||
},
|
||||
validationSchema: Yup.object({
|
||||
title: Yup.string().trim(),
|
||||
chargeRate: Yup.number()
|
||||
.min(0, 'نرخ شارژ باید عدد مثبت باشد')
|
||||
.required('نرخ شارژ الزامی است'),
|
||||
@@ -30,6 +32,7 @@ const CreateCharge: FC = () => {
|
||||
}),
|
||||
onSubmit: async (values) => {
|
||||
const payload = {
|
||||
title: values.title?.trim() || undefined,
|
||||
chargeRate: Math.floor(Number(values.chargeRate)) || 0,
|
||||
dueDays: Math.floor(Number(values.dueDays)) || 0,
|
||||
}
|
||||
@@ -66,6 +69,23 @@ const CreateCharge: FC = () => {
|
||||
<div className="mt-10 bg-white py-8 xl:px-10 px-4 rounded-3xl">
|
||||
<div className="text-base font-medium mb-6">اطلاعات قبض شارژ</div>
|
||||
|
||||
<div className="mt-6">
|
||||
<Input
|
||||
label="عنوان"
|
||||
name="title"
|
||||
type="text"
|
||||
value={formik.values.title ?? ''}
|
||||
onChange={formik.handleChange}
|
||||
onBlur={formik.handleBlur}
|
||||
error_text={
|
||||
formik.touched.title && formik.errors.title
|
||||
? String(formik.errors.title)
|
||||
: ''
|
||||
}
|
||||
placeholder="عنوان اختیاری برای قبض شارژ"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="rowTwoInput mt-6">
|
||||
<Input
|
||||
label="نرخ شارژ (تومان)"
|
||||
|
||||
@@ -33,6 +33,7 @@ const BillsList: FC = () => {
|
||||
<thead className="thead">
|
||||
<tr>
|
||||
<Td text={t('bill.row')} />
|
||||
<Td text={t('bill.title')} />
|
||||
<Td text={t('bill.created_at')} />
|
||||
<Td text={t('bill.type')} />
|
||||
<Td text={t('bill.invoice_count')} />
|
||||
@@ -43,6 +44,7 @@ const BillsList: FC = () => {
|
||||
{data?.data?.bills?.map((item: BillItemType, index: number) => (
|
||||
<tr key={item.id} className="tr hover:bg-gray-50">
|
||||
<Td text={String((page - 1) * 10 + index + 1)} />
|
||||
<Td text={item.title ?? '—'} />
|
||||
<Td text={moment(item.createdAt).format('jYYYY/jMM/jDD')} />
|
||||
<Td text={getBillTypeLabel(item.type)} />
|
||||
<Td text={''}>
|
||||
|
||||
@@ -22,6 +22,7 @@ export const getBills = async (page: number = 1) => {
|
||||
|
||||
export const createBillWithExcel = async (params: CreateBillWithExcelType) => {
|
||||
const formData = new FormData();
|
||||
if (params.title) formData.append("title", params.title);
|
||||
formData.append("waterRate", String(params.waterRate));
|
||||
formData.append("dueDays", String(params.dueDays));
|
||||
formData.append("file", params.file);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export type CreateBillType = {
|
||||
title?: string;
|
||||
waterRate: number;
|
||||
dueDays: number;
|
||||
values: {
|
||||
@@ -8,11 +9,13 @@ export type CreateBillType = {
|
||||
};
|
||||
|
||||
export type CreateBillChargeType = {
|
||||
title?: string;
|
||||
chargeRate: number;
|
||||
dueDays: number;
|
||||
};
|
||||
|
||||
export type CreateBillWithExcelType = {
|
||||
title?: string;
|
||||
waterRate: number;
|
||||
dueDays: number;
|
||||
file: File;
|
||||
@@ -24,6 +27,7 @@ export type BillItemType = {
|
||||
updatedAt: string;
|
||||
deletedAt: string | null;
|
||||
type: 'water_bill' | 'monthly_charge';
|
||||
title?: string;
|
||||
business: string;
|
||||
invoiceCount: number;
|
||||
};
|
||||
|
||||
@@ -35,7 +35,7 @@ const ReceiptSubMenu: FC = () => {
|
||||
/>
|
||||
<SubMenuItem
|
||||
title={t('receip.add_receip')}
|
||||
isActive={isActive('create')}
|
||||
isActive={isActive('receipts/create')}
|
||||
link={Pages.receipts.create}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user