fix: calc price

This commit is contained in:
Thanaphon Saengchan 2025-09-15 17:02:25 +07:00 • committed by Methapon2001
parent 67cde37e34
commit c430b6082e
5 changed files with 119 additions and 50 deletions

View file

@ -245,22 +245,9 @@ function calcPricePerUnit(product: RequestWork['productService']['product']) {
: product.price;
}
function calcPrice(
product: RequestWork['productService']['product'],
amount: number,
vat: number = 0,
) {
const pricePerUnit = agentPrice.value ? product.agentPrice : product.price;
const priceNoVat = product.vatIncluded
? pricePerUnit / (1 + (config.value?.vat || 0.07))
: pricePerUnit;
const priceDiscountNoVat = priceNoVat * amount - 0;
const rawVatTotal =
vat === 0 ? 0 : priceDiscountNoVat * (config.value?.vat || 0.07);
return precisionRound(priceNoVat * amount + rawVatTotal);
function calcPrice(c: RequestWork[]): number {
const price = creditNoteStore.getfinalPriceCredit(c);
return price.finalPrice;
}
watch(elements, () => {});
@ -327,13 +314,11 @@ function closeAble() {
<th>{{ $t('preview.pricePerUnit') }}</th>
<th>{{ $t('preview.value') }}</th>
</tr>
{{ console.log(chunks) }}
{{ console.log(chunk) }}
<tr v-for="(v, i) in chunk" :key="i">
<td class="text-center">{{ i + 1 }}</td>
<td>{{ v.product.product.code }}</td>
<td>{{ v.product.product.name }}</td>
<td style="text-align: center">
<td style="text-align: right">
{{
formatNumberDecimal(
calcPricePerUnit(v.product.product) +
@ -345,13 +330,8 @@ function closeAble() {
)
}}
</td>
<td style="text-align: center">
{{
formatNumberDecimal(
calcPrice(v.product.product, v.list.length, v.product.vat),
2,
)
}}
<td style="text-align: right">
{{ formatNumberDecimal(calcPrice(v.list), 2) }}
</td>
</tr>
</tbody>
@ -409,8 +389,8 @@ function closeAble() {
{{
formatNumberDecimal(
summaryPrice.totalPrice -
summaryPrice.totalDiscount +
summaryPrice.vat,
summaryPrice.totalDiscount -
summaryPrice.vatExcluded,
2,
)
}}