taxjar

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2017 License: MIT Imports: 6 Imported by: 0

README

TaxJar Sales Tax API for Go

Golang client for Sales Tax API v2. For the REST documentation, please visit http://developers.taxjar.com/api.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RateCity

func RateCity(city string) func(*rateParams) error

func RateCountry

func RateCountry(country string) func(*rateParams) error

Types

type Address

type Address struct {
	Street  string `json:"street,omitempty"`
	City    string `json:"city,omitempty"`
	State   string `json:"state,omitempty"`
	Zip     string `json:"zip,omitempty"`
	Country string `json:"country,omitempty"`
}

type Breakdown

type Breakdown struct {
	Shipping  Shipping      `json:"shipping"`
	LineItems []TaxLineItem `json:"line_items"`

	TaxCollectable float64 `json:"tax_collectable"`
	TaxableAmount  float64 `json:"taxable_amount"`

	// For US transactions
	StateTaxableAmount    float64 `json:"state_taxable_amount"`
	StateTaxRate          float64 `json:"state_tax_rate"`
	StateTaxCollectable   float64 `json:"state_tax_collectable"`
	CountyTaxableAmount   float64 `json:"county_taxable_amount"`
	CountyTaxRate         float64 `json:"county_tax_rate"`
	CountyTaxCollectable  float64 `json:"county_tax_collectable"`
	CityTaxableAmount     float64 `json:"city_taxable_amount"`
	CityTaxRate           float64 `json:"city_tax_rate"`
	CityTaxCollectable    float64 `json:"city_tax_collectable"`
	SpecialTaxableAmount  float64 `json:"special_district_taxable_amount"`
	SpecialTaxRate        float64 `json:"special_tax_rate"`
	SpecialTaxCollectable float64 `json:"special_district_tax_collectable"`

	// For CA transactions
	GstTaxableAmount  float64 `json:"gst_taxable_amount"`
	GstTaxCollectable float64 `json:"gst"`
	GstTaxRate        float64 `json:"gst_tax_rate"`
	PstTaxableAmount  float64 `json:"pst_taxable_amount"`
	PstTaxCollectable float64 `json:"pst"`
	PstTaxRate        float64 `json:"pst_tax_rate"`
	QstTaxableAmount  float64 `json:"qst_taxable_amount"`
	QstTaxCollectable float64 `json:"qst"`
	QstTaxRate        float64 `json:"qst_tax_rate"`
}

type Category

type Category struct {
	Name           string `json:"name"`
	ProductTaxCode string `json:"product_tax_code"`
	Description    string `json:"description"`
}

type CategoryApi

type CategoryApi struct {
	// contains filtered or unexported fields
}

CategoryApi implements CategoryRepository

type CategoryList

type CategoryList struct {
	Categories []Category `json:"categories"`
}

type CategoryRepository

type CategoryRepository interface {
	// contains filtered or unexported methods
}

CategoryRepository defines the interface for working with Categories through the API.

type CategoryService

type CategoryService struct {
	Repository CategoryRepository
}

func (*CategoryService) List

func (s *CategoryService) List() (CategoryList, error)

List all Categories

type Client

type Client struct {
	*http.Client

	Debug bool

	Categories CategoryService
	Rates      RateService
	Taxes      TaxService
	// contains filtered or unexported fields
}

func NewClient

func NewClient(token string) *Client

func (Client) Get

func (c Client) Get(url string, queryParams interface{}) ([]byte, error)

func (Client) Post

func (c Client) Post(url string, params interface{}) ([]byte, error)

func (*Client) Setup

func (c *Client) Setup()

type LineItem

type LineItem struct {
	Id             string  `json:"id,omitempty"`
	Quantity       int64   `json:"quantity,omitempty"`
	ProductTaxCode string  `json:"product_tax_code,omitempty"`
	UnitPrice      float64 `json:"unit_price,omitempty"`
	Discount       float64 `json:"discount,omitempty"`
}

type Rate

type Rate struct {
	Zip                   string  `json:"zip"`
	State                 string  `json:"state`
	StateRate             float64 `json:"state_rate,string"`
	County                string  `json:"county"`
	CountyRate            float64 `json:"county_rate,string"`
	City                  string  `json:"city"`
	CityRate              float64 `json:"city_rate,string"`
	CombinedDistrictRate  float64 `json:"combined_district_rate,string"`
	CombinedRate          float64 `json:"combined_rate,string"`
	Country               string  `json:"country"`
	Name                  string  `json:"name"`
	StandardRate          float64 `json:"standard_rate,string"`
	ReducedRate           float64 `json:"reduced_rate,string"`
	SuperReducedRate      float64 `json:"super_reduced_rate,string"`
	ParkingRate           float64 `json:"parking_rate,string"`
	DistanceSaleThreshold float64 `json:"distance_sale_threshold,string"`
	FreightTaxable        *bool   `json:"freight_taxable"`
}

