From 1f16e05c01951d007dfd6ae9d242d7a1523341e5 Mon Sep 17 00:00:00 2001 From: callmeyan Date: Sat, 3 Aug 2024 23:51:08 +0800 Subject: [PATCH] feat: add query condition --- src/components/bill/list.tsx | 21 +++++++++++---- src/components/bill/search-form.tsx | 41 ++++++++++++++++++++--------- src/i18n/translations/en.json | 2 ++ src/i18n/translations/sc.json | 2 ++ src/i18n/translations/tc.json | 2 ++ src/pages/bill/external_create.tsx | 7 +++++ src/service/generate-pdf.ts | 12 +++++---- src/types/bill.d.ts | 6 ++++- 8 files changed, 69 insertions(+), 24 deletions(-) diff --git a/src/components/bill/list.tsx b/src/components/bill/list.tsx index d46d726..700cc20 100644 --- a/src/components/bill/list.tsx +++ b/src/components/bill/list.tsx @@ -118,7 +118,7 @@ export const BillList: React.FC = (props) => { title: t('bill.title_year'), dataIndex: 'intake_year', width: 120, - render: (_, record) => (
{record.intake_year}/{record.intake_semester}
) + render: (_, record) => (
{record.intake_year}/{String(record.intake_semester).length == 1 ? '0':''}{record.intake_semester}
) }, // { // title: t('bill.title_semester'), @@ -134,6 +134,15 @@ export const BillList: React.FC = (props) => { {record.details.map((it, idx) => (
{it.bill_type}:
))} ), }, + { + title: t('bill.title_bill_type_confirm'), + dataIndex: '_detail', + ellipsis: {showTitle: true}, + width: 220, + render: (_, record) => (
+ {record.details.filter(s=>s.confirm_status == 'CONFIRMED').map((it) => (
{it.confirm_type}:
))} +
), + }, { title: t('bill.title_amount'), dataIndex: 'amount', @@ -169,10 +178,12 @@ export const BillList: React.FC = (props) => { width: 130, render: (_, {payment_method, payment_channel}) => (payment_channel?(
- {payment_channel}
- - ({payment_method}) - + {payment_channel} + {payment_method && payment_method.length > 0 &&
+ + ({payment_method}) + +
}
):'N/A'), }, diff --git a/src/components/bill/search-form.tsx b/src/components/bill/search-form.tsx index 6468320..e544b6d 100644 --- a/src/components/bill/search-form.tsx +++ b/src/components/bill/search-form.tsx @@ -15,6 +15,7 @@ type SearchFormProps = { type SearchFormFields = { dateRange?: Date[]; student_number?: string; + merchant_ref?: string; id?: string; application_number?: string; bill_number?: string; @@ -34,6 +35,9 @@ const SearchForm: React.FC = (props) => { if (value.id) { params.id = value.id; } + if (value.merchant_ref) { + params.merchant_ref = value.merchant_ref; + } if (value.student_number) { params.student_number = value.student_number; } @@ -86,32 +90,27 @@ const SearchForm: React.FC = (props) => { {props.searchHeader}
onSubmit={formSubmit}> - - + + + + + - + - + - - - FLYWIRE - CBP - PPS - - - + ID {t('bill.sort_desc')} @@ -127,6 +126,22 @@ const SearchForm: React.FC = (props) => { {t('bill.title_create_at')} {t('bill.sort_asc')} + + + FLYWIRE + CBP + PPS + + + + + FLYWIRE + CBP + PPS + + {props.showApply && <> { if (!params.details || params.details.length == 0) { return setState({error: 'params error: require detail',loading: false}) } + let tempAmount = 0; + params.details.forEach((d:BillDetail) => { + tempAmount += Number(d.amount) + }) + if(tempAmount != Number(params.amount)){ + return setState({error: 'params error: amount not equal to detail amount',loading: false}) + } createBill(params) return; } diff --git a/src/service/generate-pdf.ts b/src/service/generate-pdf.ts index d40cd8e..cf7aba9 100644 --- a/src/service/generate-pdf.ts +++ b/src/service/generate-pdf.ts @@ -26,16 +26,18 @@ export function GeneratePdf(bill: BillModel) { doc.text('ACKNOWLEDGEMENT RECEIPT', 100, 20, {}); doc.setFont('Helvetica', 'normal', 'normal'); - drawItem(doc, {title: 'Student Name:', content: bill.student_english_name || bill.student_chinese_name}, 40) + drawItem(doc, {title: 'Student Name:', content: bill.student_english_name || bill.student_chinese_name || 'N/A'}, 40) drawItem(doc, {title: 'Reference Number:', content: `${bill.id}`}, 40, "right") - drawItem(doc, {title: 'Student Number:', content: `${bill.student_number || bill.application_number}`}, 48) + drawItem(doc, {title: `${bill.student_number?"Student":"Bill"} Number:`, content: `${bill.student_number || bill.application_number}`}, 48) drawItem(doc, {title: 'Print Date:', content: dayjs().format('YYYY-MM-DD')}, 48, "right") drawItem(doc, { title: 'Programme:', - content: bill.programme_english_name + content: bill.programme_english_name || 'N/A' }, 56) - drawItem(doc, {title: 'Mode of Study:', content: bill.attendance_mode == 'FT' ? 'FULL-TIME': bill.attendance_mode}, bill.programme_english_name.length > 70?70:64) + if(bill.programme_english_name && bill.programme_english_name.length > 0){ + drawItem(doc, {title: 'Mode of Study:', content: bill.attendance_mode == 'FT' ? 'FULL-TIME': bill.attendance_mode}, bill.programme_english_name.length > 70?70:64) + } // draw table autoTable(doc, { startY: 80, @@ -61,7 +63,7 @@ export function GeneratePdf(bill: BillModel) { `#${it.id}`, dayjs(bill.paid_at).format('YYYY-MM-DD'), it.bill_type, - `${bill.payment_channel}` + (bill.payment_channel != bill.payment_method ? `(${bill.payment_method})` : ''), + `${bill.payment_channel}` + (bill.payment_method && bill.payment_channel != bill.payment_method ? `(${bill.payment_method})` : ''), `${it.amount}` ]; })), diff --git a/src/types/bill.d.ts b/src/types/bill.d.ts index 1a0d58d..c24537e 100644 --- a/src/types/bill.d.ts +++ b/src/types/bill.d.ts @@ -14,6 +14,7 @@ declare type BillDetail = { id: number; bill_type: string; confirm_status: ConfirmStatus; + confirm_type: string; amount: decimal; } /** @@ -25,6 +26,8 @@ declare type BillQueryParam = { status:string; apply_status:string; id:string|number; + merchant_ref:string; + bill_type:string; student_number:string; application_number:string; payment_channel:string; @@ -93,7 +96,8 @@ declare type AsiaPayModel = { } type ExternalCreateParamsType = { - [key: string]: string | null | BillDetail[]; + details: BillDetail[]; + [key: string]: string | null; } type BillUpdateParams = {