lib/offer_totals.rb
# Given an Order and amount of offer, it calculates tax, shipping based on offer amount
Given an Order and amount of offer, it calculates tax, shipping based on offer amount
Given an Order and amount of offer it calculates tax shipping based on offer amount
def tax_data
    return OpenStruct.new(tax_total_cents: nil, should_remit_sales_tax: nil) unless @order.shipping_info?
    @tax_data ||= begin
      service = Tax::CalculatorService.new(
        @offer_amount,
        @offer_amount / @order.line_items.first.quantity,
        @order.line_items.first.quantity,
        @order.fulfillment_type,
        @order.shipping_address,
        shipping_total_cents,
        artwork_location,
        order_helper.seller_locations
      )
      sales_tax = order_helper.partner[:artsy_collects_sales_tax] ? service.sales_tax : 0
      OpenStruct.new(tax_total_cents: sales_tax, should_remit_sales_tax: service.artsy_should_remit_taxes?)
    end
  rescue Errors::ValidationError => e
    raise e unless e.code == :no_taxable_addresses
    OpenStruct.new(tax_total_cents: 0, should_remit_sales_tax: false)
  end
def tax_data return OpenStruct . new ( tax_total_cents : nil , should_remit_sales_tax : nil ) unless @order . shipping_info? @tax_data ||= begin service = Tax :: CalculatorService . new ( @offer_amount , @offer_amount / @order . line_items . first . quantity , @order . line_items . first . quantity , @order . fulfillment_type , @order . shipping_address , shipping_total_cents , artwork_location , order_helper . seller_locations ) sales_tax = order_helper . partner [ :artsy_collects_sales_tax ] ? service . sales_tax : 0 OpenStruct . new ( tax_total_cents : sales_tax , should_remit_sales_tax : service . artsy_should_remit_taxes? ) end rescue Errors :: ValidationError => e raise e unless e . code == :no_taxable_addresses OpenStruct . new ( tax_total_cents : 0 , should_remit_sales_tax : false ) end
Given an Order and amount of offer, it calculates tax, shipping based on offer amount
Given an Order and amount of offer it calculates tax shipping based on offer amount
# If there are no taxable addresses then we set the sales tax to 0.