type RateApi

type RateApi struct {
	// contains filtered or unexported fields
}

RateApi implements RateRepository

type RateList

type RateList struct {
	Rate Rate `json:"rate"`
}

type RateRepository

type RateRepository interface {
	// contains filtered or unexported methods
}

RateRepository defines the interface for working with Rates through the API.

type RateService

type RateService struct {
	Repository RateRepository
}

func (*RateService) Get

func (s *RateService) Get(zip string, options ...func(*rateParams) error) (Rate, error)

Get a Rate

type Shipping

type Shipping struct {
	StateTaxableAmount   float64 `json:"state_taxable_amount"`
	StateSalesTaxRate    float64 `json:"state_sales_tax_rate"`
	StateAmount          float64 `json:"state_amount"`
	CountyTaxableAmount  float64 `json:"county_taxable_amount"`
	CountyTaxRate        float64 `json:"county_tax_rate"`
	CountyAmount         float64 `json:"county_amount"`
	CityTaxableAmount    float64 `json:"city_taxable_amount"`
	CityTaxRate          float64 `json:"city_tax_rate"`
	CityAmount           float64 `json:"city_amount"`
	SpecialTaxableAmount float64 `json:"special_district_taxable_amount"`
	SpecialTaxRate       float64 `json:"special_tax_rate"`
	SpecialAmount        float64 `json:"special_district_amount"`

	// For CA transactions
	GstTaxableAmount float64 `json:"gst_taxable_amount"`
	GstTaxRate       float64 `json:"gst_tax_rate"`
	GstAmount        float64 `json:"gst"`
	PstTaxableAmount float64 `json:"pst_taxable_amount"`
	PstTaxRate       float64 `json:"pst_tax_rate"`
	PstAmount        float64 `json:"pst"`
	QstTaxableAmount float64 `json:"qst_taxable_amount"`
	QstTaxRate       float64 `json:"qst_tax_rate"`
	QstAmount        float64 `json:"qst"`
}

type Tax

type Tax struct {
	Breakdown        Breakdown `json:"breakdown"`
	OrderTotalAmount float64   `json:"order_total_amount"`
	Shipping         float64   `json:"shipping"`
	TaxableAmount    float64   `json:"taxable_amount"`
	Rate             float64   `json:"rate"`
	AmountToCollect  float64   `json:"amount_to_collect"`
	HasNexus         bool      `json:"has_nexus"`
	FreightTaxable   bool      `json:"freight_taxable"`
	TaxSource        string    `json:"tax_source"`
}

type TaxApi

type TaxApi struct {
	// contains filtered or unexported fields
}

TaxApi implements TaxRepository

type TaxLineItem

type TaxLineItem struct {
	Id string `json:"id"`

	// For US transactions
	StateTaxableAmount   float64 `json:"state_taxable_amount"`
	StateSalesTaxRate    float64 `json:"state_sales_tax_rate"`
	StateAmount          float64 `json:"state_amount"`
	CountyTaxableAmount  float64 `json:"county_taxable_amount"`
	CountyTaxRate        float64 `json:"county_tax_rate"`
	CountyAmount         float64 `json:"county_amount"`
	CityTaxableAmount    float64 `json:"city_taxable_amount"`
	CityTaxRate          float64 `json:"city_tax_rate"`
	CityAmount           float64 `json:"city_amount"`
	SpecialTaxableAmount float64 `json:"special_district_taxable_amount"`
	SpecialTaxRate       float64 `json:"special_tax_rate"`
	SpecialAmount        float64 `json:"special_district_amount"`
	TaxCollectable       float64 `json:"tax_collectable"`
	TaxableAmount        float64 `json:"taxable_amount"`

	// For CA transactions
	GstTaxableAmount float64 `json:"gst_taxable_amount"`
	GstTaxRate       float64 `json:"gst_tax_rate"`
	GstAmount        float64 `json:"gst"`
	PstTaxableAmount float64 `json:"pst_taxable_amount"`
	PstTaxRate       float64 `json:"pst_tax_rate"`
	PstAmount        float64 `json:"pst"`
	QstTaxableAmount float64 `json:"qst_taxable_amount"`
	QstTaxRate       float64 `json:"qst_tax_rate"`
	QstAmount        float64 `json:"qst"`
}

type TaxList

type TaxList struct {
	Tax Tax `json:"tax"`
}

type TaxRepository

type TaxRepository interface {
	// contains filtered or unexported methods
}

TaxRepository defines the interface for working with Tax through the API.

type TaxService

type TaxService struct {
	Repository TaxRepository
}

func (*TaxService) Calculate

func (s *TaxService) Calculate(from, to Address, shipping, amount float64) (Tax, error)

Calculate sales Tax for a given order

func (*TaxService) CalculateItems

func (s *TaxService) CalculateItems(from, to Address, nexuses []Address, shipping float64, items []LineItem) (Tax, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL