Skip to content

Commit

Permalink
Apply tax on discounted price
Browse files Browse the repository at this point in the history
  • Loading branch information
cyu committed Jan 19, 2017
1 parent 34f0279 commit e46a06d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/spree/line_item_decorator.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Spree::LineItem.class_eval do
def tax_cloud_cache_key
key = "Spree::LineItem #{id}: #{quantity}x<#{variant.cache_key}>@#{price}#{currency}"
key = "Spree::LineItem #{id}: #{quantity}x<#{variant.cache_key}>@#{price}#{currency}promo_total<#{promo_total}>"
if order.ship_address
key << "shipped_to<#{order.ship_address.try(:cache_key)}>"
elsif order.bill_address
Expand Down
12 changes: 11 additions & 1 deletion app/models/spree/tax_cloud.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,23 @@ def self.address_from_spree_address(address)
end

def self.cart_item_from_item(item, index)

puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
puts "promo_tota: #{item.promo_total}"
puts "quantity: #{item.quantity}"
puts "price: #{item.price}"
puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
puts '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'


case item
when Spree::LineItem
::TaxCloud::CartItem.new(
index: index,
item_id: item.try(:variant).try(:sku).present? ? item.try(:variant).try(:sku) : "LineItem #{item.id}",
tic: (item.product.tax_cloud_tic || Spree::Config.taxcloud_default_product_tic),
price: item.price,
price: item.quantity == 0 ? item.price : (item.promo_total / item.quantity) + item.price,
quantity: item.quantity
)
when Spree::Shipment
Expand Down

0 comments on commit e46a06d

Please sign in to comment.