pay

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2022 License: Apache-2.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advance added in v0.2.0

type Advance struct {
	// Unique identifier for this advance.
	UUID *uuid.UUID `json:"uuid,omitempty" jsonschema:"title=UUID"`
	// When the advance was made.
	Date *org.Date `json:"date,omitempty" jsonschema:"title=Date"`
	// ID or reference for the advance.
	Ref string `json:"ref,omitempty" jsonschema:"title=Reference"`
	// If this "advance" payment has come from a public grant or subsidy, set this to true.
	Grant bool `json:"grant,omitempty" jsonschema:"title=Grant"`
	// Details about the advance.
	Description string `json:"desc" jsonschema:"title=Description"`
	// How much as a percentage of the total with tax was paid
	Rate *num.Percentage `json:"rate,omitempty" jsonschema:"title=Rate"`
	// How much was paid.
	Amount num.Amount `json:"amount" jsonschema:"title=Amount"`
	// If different from the parent document's base currency.
	Currency currency.Code `json:"currency,omitempty" jsonschema:"title=Currency"`
}

Advance represents a single payment that has been made already, such as a deposit on an intent to purchase, or as credit from a previous invoice which was later corrected or cancelled.

func (*Advance) Calculate added in v0.13.0

func (a *Advance) Calculate(totalWithTax num.Amount)

Calculate will update the amount using the rate of the provided total, if defined.

func (*Advance) Validate added in v0.2.0

func (a *Advance) Validate() error

Validate checks the advance looks okay

type Advances added in v0.13.0

type Advances []*Advance

Advances contains an array of advance objects.

type Card added in v0.2.0

type Card struct {
	Last4  string `json:"last4" jsonschema:"title=Last 4,description=Last 4 digits of the card's Primary Account Number (PAN)."`
	Holder string `json:"holder" jsonschema:"title=Holder Name,description=Name of the person whom the card belongs to."`
}

Card contains simplified card holder data as a reference for the customer.

type CreditTransfer added in v0.2.0

type CreditTransfer struct {
	IBAN   string       `json:"iban,omitempty" jsonschema:"title=IBAN,description=International Bank Account Number"`
	BIC    string       `json:"bic,omitempty" jsonschema:"title=BIC,description=Bank Identifier Code used for international transfers."`
	Number string       `json:"number,omitempty" jsonschema:"title=Number,description=Account number, if IBAN not available."`
	Name   string       `json:"name,omitempty" jsonschema:"title=Name,description=Name of the bank."`
	Branch *org.Address `json:"branch,omitempty" jsonschema:"title=Branch,description=Bank office branch address, not normally required."`
}

CreditTransfer contains fields that can be used for making payments via a bank transfer or wire.

type DirectDebit added in v0.2.0

type DirectDebit struct {
	Ref      string `` /* 143-byte string literal not displayed */
	Creditor string `` /* 151-byte string literal not displayed */
	Account  string `json:"account,omitempty" jsonschema:"title=Account,description=Account identifier to be debited by the direct debit."`
}

DirectDebit defines the data that will be used to make the direct debit.

type DueDate added in v0.2.0

type DueDate struct {
	Date     *org.Date       `json:"date" jsonschema:"title=Date,description=When the payment is due."`
	Notes    string          `json:"notes,omitempty" jsonschema:"title=Notes,description=Other details to take into account for the due date."`
	Amount   num.Amount      `json:"amount" jsonschema:"title=Amount,description=How much needs to be paid by the date."`
	Percent  *num.Percentage `json:"percent,omitempty" jsonschema:"title=Percent,description=Percentage of the total that should be paid by the date."`
	Currency currency.Code   `json:"currency,omitempty" jsonschema:"title=Currency,description=If different from the parent document's base currency."`
}

DueDate contains an amount that should be paid by the given date.

func (*DueDate) Validate added in v0.2.0

func (dd *DueDate) Validate() error

Validate checks the DueDate has the required fields.

type Instructions added in v0.2.0

