vinsol-spree-contrib / spree_taxjar

Spree Taxjar is a US sales tax extension for Spree using the Taxjar service
BSD 3-Clause "New" or "Revised" License
6 stars 22 forks source link

Invalid calculation of discount_weightage with ineligible adjustments #45

Open joseconsador opened 5 years ago

joseconsador commented 5 years ago

We're getting an error response (Taxjar::Error::BadRequest: Order amount must be equal to the sum of line items and shipping) when processing an order with ineligible promotion adjustments. This is because the line item prices will not end up matching the order total once discounts are applied. We may be able to resolve this by scoping to eligible.

weightage = @order.adjustments.eligible.promotion.sum(:amount) / (@order.item_total)

I can submit a pull request, but I first wanted to check if anyone else has encountered this issue.

pankajkumar1104 commented 4 years ago

+1 @joseconsador today i fixed the same issue in my project too