diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 5541a802..41b3b807 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -137,7 +137,10 @@ const agentPrice = ref(false); function getPrice( list: typeof productServiceList.value, - filterHook?: (arg: (typeof productServiceList.value)[number]) => boolean, + filterHook?: ( + item: (typeof productServiceList.value)[number], + index?: number, + ) => boolean, ) { if (filterHook) list = list.filter(filterHook); @@ -492,6 +495,23 @@ function convertToTable(nodes: Node[]) { }); productServiceList.value = list; + + quotationFormData.value.paySplitCount = Math.max( + ...list.map((v) => v.installmentNo || 0), + ); + quotationFormData.value.paySplit = Array.apply( + null, + new Array(quotationFormData.value.paySplitCount), + ).map((_, i) => ({ + no: i + 1, + amount: getPrice(list, (v) => { + return ( + v.installmentNo === i + 1 || + (i + 1 === quotationFormData.value.paySplitCount && !v.installmentNo) + ); + }).finalPrice, + })); + pageState.productServiceModal = false; } diff --git a/src/pages/05_quotation/QuotationFormInfo.vue b/src/pages/05_quotation/QuotationFormInfo.vue index 96bc032e..53891773 100644 --- a/src/pages/05_quotation/QuotationFormInfo.vue +++ b/src/pages/05_quotation/QuotationFormInfo.vue @@ -95,6 +95,10 @@ function calculateInstallments(param: { newCount: number; oldCount: number; }) { + if (payType.value !== 'SplitCustom' && payType.value !== 'BillSplitCustom') { + return; + } + if (param.newCount !== null && param.oldCount !== null) { const totalAmount = summaryPrice.value.finalPrice; diff --git a/src/stores/quotations/types.ts b/src/stores/quotations/types.ts index 4f1edd61..aa4bc4d1 100644 --- a/src/stores/quotations/types.ts +++ b/src/stores/quotations/types.ts @@ -346,7 +346,7 @@ export type QuotationPayload = { _count: { worker: number }; discount?: number; payBillDate?: Date | null; - paySplit: { no: number; date: string | Date; amount: number }[]; + paySplit: { no: number; amount: number }[]; paySplitCount?: number | null; // int payCondition: | 'Full'