Giter Club home page Giter Club logo

Comments (3)

ScottRudiger avatar ScottRudiger commented on September 24, 2024 1

@calvinanderson Thanks for the issue!

Amount is actually a required field per the API reference:
Screen Shot 2020-01-17 at 3 21 25 PM

If it helps work out the logic, there are (at least) two different cases with the client as-is:

  1. Amount & LineItems add up correctly

201 Order created

taxjar.CreateOrderParams{
	// ...
	Amount:          36.21,
	Shipping: 5,
	SalesTax: 0,
	LineItems: []taxjar.OrderLineItem{
		{
			ID:                "1",
			Quantity:          1,
			ProductIdentifier: "12-34243-9",
			Description:       "Fuzzy Sweater",
			ProductTaxCode:    "20010",
			UnitPrice:         36.72,
			Discount:          5.51,
			SalesTax:          0,
		},
	},
}
  1. Amount is empty or zero and LineItems includes items

400 Bad Request - Order amount must be equal to the sum of line items and shipping

taxjar.CreateOrderParams{
	// ...
	// Amount:          36.21,
	Shipping: 5,
	SalesTax: 0,
	LineItems: []taxjar.OrderLineItem{
		{
			ID:                "1",
			Quantity:          1,
			ProductIdentifier: "12-34243-9",
			Description:       "Fuzzy Sweater",
			ProductTaxCode:    "20010",
			UnitPrice:         36.72,
			Discount:          5.51,
			SalesTax:          0,
		},
	},
}

If we pass nil for an empty Amount instead of 0, a different error would be returned since Amount is required:

406 Not Acceptable - amount is missing, amount is empty

type CreateOrderParams struct {
	// ...
	Amount          float64         `json:"amount,omitempty"`
	Shipping        float64         `json:"shipping"`
	SalesTax        float64         `json:"sales_tax"`
	...
}

Since Amount is required, our inclination is to pass 0 when omitted.

from taxjar-go.

ScottRudiger avatar ScottRudiger commented on September 24, 2024 1

No worries! We know this is confusing since Amount excludes shipping when calculating tax, but includes shipping when creating an order as well. We hope to offer more consistency in a future version of the API.

from taxjar-go.

calvinanderson avatar calvinanderson commented on September 24, 2024

Thanks, sorry, I had thought that is was an optional param like in the calculate sales tax endpoint.

from taxjar-go.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.