Fix issue on fixed total amount discount when using includes tax (#3472)
The calculation of the fixed discount amount breaks when having includes_tax setting active, due to the line item totals are incorrect and returning everything as 0, thus the totalItemPercentage will be Infinitiy due to the division by a subtotal of 0
This commit is contained in:
@@ -634,12 +634,9 @@ class DiscountService extends TransactionBaseService {
|
|||||||
})
|
})
|
||||||
|
|
||||||
let fullItemPrice = lineItem.unit_price * lineItem.quantity
|
let fullItemPrice = lineItem.unit_price * lineItem.quantity
|
||||||
if (
|
const includesTax = this.featureFlagRouter_.isFeatureEnabled(TaxInclusivePricingFeatureFlag.key) && lineItem.includes_tax
|
||||||
this.featureFlagRouter_.isFeatureEnabled(
|
|
||||||
TaxInclusivePricingFeatureFlag.key
|
if (includesTax) {
|
||||||
) &&
|
|
||||||
lineItem.includes_tax
|
|
||||||
) {
|
|
||||||
const lineItemTotals = await this.newTotalsService_
|
const lineItemTotals = await this.newTotalsService_
|
||||||
.withTransaction(transactionManager)
|
.withTransaction(transactionManager)
|
||||||
.getLineItemTotals([lineItem], {
|
.getLineItemTotals([lineItem], {
|
||||||
@@ -664,6 +661,7 @@ class DiscountService extends TransactionBaseService {
|
|||||||
const totals = await this.newTotalsService_.getLineItemTotals(
|
const totals = await this.newTotalsService_.getLineItemTotals(
|
||||||
discountedItems,
|
discountedItems,
|
||||||
{
|
{
|
||||||
|
includeTax: includesTax,
|
||||||
calculationContext,
|
calculationContext,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user