Hey everyone! I’m migrating from Spree 2.4 to Soli...
# support
n
Hey everyone! I’m migrating from Spree 2.4 to Solidus 1.0 and trying to fix the tests. I have one checking that a percentage discount gets applied before taxes that fails and I can’t figure out why 😞 order:
Copy code
1 product for 100.00
tax: 9.6%
service tax: 20
test code:
Copy code
order = create(:spree_order, :corporate)
      order.contents.add(create(:spree_product, price: '100.00'.to_d, tax_category: tax_category).master)
      order.create_fees!
      order.create_tax_charge!

      # Adhoc discount created via Admin Portal
      order.adjustments.create!(
        amount: -25.to_d,
        label: "25% off due to poor service",
        order: order,
        source: nil
      )
      order.update!
expected result:
Copy code
order.total == 104.12 # item_total(100) + discount(-25) + item_tax(75 * .096) + service_fee(20) + service_fee_tax(20 * .096)
order.adjustment_total == 4.12 # discount(-25) + item_tax(7.2) + service_fee(20) + service_fee_tax(1.92)
order.additional_tax_total == 9.12 # item_tax(7.2) + service_fee_tax(1.92)
order.adjustments.tax.first.amount == -0.48 # service_fee_tax(1.92) + discount_tax_refund(-25 * .096)
actual result:
Copy code
order.total == 106.52 # item_total(100) + discount(-25) + item_tax(100 * .096) + service_fee(20) + service_fee_tax(20 * .096)
order.adjustment_total == 6.52 # discount(-25) + item_tax(9.6) + service_fee(20) + service_fee_tax(1.92)
order.additional_tax_total == 11.52 # item_tax(9.6) + service_fee_tax(1.92)
order.adjustments.tax.first.amount == 1.92 # service_fee_tax(1.92)
Any idea what could be generating this different behaviour?
e
Looking at the changes between Spree v2.4.9 and Solidus v1.0.0 a few things have changed inside item_adjustments.rb https://gist.github.com/elia/594afefedaa8d304a65c7bd24180c5c4
👀 1