calculator

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Coupon

type Coupon interface {
	ValidForType(string) bool
	ValidForPrice(string, uint64) bool
	PercentageDiscount() uint64
	FixedDiscount(string) uint64
}

type FixedMemberDiscount

type FixedMemberDiscount struct {
	Amount   string `json:"amount"`
	Currency string `json:"currency"`
}

type Item

type Item interface {
	PriceInLowestUnit() uint64
	ProductType() string
	FixedVAT() uint64
	TaxableItems() []Item
	GetQuantity() uint64
}

type ItemPrice

type ItemPrice struct {
	Quantity uint64

	Subtotal uint64
	Discount uint64
	Taxes    uint64
	Total    uint64
}

type MemberDiscount

type MemberDiscount struct {
	Claims       map[string]string      `json:"claims"`
	Percentage   uint64                 `json:"percentage"`
	FixedAmount  []*FixedMemberDiscount `json:"fixed"`
	ProductTypes []string               `json:"product_types"`
}

func (*MemberDiscount) FixedDiscount

func (c *MemberDiscount) FixedDiscount(currency string) uint64

func (*MemberDiscount) ValidForType

func (d *MemberDiscount) ValidForType(productType string) bool

type Price

type Price struct {
	Items []ItemPrice

	Subtotal uint64
	Discount uint64
	Taxes    uint64
	Total    uint64
}

func CalculatePrice

func CalculatePrice(settings *Settings, jwtClaims map[string]interface{}, country, currency string, coupon Coupon, items []Item) Price

type Settings

type Settings struct {
	PricesIncludeTaxes bool              `json:"prices_include_taxes"`
	Taxes              []*Tax            `json:"taxes"`
	MemberDiscounts    []*MemberDiscount `json:"member_discounts"`
}

type Tax

type Tax struct {
	Percentage   uint64   `json:"percentage"`
	ProductTypes []string `json:"product_types"`
	Countries    []string `json:"countries"`
}

func (*Tax) AppliesTo

func (t *Tax) AppliesTo(country, productType string) bool

Jump to

Keyboard shortcuts

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