v3.0.0-beta.4
Pre-releaseMinor Changes
-
#388
f053fb9Thanks @BramKaashoek! - Add support forExternalandExternalAmounttax modes on carts.New behavior
Externaltax mode —LineItem,CustomLineItem, and shipping methods can now carry anexternalTaxRate:createCarthonorsLineItemDraft.externalTaxRate,CustomLineItemDraft.externalTaxRate, andCartDraft.externalTaxRateForShippingMethod.addLineItem,addCustomLineItem, andsetShippingMethod/setCustomShippingMethodacceptexternalTaxRate.- New update actions:
setLineItemTaxRate,setCustomLineItemTaxRate,setShippingMethodTaxRate.
ExternalAmounttax mode — explicit gross amounts can be supplied per item and at the cart level:- New update actions:
setLineItemTaxAmount,setCustomLineItemTaxAmount,setShippingMethodTaxAmount,setCartTotalTax. - In this mode the cart's
taxedPriceis whateversetCartTotalTaxlast set; it is no longer aggregated from line items.taxedShippingPricecontinues to mirrorshippingInfo.taxedPrice.
- New update actions:
- All tax calculations now respect
cart.taxRoundingMode(HalfEven/HalfUp/HalfDown) instead of always usingMath.round.
Cart total recomputation after update actions
CartUpdateHandler.applynow recomputescart.taxedPriceandcart.taxedShippingPriceafter every update batch (except inExternalAmountmode, where the cart total is authoritative viasetCartTotalTax).This fixes a pre-existing latent bug: previously these fields were only computed once during
create()and were never refreshed after update actions, so e.g. runningsetShippingMethodafter cart creation would leave the cart-level aggregate stale. It didn't show up before becauseLineItem.taxedPricewas never populated in any mode, so the aggregate had no contributors that could drift. With the new tax-mode work, line items and custom line items now actually carrytaxedPrice, which made the gap observable and required fixing.