credit

package
v1.42.21 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Query

Types

type CreditNote

type CreditNote struct {
	mixin.Model[CreditNote]

	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" orm:"default:usd"`
	Status     Status        `json:"status" orm:"default:issued"`

	// "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) 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