type Instructions struct {
	Code           MethodCode        `json:"code" jsonschema:"title=Code,description=How payment is expected or has been arranged to be collected."`
	Detail         string            `json:"detail,omitempty" jsonschema:"title=Detail,description=Optional text description of the payment method."`
	Ref            string            `` /* 135-byte string literal not displayed */
	CreditTransfer []*CreditTransfer `` /* 133-byte string literal not displayed */
	Card           *Card             `` /* 126-byte string literal not displayed */
	DirectDebit    *DirectDebit      `` /* 170-byte string literal not displayed */
	Online         []*Online         `json:"online,omitempty" jsonschema:"title=Online,description=Array of online payment options."`
	Notes          string            `` /* 129-byte string literal not displayed */
	Meta           map[string]string `json:"meta,omitempty" jsonschema:"title=Meta,description=Non-structured additional data that may be useful."`
}

Instructions holds a set of instructions that determine how the payment has or should be made. A single "code" exists in which the preferred payment method should be provided. All other details serve as a reference.

type MethodCode

type MethodCode string

MethodCode defines a standard set of names for payment means.

const (
	MethodCodeAny            MethodCode = "any" // Use any method available.
	MethodCodeCard           MethodCode = "card"
	MethodCodeCreditTransfer MethodCode = "credit_transfer"
	MethodCodeCash           MethodCode = "cash"
	MethodCodeDirectDebit    MethodCode = "direct_debit" // aka. Mandate
	MethodCodeOnline         MethodCode = "online"       // Website from which payment can be made
)

Standard payment method codes. This is a heavily reduced list of practical codes which can be linked to UNTDID 4461 counterparts. If you require more payment method options, please send your pull requests.

func (MethodCode) UNTDID4461 added in v0.2.0

func (c MethodCode) UNTDID4461() string

UNTDID4461 provides the standard UNTDID 4461 code for the payment method.

type Online added in v0.2.0

type Online struct {
	Name    string `json:"name,omitempty" jsonschema:"title=Name,description=Descriptive name given to the online provider."`
	Address string `json:"addr" jsonschema:"title=Address,description=Full URL to be used for payment."`
}

Online provides the details required to make a payment online using a website

func (*Online) Validate added in v0.2.0

func (u *Online) Validate() error

Validate ensures the Online method details look correct.

type TermCode

type TermCode string

TermCode is used to define a code that identifies the payment terms.

const (
	TermNA         TermCode = "na"           // None defined
	TermEndOfMonth TermCode = "end_of_month" // End of Month
	TermDueDate    TermCode = "due_date"     // Due on a specific date
	TermDeferred   TermCode = "deferred"     // Deferred until after the due dates
	TermProximo    TermCode = "proximo"      // Month after the present
	TermInstant    TermCode = "instant"      // on receipt of invoice
	TermElective   TermCode = "elective"     // chosen by buyer
	TermPending    TermCode = "pending"      // Seller to advise buyer in separate transaction
	TermAdvance    TermCode = "advance"      // Payment made in advance
	TermDelivery   TermCode = "delivery"     // Payment on Delivery
)

Pre-defined Payment Terms based on UNTDID 4279

func (TermCode) Validate added in v0.2.0

func (c TermCode) Validate() error

Validate checks to ensure the typecode is part of a known list.

type Terms

type Terms struct {
	Code     TermCode   `json:"code" jsonschema:"title=Code,description=Type of terms to be applied."`
	Detail   string     `json:"detail,omitempty" jsonschema:"title=Detail,description=Text detail of the chosen payment terms."`
	DueDates []*DueDate `json:"due_dates,omitempty" jsonschema:"title=Due Dates,description=Set of dates for agreed payments."`
	Notes    string     `json:"notes,omitempty" jsonschema:"title=Notes,description=Description of the conditions for payment."`
}

Terms defines when we expect the customer to pay, or have paid, for the contents of the document.

func (*Terms) CalculateDues added in v0.2.0

func (t *Terms) CalculateDues(sum num.Amount)

CalculateDues goes through each DueDate. If it has a percentage value set, it'll be used to calculate the amount.

func (*Terms) Validate added in v0.2.0

func (t *Terms) Validate() error

Validate ensures that the terms contain everything required.

Jump to

Keyboard shortcuts

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