Skip to content

Avalara Tax - exception and broken tax calculation logic when discounts in order#5

Merged
MrBuhl merged 1 commit intomainfrom
ssm/26742-discounts_and_tax_calculation
Dec 17, 2025
Merged

Avalara Tax - exception and broken tax calculation logic when discounts in order#5
MrBuhl merged 1 commit intomainfrom
ssm/26742-discounts_and_tax_calculation

Conversation

@StanislavSmetaninSSM
Copy link
Contributor

@StanislavSmetaninSSM StanislavSmetaninSSM commented Dec 16, 2025

NOTE: we have unmerged changes in the: #2
So we need to merge it first, AND THEN probably update the package version here if needed.

The task: https://dev.azure.com/dynamicwebsoftware/Dynamicweb/_workitems/edit/26742

Fixed an exception that occurred when there was an Order Discount in the Order.

In addition, there is an incorrect behavior in the tax calculation logic, and product discounts/order discounts are not taken into account at all. It looks really strange. So I fixed it this way: we use orderLine.TotalPriceWithProductDiscounts - as a product price for calculation (it already has a discount), and I also removed strange check:

if (string.Equals(line.TaxCode, Provider.TaxCodeShipping, StringComparison.Ordinal))
    line.Discounted = true;

So if the orderDiscount > 0, we mark all order lines as discounted.
I suppose it will fix the error and calculation logic.

BUT, I'll probably need some review, since the previous code was ported from DW9, and I'm changing the logic. I can only assume that Avalara has always handled discounts incorrectly before.

…, there is an incorrect behavior in the tax calculation logic, and product discounts/order discounts are not taken into account at all. It looks really strange. So I fixed it this way: we use orderLine.TotalPriceWithProductDiscounts - as a product price for calculation (it already has a discount), and removed strange check: if (string.Equals(line.TaxCode, Provider.TaxCodeShipping, StringComparison.Ordinal))

So if the orderDiscount > 0, we mark all order lines as discounted.
I suppose it will fix the error and calculation logic.
@MrBuhl MrBuhl merged commit d94e068 into main Dec 17, 2025
3 checks passed
@MrBuhl MrBuhl deleted the ssm/26742-discounts_and_tax_calculation branch December 17, 2025 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants