feat: add separate price vat calc

This commit is contained in:
Methapon2001 2025-01-28 09:44:18 +07:00
parent ef81a93690
commit 310464f834
7 changed files with 344 additions and 280 deletions

View file

@ -1014,6 +1014,10 @@ const currentNoAction = ref(false);
const prevProduct = ref<ProductCreate>({
expenseType: '',
vatIncluded: true,
agentPriceVatIncluded: true,
agentPriceCalcVat: true,
serviceChargeVatIncluded: true,
serviceChargeCalcVat: true,
productGroupId: '',
remark: '',
serviceCharge: 0,
@ -1050,6 +1054,10 @@ async function assignFormDataProduct(data: Product) {
status: data.status,
expenseType: data.expenseType,
vatIncluded: data.vatIncluded,
serviceChargeCalcVat: data.serviceChargeCalcVat,
serviceChargeVatIncluded: data.serviceChargeVatIncluded,
agentPriceCalcVat: data.agentPriceCalcVat,
agentPriceVatIncluded: data.agentPriceVatIncluded,
selectedImage: data.selectedImage,
document: data.document,
shared: data.shared,
@ -1086,6 +1094,10 @@ function clearFormProduct() {
expenseType: '',
calcVat: true,
vatIncluded: true,
agentPriceCalcVat: true,
agentPriceVatIncluded: true,
serviceChargeCalcVat: true,
serviceChargeVatIncluded: true,
shared: false,
};
imageProduct.value = undefined;
@ -3900,7 +3912,12 @@ watch(
v-model:service-charge="formProduct.serviceCharge"
v-model:vat-included="formProduct.vatIncluded"
v-model:calc-vat="formProduct.calcVat"
dense
v-model:agent-price-vat-included="formProduct.agentPriceVatIncluded"
v-model:agent-price-calc-vat="formProduct.agentPriceCalcVat"
v-model:service-charge-vat-included="
formProduct.serviceChargeVatIncluded
"
v-model:service-charge-calc-vat="formProduct.serviceChargeCalcVat"
/>
<FormDocument
v-if="productTab === 3"
@ -4109,7 +4126,12 @@ watch(
v-model:service-charge="formProduct.serviceCharge"
v-model:vat-included="formProduct.vatIncluded"
v-model:calc-vat="formProduct.calcVat"
dense
v-model:agent-price-vat-included="formProduct.agentPriceVatIncluded"
v-model:agent-price-calc-vat="formProduct.agentPriceCalcVat"
v-model:service-charge-vat-included="
formProduct.serviceChargeVatIncluded
"
v-model:service-charge-calc-vat="formProduct.serviceChargeCalcVat"
:priceDisplay="priceDisplay"
/>
<FormDocument

View file

@ -251,10 +251,13 @@ function getPrice(
const vat =
(finalPriceNoVat * c.amount - c.discount) * (config.value?.vat || 0.07);
const calcVat =
c.product[agentPrice.value ? 'agentPriceCalcVat' : 'calcVat'];
a.totalPrice = precisionRound(a.totalPrice + price);
a.totalDiscount = precisionRound(a.totalDiscount + Number(c.discount));
a.vat = c.product.calcVat ? precisionRound(a.vat + vat) : a.vat;
a.vatExcluded = c.product.calcVat
a.vat = calcVat ? precisionRound(a.vat + vat) : a.vat;
a.vatExcluded = calcVat
? a.vatExcluded
: precisionRound(a.vatExcluded + price);
a.finalPrice = precisionRound(

View file

@ -260,7 +260,11 @@ function mapNode() {
const price = prop.agentPrice
? p.product.agentPrice
: p.product.price;
const pricePerUnit = p.product.vatIncluded
const pricePerUnit = (
prop.agentPrice
? p.product.agentPriceVatIncluded
: p.product.vatIncluded
)
? precisionRound(price / (1 + (config.value?.vat || 0.07)))
: price;
productCount.value++;
@ -334,7 +338,9 @@ function mapNode() {
};
} else {
const price = prop.agentPrice ? v.raw.agentPrice : v.raw.price;
const pricePerUnit = v.raw.vatIncluded
const pricePerUnit = (
prop.agentPrice ? v.raw.agentPriceVatIncluded : v.raw.vatIncluded
)
? precisionRound(price / (1 + (config.value?.vat || 0.07)))
: price;
productCount.value++;