feat: add final discount as payload

This commit is contained in:
Methapon Metanipat 2024-10-10 15:05:15 +07:00
parent 99c43bdd66
commit ee45da0e8c
3 changed files with 7 additions and 4 deletions

View file

@ -137,11 +137,9 @@ const workerList = ref<Employee[]>([]);
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"
/>
</div>

View file

@ -24,6 +24,7 @@ const DEFAULT_DATA: QuotationPayload = {
paySplitCount: 0,
payCondition: 'Full',
dueDate: new Date(),
discount: 0,
documentReceivePoint: '',
contactTel: '',
contactName: '',

View file

@ -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