pay

package
v0.28.2 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

View Source
const (
	MethodKeyAny            org.Key = "any" // Use any method available.
	MethodKeyCard           org.Key = "card"
	MethodKeyCreditTransfer org.Key = "credit-transfer"
	MethodKeyDebitTransfer  org.Key = "debit-transfer"
	MethodKeyCash           org.Key = "cash"
	MethodKeyDirectDebit    org.Key = "direct-debit" // aka. Mandate
	MethodKeyOnline         org.Key = "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.

View Source
const (
	TermKeyNA         org.Key = ""             // None defined
	TermKeyEndOfMonth org.Key = "end-of-month" // End of Month
	TermKeyDueDate    org.Key = "due-date"     // Due on a specific date
	TermKeyDeferred   org.Key = "deferred"     // Deferred until after the due dates
	TermKeyProximo    org.Key = "proximo"      // Month after the present
	TermKeyInstant    org.Key = "instant"      // on receipt of invoice
	TermKeyElective   org.Key = "elective"     // chosen by buyer
	TermKeyPending    org.Key = "pending"      // Seller to advise buyer in separate transaction
	TermKeyAdvance    org.Key = "advance"      // Payment made in advance
	TermKeyDelivery   org.Key = "delivery"     // Payment on Delivery
)

Pre-defined Payment Terms based on UNTDID 4279

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 *cal.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
	Percent *num.Percentage `json:"percent,omitempty" jsonschema:"title=Percent"`
	// 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 {
	// Last 4 digits of the card's Primary Account Number (PAN).
	Last4 string `json:"last4" jsonschema:"title=Last 4"`
	// Name of the person whom the card belongs to.
	Holder string `json:"holder" jsonschema:"title=Holder Name"`
}

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

type CreditTransfer added in v0.2.0

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

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 {
	// Unique identifier assigned by the payee for referencing the direct debit.
	Ref string `json:"ref,omitempty" jsonschema:"title=Mandate Reference"`
	// Unique banking reference that identifies the payee or seller assigned by the bank.
	Creditor string `json:"creditor,omitempty" jsonschema:"title=Creditor ID"`
	// Account identifier to be debited by the direct debit.
	Account string `json:"account,omitempty" jsonschema:"title=Account"`
}

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

type DueDate added in v0.2.0

type DueDate struct {
	Date     *cal.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 {
	// How payment is expected or has been arranged to be collected
	Key org.Key `json:"key" jsonschema:"title=Key"`
	// Optional text description of the payment method
	Detail string `json:"detail,omitempty" jsonschema:"title=Detail"`
	// Remittance information, a text value used to link the payment with the invoice.
	Ref string `json:"ref,omitempty" jsonschema:"title=Ref"`
	// Instructions for sending payment via a bank transfer.
	CreditTransfer []*CreditTransfer `json:"credit_transfer,omitempty" jsonschema:"title=Credit Transfer"`
	// Details of the payment that will be made via a credit or debit card.
	Card *Card `json:"card,omitempty" jsonschema:"title=Card"`
	// A group of terms that can be used by the customer or payer to consolidate direct debit payments.
	DirectDebit *DirectDebit `json:"direct_debit,omitempty" jsonschema:"title=Direct Debit"`
	// Array of online payment options
	Online []*Online `json:"online,omitempty" jsonschema:"title=Online"`
	// Any additional instructions that may be required to make the payment.
	Notes string `json:"notes,omitempty" jsonschema:"title=Notes"`
	// Non-structured additional data that may be useful.
	Meta org.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}

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.

func (*Instructions) UNTDID4461 added in v0.28.0

func (i *Instructions) UNTDID4461() string

UNTDID4461 provides the standard UNTDID 4461 code for the instruction's key.

func (*Instructions) Validate added in v0.28.0

func (i *Instructions) Validate() error

Validate ensures the fields provided in the instructions are valid.

type Online added in v0.2.0

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

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 Terms

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

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) UNTDID4279 added in v0.28.0

func (t *Terms) UNTDID4279() string

UNTDID4279 returns the UNTDID 4270 code associated with the terms key.

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