Documentation
¶
Overview ¶
Package pay handles models related to payments.
Index ¶
- Constants
- Variables
- type Advance
- func (a *Advance) CalculateFrom(totalWithTax num.Amount)
- func (Advance) JSONSchemaExtend(schema *jsonschema.Schema)
- func (a *Advance) Normalize(normalizers tax.Normalizers)
- func (a *Advance) UnmarshalJSON(data []byte) error
- func (a *Advance) Validate() error
- func (a *Advance) ValidateWithContext(ctx context.Context) error
- type Card
- type CreditTransfer
- type DirectDebit
- type DueDate
- type Instructions
- type Online
- type TermKeyDef
- type Terms
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 MeansKeySEPA cbc.Key = "sepa" // extension for SEPA payments 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.
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 = []*cbc.Definition{ { Key: MeansKeyAny, Name: i18n.NewString("Any"), Desc: i18n.NewString("Any method available, no preference."), }, { Key: MeansKeyCard, Name: i18n.NewString("Card"), Desc: i18n.NewString("Payment card."), }, { Key: MeansKeyCreditTransfer, Name: i18n.NewString("Credit Transfer"), Desc: i18n.NewString("Sender initiated bank or wire transfer."), }, { Key: MeansKeyCreditTransfer.With(MeansKeySEPA), Name: i18n.NewString("SEPA Credit Transfer"), Desc: i18n.NewString("Sender initiated bank or wire transfer via SEPA."), }, { Key: MeansKeyDebitTransfer, Name: i18n.NewString("Debit Transfer"), Desc: i18n.NewString("Receiver initiated bank or wire transfer."), }, { Key: MeansKeyCash, Name: i18n.NewString("Cash"), Desc: i18n.NewString("Cash in hand."), }, { Key: MeansKeyCheque, Name: i18n.NewString("Cheque"), Desc: i18n.NewString("Cheque from bank."), }, { Key: MeansKeyBankDraft, Name: i18n.NewString("Draft"), Desc: i18n.NewString("Bankers Draft or Bank Cheque."), }, { Key: MeansKeyDirectDebit, Name: i18n.NewString("Direct Debit"), Desc: i18n.NewString("Direct debit from the customers bank account."), }, { Key: MeansKeyDirectDebit.With(MeansKeySEPA), Name: i18n.NewString("SEPA Direct Debit"), Desc: i18n.NewString("Direct debit from the customers bank account via SEPA."), }, { Key: MeansKeyOnline, Name: i18n.NewString("Online"), Desc: i18n.NewString("Online or web payment."), }, { Key: MeansKeyPromissoryNote, Name: i18n.NewString("Promissory Note"), Desc: i18n.NewString("Promissory note contract."), }, { Key: MeansKeyNetting, Name: i18n.NewString("Netting"), Desc: i18n.NewString("Intercompany clearing or clearing between partners."), }, { Key: MeansKeyOther, Name: i18n.NewString("Other"), Desc: i18n.NewString("Other or mutually defined means of payment."), }, }
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 { uuid.Identify // 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:"description" 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"` // Details of the payment that was made via a credit or debit card. Card *Card `json:"card,omitempty" jsonschema:"title=Card"` // Details about how the payment was made by credit (bank) transfer. CreditTransfer *CreditTransfer `json:"credit_transfer,omitempty" jsonschema:"title=Credit Transfer"` // Tax extensions required by tax regimes or addons. Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"` // Additional details useful for the parties involved. Meta cbc.Meta `json:"meta,omitempty" jsonschema:"title=Meta"` }
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.
func (*Advance) Normalize ¶ added in v0.200.0
func (a *Advance) Normalize(normalizers tax.Normalizers)
Normalize will try to normalize the advance's data.
func (*Advance) UnmarshalJSON ¶ added in v0.67.0
UnmarshalJSON helps migrate the desc field to description.
type Card ¶ added in v0.2.0
type Card struct { // First 6 digits of the card's Primary Account Number (PAN). First6 string `json:"first6" jsonschema:"title=First 6"` // 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. PCI compliance requires only the first 6 and last 4 digits of the card number to be stored openly.
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 code value used to link the payment with the invoice. Ref cbc.Code `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"` // Extension key-pairs values defined by a tax regime. Ext tax.Extensions `json:"ext,omitempty" jsonschema:"title=Extensions"` // 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) Normalize ¶ added in v0.200.0
func (i *Instructions) Normalize(normalizers tax.Normalizers)
Normalize will try to normalize the instructions.
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 Online ¶ added in v0.2.0
type Online struct { // Key identifier for this online payment method. Key cbc.Key `json:"key,omitempty" jsonschema:"title=Key"` // Descriptive label for the online provider. Label string `json:"label,omitempty" jsonschema:"title=Label"` // URL to be used for payment. URL string `json:"url" jsonschema:"title=URL"` }
Online provides the details required to make a payment online using a website
func (*Online) UnmarshalJSON ¶ added in v0.78.0
UnmarshalJSON is used to handle the migration of the Online's properties to Label and URL.
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,omitempty" 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 4279 code associated with the terms key.