diff --git a/src/components/05_quotation/ProductItem.vue b/src/components/05_quotation/ProductItem.vue index 651a949d..94d38c56 100644 --- a/src/components/05_quotation/ProductItem.vue +++ b/src/components/05_quotation/ProductItem.vue @@ -59,7 +59,9 @@ const summaryPrice = defineModel<{ }, }); -const totalDiscount4show = ref(summaryPrice.value.totalDiscount.toString()); +const currentBtnOpen = ref([]); +const finalDiscount = ref(0); +const finalDiscount4Show = ref(finalDiscount.value.toString()); function calcPrice(c: (typeof rows.value)[number]) { return precisionRound( @@ -80,7 +82,7 @@ const summary = computed(() => a.totalPrice = precisionRound(a.totalPrice + price); a.totalDiscount = precisionRound(a.totalDiscount + Number(c.discount)); a.vat = precisionRound(a.vat + vat); - a.finalPrice = precisionRound(a.totalPrice - a.totalDiscount + a.vat); + a.finalPrice = precisionRound(a.finalPrice + price + vat); return a; }, @@ -88,7 +90,7 @@ const summary = computed(() => totalPrice: 0, totalDiscount: 0, vat: 0, - finalPrice: 0, + finalPrice: -(+finalDiscount.value || 0), }, ), ); @@ -158,9 +160,23 @@ const columns = [ const EngBahtText = (number: number) => { const [baht, satang] = number.toString().split('.'); - return `${toWords(baht)} Baht${satang && ` and ${toWords(satang)} Satang`}`; + const bahtText = + toWords(baht).charAt(0).toUpperCase() + toWords(baht).slice(1); + const satangText = + toWords(satang).charAt(0).toUpperCase() + toWords(satang).slice(1); + return `${bahtText} Baht${satang ? ` and ${satangText} Satang` : ''}`; }; +function openEmployeeTable(index: number) { + currentBtnOpen.value.map((_, i) => { + if (i !== index) { + currentBtnOpen.value[i] = false; + } + }); + + currentBtnOpen.value[index] = !currentBtnOpen.value[index]; +} + watch( () => summary.value, () => { @@ -280,7 +296,22 @@ watch( -