Skip to content

Commit e46a06d

Browse files
committed
Apply tax on discounted price
1 parent 34f0279 commit e46a06d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

app/models/spree/line_item_decorator.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Spree::LineItem.class_eval do
22
def tax_cloud_cache_key
3-
key = "Spree::LineItem #{id}: #{quantity}x<#{variant.cache_key}>@#{price}#{currency}"
3+
key = "Spree::LineItem #{id}: #{quantity}x<#{variant.cache_key}>@#{price}#{currency}promo_total<#{promo_total}>"
44
if order.ship_address
55
key << "shipped_to<#{order.ship_address.try(:cache_key)}>"
66
elsif order.bill_address

app/models/spree/tax_cloud.rb

+11-1
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,23 @@ def self.address_from_spree_address(address)
4242
end
4343

4444
def self.cart_item_from_item(item, index)
45+
46+
puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
47+
puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
48+
puts "promo_tota: #{item.promo_total}"
49+
puts "quantity: #{item.quantity}"
50+
puts "price: #{item.price}"
51+
puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
52+
puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
53+
54+
4555
case item
4656
when Spree::LineItem
4757
::TaxCloud::CartItem.new(
4858
index: index,
4959
item_id: item.try(:variant).try(:sku).present? ? item.try(:variant).try(:sku) : "LineItem #{item.id}",
5060
tic: (item.product.tax_cloud_tic || Spree::Config.taxcloud_default_product_tic),
51-
price: item.price,
61+
price: item.quantity == 0 ? item.price : (item.promo_total / item.quantity) + item.price,
5262
quantity: item.quantity
5363
)
5464
when Spree::Shipment

0 commit comments

Comments
 (0)