feat: add vat exclude feature
This commit is contained in:
parent
0af6dbaae1
commit
eb91715ca7
1 changed files with 20 additions and 2 deletions
|
|
@ -370,7 +370,9 @@ export class QuotationController extends Controller {
|
|||
const p = product.find((p) => p.id === v.productId)!;
|
||||
const price = body.agentPrice ? p.agentPrice : p.price;
|
||||
const pricePerUnit = p.vatIncluded ? precisionRound(price / (1 + VAT_DEFAULT)) : price;
|
||||
const vat = precisionRound((pricePerUnit * v.amount - (v.discount || 0)) * VAT_DEFAULT);
|
||||
const vat = p.calcVat
|
||||
? precisionRound((pricePerUnit * v.amount - (v.discount || 0)) * VAT_DEFAULT)
|
||||
: 0;
|
||||
|
||||
return {
|
||||
order: i + 1,
|
||||
|
|
@ -394,6 +396,12 @@ export class QuotationController extends Controller {
|
|||
a.totalPrice = precisionRound(a.totalPrice + c.pricePerUnit * c.amount);
|
||||
a.totalDiscount = precisionRound(a.totalDiscount + c.discount);
|
||||
a.vat = precisionRound(a.vat + c.vat);
|
||||
a.vatExcluded =
|
||||
c.vat === 0
|
||||
? precisionRound(
|
||||
a.vatExcluded + (c.pricePerUnit * c.amount - (c.discount || 0)) * VAT_DEFAULT,
|
||||
)
|
||||
: 0;
|
||||
a.finalPrice = precisionRound(
|
||||
Math.max(a.totalPrice - a.totalDiscount + a.vat - (body.discount || 0), 0),
|
||||
);
|
||||
|
|
@ -404,6 +412,7 @@ export class QuotationController extends Controller {
|
|||
totalPrice: 0,
|
||||
totalDiscount: 0,
|
||||
vat: 0,
|
||||
vatExcluded: 0,
|
||||
discount: body.discount,
|
||||
finalPrice: 0,
|
||||
},
|
||||
|
|
@ -613,7 +622,9 @@ export class QuotationController extends Controller {
|
|||
const p = product.find((p) => p.id === v.productId)!;
|
||||
const price = record.agentPrice ? p.agentPrice : p.price;
|
||||
const pricePerUnit = p.vatIncluded ? precisionRound(price / 1 + VAT_DEFAULT) : price;
|
||||
const vat = precisionRound((pricePerUnit * v.amount - (v.discount || 0)) * VAT_DEFAULT);
|
||||
const vat = p.calcVat
|
||||
? precisionRound((pricePerUnit * v.amount - (v.discount || 0)) * VAT_DEFAULT)
|
||||
: 0;
|
||||
|
||||
return {
|
||||
order: i + 1,
|
||||
|
|
@ -637,6 +648,12 @@ export class QuotationController extends Controller {
|
|||
a.totalPrice = precisionRound(a.totalPrice + c.pricePerUnit * c.amount);
|
||||
a.totalDiscount = precisionRound(a.totalDiscount + c.discount);
|
||||
a.vat = precisionRound(a.vat + c.vat);
|
||||
a.vatExcluded =
|
||||
c.vat === 0
|
||||
? precisionRound(
|
||||
a.vatExcluded + (c.pricePerUnit * c.amount - (c.discount || 0)) * VAT_DEFAULT,
|
||||
)
|
||||
: 0;
|
||||
a.finalPrice = precisionRound(
|
||||
Math.max(a.totalPrice - a.totalDiscount + a.vat - (body.discount || 0), 0),
|
||||
);
|
||||
|
|
@ -647,6 +664,7 @@ export class QuotationController extends Controller {
|
|||
totalPrice: 0,
|
||||
totalDiscount: 0,
|
||||
vat: 0,
|
||||
vatExcluded: 0,
|
||||
discount: body.discount,
|
||||
finalPrice: 0,
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue