diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 44b0f87b..5541a802 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -134,8 +134,14 @@ const workerList = ref([]); const selectedProductGroup = ref(''); const selectedInstallmentNo = ref([]); const agentPrice = ref(false); -const summaryPrice = computed(() => - productServiceList.value.reduce( + +function getPrice( + list: typeof productServiceList.value, + filterHook?: (arg: (typeof productServiceList.value)[number]) => boolean, +) { + if (filterHook) list = list.filter(filterHook); + + return list.reduce( (a, c) => { if ( selectedInstallmentNo.value.length > 0 && @@ -172,8 +178,10 @@ const summaryPrice = computed(() => vatExcluded: 0, finalPrice: 0, }, - ), -); + ); +} + +const summaryPrice = computed(() => getPrice(productServiceList.value)); const payBank = ref(''); diff --git a/src/pages/05_quotation/QuotationFormInfo.vue b/src/pages/05_quotation/QuotationFormInfo.vue index a0afd2f1..2082394c 100644 --- a/src/pages/05_quotation/QuotationFormInfo.vue +++ b/src/pages/05_quotation/QuotationFormInfo.vue @@ -51,9 +51,9 @@ const payType = defineModel<'Full' | 'Split' | 'BillFull' | 'BillSplit'>( const paySplitCount = defineModel('paySplitCount', { default: 1, }); -const paySplit = defineModel< - { no: number; date: string | Date | null; amount: number }[] ->('paySplit', { required: true }); +const paySplit = defineModel<{ no: number; amount: number }[]>('paySplit', { + required: true, +}); const summaryPrice = defineModel<{ totalPrice: number; totalDiscount: number; @@ -82,14 +82,6 @@ const payTypeOpion = computed(() => [ value: 'Split', label: t('quotation.type.installmentsCash'), }, - // { - // value: 'BillFull', - // label: t('quotation.type.fullAmountBill'), - // }, - // { - // value: 'BillSplit', - // label: t('quotation.type.installmentsBill'), - // }, ]); const amount4Show = ref([]); @@ -117,7 +109,6 @@ function calculateInstallments(param: { for (let i = param.oldCount; i < param.newCount; i++) { paySplit.value.push({ no: i + 1, - date: null, amount: installmentAmount, }); amount4Show.value.push(installmentAmount.toString()); @@ -157,28 +148,6 @@ function calculateInstallments(param: { } } -function installmentsDate(date: Date | string) { - const firstPayDateObj = new Date(date); - - paySplit.value = paySplit.value.map((pay, index) => { - if (index === 0) { - return pay; - } - - let updatedDate = new Date(firstPayDateObj); - updatedDate.setMonth(updatedDate.getMonth() + index); - - if (updatedDate.getDate() !== firstPayDateObj.getDate()) { - updatedDate.setDate(0); - } - - return { - ...pay, - date: updatedDate.toISOString(), - }; - }); -} - watch( () => payType.value, (v) => { @@ -202,23 +171,9 @@ watch( ) return; calculateInstallments({ newCount: newCount || 0, oldCount: oldCount || 0 }); - if (paySplit.value.length > 0 && !paySplit.value[0].date) - paySplit.value[0].date = new Date(); - if (newCount !== oldCount) { - paySplit.value[0].date && installmentsDate(paySplit.value[0].date); - } }, { deep: true }, ); - -watch( - () => paySplit.value[0]?.date, - (firstPayDate, beforeDate) => { - if (firstPayDate && firstPayDate !== beforeDate) { - installmentsDate(firstPayDate); - } - }, -); - diff --git a/src/stores/quotations/types.ts b/src/stores/quotations/types.ts index bb1b7c87..3e9716ac 100644 --- a/src/stores/quotations/types.ts +++ b/src/stores/quotations/types.ts @@ -201,7 +201,8 @@ export type Quotation = { payBillDate: string | Date; paySplitCount: number; paySplit: { - date: string | Date; + no: number; + invoice: boolean; amount: number; }[]; payCondition: 'Full' | 'Split' | 'BillFull' | 'BillSplit'; @@ -277,7 +278,7 @@ export type QuotationFull = { urgent: boolean; payBillDate: string | Date | null; paySplitCount: number | null; - paySplit: { no: number; date: string | Date; amount: number }[]; + paySplit: { no: number; amount: number }[]; payCondition: 'Full' | 'Split' | 'BillFull' | 'BillSplit'; date: string | Date; dueDate: string | Date;