Documentation
¶
Overview ¶
Package pay handles models related to payments.
Index ¶
Constants ¶
const ( MeansKeyAny cbc.Key = "any" // Use any method available. MeansKeyCard cbc.Key = "card" MeansKeyCreditTransfer cbc.Key = "credit-transfer" MeansKeyDebitTransfer cbc.Key = "debit-transfer" MeansKeyCash cbc.Key = "cash" MeansKeyPromissoryNote cbc.Key = "promissory-note" MeansKeyNetting cbc.Key = "netting" // Clearing between parties MeansKeyCheque cbc.Key = "cheque" MeansKeyBankDraft cbc.Key = "bank-draft" MeansKeyDirectDebit cbc.Key = "direct-debit" // aka. Mandate MeansKeyOnline cbc.Key = "online" // Website from which payment can be made MeansKeyOther cbc.Key = "other" )
Standard payment means codes for instructions. If you require more payment means options, please make a pull request and try to include references to the use case. All new means keys should map to an existing UNTDID 4461 code.
const ( // None defined TermKeyNA cbc.Key = "" // End of Month TermKeyEndOfMonth cbc.Key = "end-of-month" // Due on a specific date TermKeyDueDate cbc.Key = "due-date" // Deferred until after the due dates TermKeyDeferred cbc.Key = "deferred" // Month after the present TermKeyProximo cbc.Key = "proximo" // on receipt of invoice TermKeyInstant cbc.Key = "instant" // chosen by buyer TermKeyElective cbc.Key = "elective" // Seller to advise buyer in separate transaction TermKeyPending cbc.Key = "pending" // Payment made in advance TermKeyAdvanced cbc.Key = "advanced" // Payment on Delivery TermKeyDelivery cbc.Key = "delivery" )
Pre-defined Payment Terms based on UNTDID 4279
Variables ¶
var HasValidMeansKey = cbc.HasValidKeyIn(validBaseMeansKeys()...)
HasValidMeansKey provides a usable validator for the means key to ensure it is at least *based* on one of the primary keys. This allows means keys to be extended or customised.
var MeansKeyDefinitions = []MeansKeyDef{ {MeansKeyAny, "Any", "Any method available, no preference.", "1"}, {MeansKeyCard, "Card", "Payment card.", "48"}, {MeansKeyCreditTransfer, "Credit Transfer", "Sender initiated bank or wire transfer.", "30"}, {MeansKeyDebitTransfer, "Debit Transfer", "Receiver initiated bank or wire transfer.", "31"}, {MeansKeyCash, "Cash", "Cash in hand.", "10"}, {MeansKeyCheque, "Cheque", "Cheque from bank.", "20"}, {MeansKeyBankDraft, "Draft", "Bankers Draft or Bank Cheque.", "21"}, {MeansKeyDirectDebit, "Direct Debit", "Direct debit from the customers bank account.", "49"}, {MeansKeyOnline, "Online", "Online or web payment.", "68"}, {MeansKeyPromissoryNote, "Promissory Note", "Promissory note contract.", "60"}, {MeansKeyNetting, "Netting", "Intercompany clearing or clearing between partners.", "97"}, {MeansKeyOther, "Other", "Other or mutually defined means of payment.", "ZZZ"}, }
MeansKeyDefinitions includes all the payment means keys that are accepted by GOBL.
var TermKeyDefinitions = []TermKeyDef{ {TermKeyNA, "NA", "Not yet defined", "16"}, {TermKeyEndOfMonth, "End of Month", "End of month", "2"}, {TermKeyDueDate, "Due Date", "Due on a specific date", "3"}, {TermKeyDeferred, "Deferred", "Deferred until after the due date", "4"}, {TermKeyProximo, "Proximo", "Month after the present", "9"}, {TermKeyInstant, "Instant", "On receipt of invoice", "10"}, {TermKeyElective, "Elective", "Chosen by the buyer", "11"}, {TermKeyPending, "Pending", "Seller to advise buyer in separate transaction", "13"}, {TermKeyAdvanced, "Advanced", "Payment made in advance", "32"}, {TermKeyDelivery, "Delivery", "Payment on Delivery", "52"}, }
TermKeyDefinitions includes all the currently accepted GOBL Payment Term definitions.
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"`
// The payment means used to make the advance.
Key cbc.Key `json:"key,omitempty" jsonschema:"title=Key"`
// 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) CalculateFrom ¶ added in v0.30.3
CalculateFrom will update the amount using the rate of the provided total, if defined.
func (Advance) JSONSchemaExtend ¶ added in v0.50.0
func (Advance) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSONSchema for the Instructions type.
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.
type Instructions ¶ added in v0.2.0
type Instructions struct {
// The payment means expected or that have been arranged to be used to make the payment.
Key cbc.Key `json:"key" jsonschema:"title=Key"`
// Optional text description of the payment method
Detail string `json:"detail,omitempty" jsonschema:"title=Detail"`
// Remittance information or concept, a text value used to link the payment with the invoice.
Ref string `json:"ref,omitempty" jsonschema:"title=Reference"`
// 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 cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"`
}
Instructions determine how the payment has or should be made. A single "key" exists in which the preferred payment method should be provided, all other details serve as a reference.
func (Instructions) JSONSchemaExtend ¶ added in v0.38.0
func (Instructions) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend extends the JSONSchema for the Instructions type.
func (*Instructions) UNTDID4461 ¶ added in v0.28.0
func (i *Instructions) UNTDID4461() cbc.Code
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.
func (*Instructions) ValidateWithContext ¶ added in v0.50.0
func (i *Instructions) ValidateWithContext(ctx context.Context) error
ValidateWithContext ensures the fields provided in the instructions are valid.
type MeansKeyDef ¶ added in v0.50.0
type MeansKeyDef struct {
// Key being described
Key cbc.Key `json:"key" jsonschema:"title=Key"`
// Human value of the key
Title string `json:"title" jsonschema:"title=Title"`
// Details about the meaning of the key
Description string `json:"description" jsonschema:"title=Description"`
// UNTDID 4461 Equivalent Code
UNTDID4461 cbc.Code `json:"untdid4461" jsonschema:"title=UNTDID 4461 Code"`
}
MeansKeyDef is used to define each of the payment means keys that can be accepted by GOBL.
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
type TermKeyDef ¶ added in v0.29.0
type TermKeyDef struct {
// The key being defined
Key cbc.Key `json:"key" jsonschema:"title=Key"`
// Human readable title for the key
Title string `json:"title" jsonschema:"title=Title"`
// Human text for the key
Description string `json:"description" jsonschema:"title=Description"`
// The equivalent UNTDID 4279 Code
UNTDID4279 cbc.Code `json:"untdid4279" jsonschema:"title=UNTDID 4279 Code"`
}
TermKeyDef holds a definition of a single payment term key
type Terms ¶
type Terms struct {
// Type of terms to be applied.
Key cbc.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
CalculateDues goes through each DueDate. If it has a percentage value set, it'll be used to calculate the amount.
func (Terms) JSONSchemaExtend ¶ added in v0.38.0
func (Terms) JSONSchemaExtend(schema *jsonschema.Schema)
JSONSchemaExtend adds the payment terms key list to the schema.
func (*Terms) UNTDID4279 ¶ added in v0.28.0
UNTDID4279 returns the UNTDID 4270 code associated with the terms key.