fix: price calc

This commit is contained in:
Methapon Metanipat 2024-10-21 15:18:52 +07:00
parent 5774dfcf5c
commit 07656eccde

View file

@ -198,7 +198,10 @@ onMounted(async () => {
? a.vatExcluded
: precisionRound(a.vat + vat);
a.finalPrice = precisionRound(
a.totalPrice - a.totalDiscount + a.vat - Number(obj.discount || 0),
a.totalPrice -
a.totalDiscount +
a.vat -
Number(data.value?.discount || 0),
);
return a;
@ -253,7 +256,7 @@ function print() {
</span>
<table ref="elements" class="q-mb-sm" cellpadding="0" style="width: 100%">
<tbody>
<tbody class="color-tr">
<tr>
<th>{{ $t('peview.rank') }}</th>
<th>{{ $t('peview.productCode') }}</th>
@ -264,7 +267,7 @@ function print() {
<th>{{ $t('peview.vat') }}</th>
<th>{{ $t('peview.value') }}</th>
</tr>
<tr class="color-tr" v-for="(v, i) in chunk">
<tr v-for="(v, i) in chunk">
<td class="text-center">{{ i + 1 }}</td>
<td>{{ v.code }}</td>
<td>{{ v.detail }}</td>
@ -290,7 +293,7 @@ function print() {
class="q-mb-md"
cellpadding="0"
>
<tbody>
<tbody class="color-tr">
<tr>
<td>{{ $t('general.total') }}</td>
<td class="text-right">
@ -299,7 +302,7 @@ function print() {
</td>
</tr>
<tr class="bg-color-orange">
<tr>
<td>{{ $t('general.discount') }}</td>
<td class="text-right">
{{ formatNumberDecimal(summaryPrice.totalDiscount, 2) || 0 }} ฿
@ -318,14 +321,19 @@ function print() {
</td>
</tr>
<tr class="bg-color-orange">
<tr>
<td>{{ $t('general.totalVatExcluded') }}</td>
<td class="text-right">
{{ formatNumberDecimal(summaryPrice.vatExcluded, 2) || 0 }}
฿
</td>
</tr>
<tr>
<td>{{ $t('general.vat', { msg: '7%' }) }}</td>
<td class="text-right">
{{ formatNumberDecimal(summaryPrice.vat, 2) }} ฿
</td>
</tr>
<tr>
<td>{{ $t('general.totalVatIncluded') }}</td>
<td class="text-right">
@ -341,12 +349,6 @@ function print() {
</td>
</tr>
<tr class="bg-color-orange">
<td>{{ $t('general.vat', { msg: '7%' }) }}</td>
<td class="text-right">
{{ formatNumberDecimal(summaryPrice.vat, 2) }} ฿
</td>
</tr>
<tr>
<td>{{ $t('general.discountAfterVat') }}</td>
<td class="text-right">
@ -498,7 +500,7 @@ td {
background-color: hsla(var(--orange-5-hsl) / 0.1);
}
.color-tr:nth-child(odd) {
.color-tr > tr:nth-child(odd) {
background-color: hsla(var(--orange-5-hsl) / 0.1);
}