Skip to content

line item included tax being sent as $0 #13

@dholdren

Description

@dholdren

Solidus Version: 2.3

I'm getting the following error stating that the total_tax_amount has a bad value when creating a session:

(byebug) Klarna.client(:credit).create_session(order)
#<Klarna::Response:0x00007f91ce808a60 @http_response=#<Net::HTTPBadRequest 400 Bad Request readbody=true>, @code=400, @body={"error_code"=>"BAD_VALUE", "error_messages"=>["Bad value: order_lines[0].total_tax_amount"], "correlation_id"=>"4c73c59f-f741-44db-a69b-22298902fc41"}, @headers={"content-type"=>["application/json"], "date"=>["Fri, 01 Jun 2018 17:32:51 GMT"], "klarna-correlation-id"=>["4c73c59f-f741-44db-a69b-22298902fc41"], "render-time"=>["1"], "server"=>["openresty"], "strict-transport-security"=>["max-age=31536000; includeSubDomains"], "content-length"=>["164"], "connection"=>["Close"]}>

The serialized order's order_lines have $0 for the total_tax_amount

(byebug) order
{:purchase_country=>"GB", :purchase_currency=>"GBP", :locale=>"en-GB", :order_amount=>35000, :order_lines=>[{:reference=>"MATTRESSSINGLEUK", :name=>"The Mattress", :quantity=>1, :unit_price=>35000, :tax_rate=>2000, :total_amount=>35000, :total_tax_amount=>0, :image_url=>nil, :product_url=>nil, :discount_amount=>0}, {:type=>"shipping_fee", :reference=>"H63134638705", :name=>"Parcel", :quantity=>1, :unit_price=>0, :total_amount=>0, :total_tax_amount=>0, :tax_rate=>0}], :merchant_reference1=>"R613395713", :options=>{}, :merchant_urls=>{:confirmation=>"http://casper.com/uk/en/orders/R613395713?completed=true&locale=", :notification=>"http://casper.com/uk/uk/en/klarna/callbacks/notification"}}

But the order's line items have a value for included_tax_total:

(byebug) Spree::Order.last.line_items
#<ActiveRecord::Associations::CollectionProxy [#<Spree::LineItem id: 7124026, variant_id: 173, order_id: 4280614, quantity: 1, price: #<BigDecimal:7f91eb69c178,'0.35E3',9(18)>, created_at: "2018-05-31 20:32:15", updated_at: "2018-05-31 20:32:16", cost_price: nil, tax_category_id: 2, adjustment_total: #<BigDecimal:7f91eb6900f8,'0.0',9(18)>, additional_tax_total: #<BigDecimal:7f91eb6936b8,'0.0',9(18)>, promo_total: #<BigDecimal:7f91eb692c18,'0.0',9(18)>, included_tax_total: #<BigDecimal:7f91eb6929c0,'0.5833E2',18(27)>, promotional_credit_total: #<BigDecimal:7f91eb692678,'0.0',9(18)>, deleted_at: nil>]>

Pinning the gem to sha ef6fdc7 resolves the issue and looking at the comparison
ef6fdc78f00c...43a2afb you'll see there's been a change to the way total_tax_amount is calculated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions