From ee45da0e8ceb418b6229be90a00c273c13baa25e Mon Sep 17 00:00:00 2001 From: Methapon Metanipat Date: Thu, 10 Oct 2024 15:05:15 +0700 Subject: [PATCH] feat: add final discount as payload --- src/pages/05_quotation/QuotationForm.vue | 9 +++++---- src/pages/05_quotation/form.ts | 1 + src/stores/quotations/types.ts | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index 6064a357..bd895688 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -137,11 +137,9 @@ const workerList = ref([]); const selectedProductGroup = ref(''); const agentPrice = ref(false); -const finalDiscount = ref(0); const summaryPrice = computed(() => productServiceList.value.reduce( (a, c) => { - console.log(finalDiscount.value); const price = precisionRound(c.pricePerUnit * c.amount); const vat = precisionRound( (c.pricePerUnit * c.amount - c.discount) * (config.value?.vat || 0.07), @@ -151,7 +149,10 @@ const summaryPrice = computed(() => a.totalDiscount = precisionRound(a.totalDiscount + Number(c.discount)); a.vat = precisionRound(a.vat + vat); a.finalPrice = precisionRound( - a.totalPrice - a.totalDiscount + a.vat - Number(finalDiscount.value), + a.totalPrice - + a.totalDiscount + + a.vat - + Number(quotationFormData.value.discount || 0), ); return a; @@ -833,7 +834,7 @@ watch( v-model:pay-split-count="quotationFormData.paySplitCount" v-model:pay-split="quotationFormData.paySplit" :readonly - v-model:final-discount="finalDiscount" + v-model:final-discount="quotationFormData.discount" v-model:summary-price="summaryPrice" /> diff --git a/src/pages/05_quotation/form.ts b/src/pages/05_quotation/form.ts index 89432e1d..33ef6b06 100644 --- a/src/pages/05_quotation/form.ts +++ b/src/pages/05_quotation/form.ts @@ -24,6 +24,7 @@ const DEFAULT_DATA: QuotationPayload = { paySplitCount: 0, payCondition: 'Full', dueDate: new Date(), + discount: 0, documentReceivePoint: '', contactTel: '', contactName: '', diff --git a/src/stores/quotations/types.ts b/src/stores/quotations/types.ts index b182dc18..a3412310 100644 --- a/src/stores/quotations/types.ts +++ b/src/stores/quotations/types.ts @@ -270,6 +270,7 @@ export type QuotationPayload = { urgent: boolean; worker: EmployeeWorker[]; _count: { worker: number }; + discount?: number; payBillDate?: Date | null; paySplit: { no: number; date: string | Date; amount: number }[]; paySplitCount?: number | null; // int