credit

package
v1.35.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Query

Types

type CreditNote

type CreditNote struct {
	mixin.BaseModel

	InvoiceId  string        `json:"invoiceId"`
	CustomerId string        `json:"customerId"`
	Number     string        `json:"number"` // "CN-0001"
	Amount     int64         `json:"amount"` // total credit in cents
	Currency   currency.Type `json:"currency"`
	Status     Status        `json:"status"`

	// "duplicate" | "fraudulent" | "order_change" | "product_unsatisfactory"
	Reason string `json:"reason,omitempty"`

	LineItems  []CreditNoteLineItem `json:"lineItems,omitempty" datastore:"-"`
	LineItems_ string               `json:"-" datastore:",noindex"`

	// Credit that doesn't correspond to a specific line on the original invoice
	OutOfBandAmount int64 `json:"outOfBandAmount,omitempty"`

	// If applied to customer balance, the balance transaction ID
	CreditBalanceTransaction string `json:"creditBalanceTransaction,omitempty"`

	// If refunded to payment method
	RefundId string `json:"refundId,omitempty"`

	Memo string `json:"memo,omitempty"`

	Metadata  Map    `json:"metadata,omitempty" datastore:"-"`
	Metadata_ string `json:"-" datastore:",noindex"`
}

CreditNote represents a credit issued against an invoice. Credits can be applied to customer balance or refunded to the original payment method.

func New

func New(db *datastore.Datastore) *CreditNote

func (*CreditNote) Defaults

func (cn *CreditNote) Defaults()

func (*CreditNote) Init

func (cn *CreditNote) Init(db *datastore.Datastore)

func (CreditNote) Kind

func (cn CreditNote) Kind() string

func (*CreditNote) Load

func (cn *CreditNote) Load(ps []datastore.Property) (err error)

func (*CreditNote) MarkVoid

func (cn *CreditNote) MarkVoid() error

MarkVoid voids the credit note.

func (*CreditNote) Save

func (cn *CreditNote) Save() (ps []datastore.Property, err error)

func (*CreditNote) SetNumber

func (cn *CreditNote) SetNumber(n int)

SetNumber assigns the credit note number.

func (*CreditNote) Validator

func (cn *CreditNote) Validator() *val.Validator

type CreditNoteLineItem

type CreditNoteLineItem struct {
	Description string        `json:"description"`
	Amount      int64         `json:"amount"` // cents
	Currency    currency.Type `json:"currency"`
	Quantity    int64         `json:"quantity,omitempty"`
	UnitPrice   int64         `json:"unitPrice,omitempty"`
}

CreditNoteLineItem represents a line on a credit note.

type Status

type Status string

Status represents the credit note lifecycle state.

const (
	Issued Status = "issued"
	Void   Status = "void"
)

Jump to

Keyboard shortcuts

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