Vendure: Include price and priceWithTax convention for discounts

Created on 5 Mar 2021  路  4Comments  路  Source: vendure-ecommerce/vendure

Is your feature request related to a problem? Please describe.
Since every other item in an order has the option to see a price with and without tax, it would be great to have that convention extended to discounts. Currently discounts only provide access to amount, which is the equivalent to priceWithTax. In our shopping carts (and any shopping cart I've seen in the US), we display all items without tax. The tax is displayed as a separate line item, which encompasses all tax for the order (see additional context section). For discounts we are required to calculate the value without tax dynamically, which makes quite a few assumptions regarding the taxLines array.

Describe the solution you'd like
The primary solution I would like to see is the use of price and priceWithTax for discounts.

Describe alternatives you've considered
Our current alternative is to reverse calculate the price without tax using the taxLines.

Additional context
image

@vendurcore

Most helpful comment

Thank you both for the additional information. I posed the question of whether to fix now or later in the Slack group and the response is a unanimous yes:
image

So I'll work on this for the next beta release.

All 4 comments

This is a good point and as well as being needed for you use-case would also make the API more consistent.

The only problem is that it is a breaking change, since amount is currently _with tax_ and then would become _without tax_. I am trying to avoid breaking changes now that we are in the 1.0.0-beta phase. But on the other hand a relatively minor break, which would make such a difference to US-based projects is probably worthwhile.

Hi @michaelbromley, just adding onto this issue--here's a screenshot of another use case we've run into. We're trying to display to the user a list of the discounts that they've applied to their cart and the only way we can do that right now is to back calculate from the amount with tax, which ends up giving us rounding errors. Also, since the discount amount with tax changes every time the user modifies the cart, i.e adds or removes an item, the displayed discount amount (from the back calculation) also changes. We were hoping to avoid this by maybe adding another property to the Cart that would give us all the discounts as is instead of the discount with tax.
image

Thank you for adding that screenshot as a strong example of the issue @sidings. @michaelbromley For context, @sidings and I are on the same team and her follow up is directly related to my original request. I appreciate that you are considering adding this into the beta phase, even though you want to avoid breaking changes. Based on some recent stakeholder meetings, it seems increasingly important to have access to a reliable pre tax discount value.

Thank you both for the additional information. I posed the question of whether to fix now or later in the Slack group and the response is a unanimous yes:
image

So I'll work on this for the next beta release.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michaelbromley picture michaelbromley  路  3Comments

Zyles picture Zyles  路  8Comments

michaelbromley picture michaelbromley  路  4Comments

azfx picture azfx  路  3Comments

villesau picture villesau  路  3Comments