Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discounts on Spree::Shipment cause NoLinesDiscounted Response, Failing Tax Calculation #102

Open
joshhepworth opened this issue Sep 27, 2018 · 0 comments

Comments

@joshhepworth
Copy link

joshhepworth commented Sep 27, 2018

This issue occurred using Solidus 2.4 and a version of this gem with the following changes.

When using a Spree::Promotion that contains the "Make all shipments free" action that automatically applies to orders that meet the Rules, it causes the following error response to be logged and no tax to be applied to the order. This might be limited to orders that contain no other discounts.

[AVATAX] Get Tax Error {"error"=>{"code"=>"NoLinesDiscounted", "message"=>"Transaction has no lines which are discounted.", "target"=>"IncorrectData", "details"=>[{"code"=>"NoLinesDiscounted", "number"=>190, "message"=>"Transaction has no lines which are discounted.", "description"=>"The CreateTransactionModel object with discount amount set must have at least one line which is discounted.", "faultCode"=>"Client", "helpLink"=>"http://developer.avalara.com/avatax/errors/NoLinesDiscounted", "severity"=>"Error"}, {"code"=>"NoLinesDiscounted", "number"=>190, "message"=>"Transaction has no lines which are discounted.", "description"=>"The CreateTransactionModel object with discount amount set must have at least one line which is discounted.", "faultCode"=>"Client", "helpLink"=>"http://developer.avalara.com/avatax/errors/NoLinesDiscounted", "severity"=>"Error"}]}}

Here's the corresponding request hash:

[AVATAX] get_tax request hash {:createTransactionModel=>
  {:code=>"R378534300",
   :date=>"2018-09-27",
   :discount=>"9.99",
   :commit=>true,
   :type=>"SalesInvoice",
   :lines=>
    [{:number=>"1702304-LI",
      :description=>"The Rover Jacket",
      :taxCode=>"PC040100",
      :itemCode=>"148834",
      :quantity=>1,
      :amount=>298.0,
      :discounted=>false,
      :taxIncluded=>false,
      :addresses=>
       {:shipFrom=>
         {:line1=>"123 Main St",
          :line2=>"",
          :city=>"Columbus",
          :region=>nil,
          :country=>"US",
          :postalCode=>"20001"},
        :shipTo=>
         {:line1=>"161 Sussex Street",
          :line2=>nil,
          :city=>"Sydney",
          :region=>nil,
          :country=>"AU",
          :postalCode=>"2000"}},
      :customerUsageType=>nil,
      :businessIdentificationNo=>nil,
      :exemptionCode=>nil},
     {:number=>"1137240-FR",
      :itemCode=>"Australia + UK",
      :quantity=>1,
      :amount=>0.0,
      :description=>"Shipping Charge",
      :taxCode=>"FR020100",
      :discounted=>false,
      :taxIncluded=>false,
      :addresses=>
       {:shipFrom=>
         {:line1=>"123 Main St",
          :line2=>"",
          :city=>"Columbus",
          :region=>nil,
          :country=>"US",
          :postalCode=>"20001"},
        :shipTo=>
         {:line1=>"161 Sussex Street",
          :line2=>nil,
          :city=>"Sydney",
          :region=>nil,
          :country=>"AU",
          :postalCode=>"2000"}},
      :customerUsageType=>nil,
      :businessIdentificationNo=>nil,
      :exemptionCode=>nil}],
   :customerCode=>9999999,
   :companyCode=>"COMPANYINC",
   :customerUsageType=>nil,
   :exemptionNo=>nil,
   :referenceCode=>"R378534300",
   :currencyCode=>"USD",
   :businessIdentificationNo=>nil}}

Note: the above shipFrom address has been modified.

In the request hash there is a discount set at the highest level, however all of the items show that discounted is set to false. This value seems to be hardcoded to false for all shipments sent to AvaTax.

In the above order in Solidus, the Spree::Shipment itself had a before promo total of 9.99 with a 9.99 discount applied by the Free Shipping promotion.

Looking at SolidusAvataxCertified::Line, I'm unsure if #shipment_line should be updated to reflect itself being discounted, or if the the discount key should have its calculation updated in SolidusAvataxCertified::Request::GetTax – or something else entirely.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant