fee

package
v1.49.61 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSchedule = schedule.Schedule{Type: schedule.DailyRolling, Period: 30}

DefaultSchedule is the clawback buffer a payable matures through: 30 days daily-rolling, the same default affiliate.New seeds.

Functions

func Qualify added in v1.49.61

func Qualify(db *datastore.Datastore, s schedule.Schedule, now time.Time) (int, error)

Qualify is the Pending -> Payable transition, and the ONE definition of when a commission has matured.

A commission is EARNED the moment the referee spends, but it is not yet ours to pay: the charge behind it can still be refunded or charged back. It becomes PAYABLE once it is older than the clawback buffer. That buffer is exactly what schedule.Schedule already computes and what the payout crons already filtered on — this supplies the transition they were waiting for.

Nothing in the repo ever wrote Payable while four consumers filtered on it, so every commission accrued Pending and was structurally unpayable. Returns the number of fees matured.

func Query

Query returns a datastore query for fees.

Types

type Bitcoin

type Bitcoin struct {
	FinalTransactionTxId string         `json:"finalTransactionTxId,omitempty"`
	FinalAddress         string         `json:"finalAddress,omitempty"`
	FinalAmount          currency.Cents `json:"finalAmount,omitempty"`
	FinalVOut            int64          `json:"vout,omitempty"`
}

type Ethereum

type Ethereum struct {
	FinalTransactionHash string                `json:"finalTransactionHash,omitempty"`
	FinalTransactionCost blockchains.BigNumber `json:"finalTransactionCost,omitempty"`
	FinalAddress         string                `json:"finalAddress,omitempty"`
	FinalAmount          blockchains.BigNumber `json:"finalAmount,omitempty"`
}

type Fee

type Fee struct {
	mixin.Model[Fee]

	Name string `json:"name"`

	// Type names WHY we owe (which program earned it); PayeeId names WHO. One
	// payee reference, not one field per program — the program is a field on the
	// payable, not a shape of it.
	Type    Type   `json:"type"`
	PayeeId string `json:"payeeId,omitempty"`

	// PaymentId is the event that earned it — the charge or usage transaction.
	PaymentId string `json:"paymentId"`

	Commission commission.Commission `json:"commission,omitempty"`

	Currency       currency.Type  `json:"currency"`
	Amount         currency.Cents `json:"amount"`
	AmountRefunded currency.Cents `json:"amountRefunded,omitempty"`

	Status Status `json:"status" orm:"default:pending"`

	Ethereum Ethereum `json:"ethereum"`
	Bitcoin  Bitcoin  `json:"bitcoin"`

	// Stripe livemode
	Live bool `json:"live"`

	// Internal testing flag
	Test bool `json:"-"`
}

func New

func New(db *datastore.Datastore) *Fee

New creates a new Fee wired to the given datastore.

func (*Fee) Owed added in v1.49.61

func (f *Fee) Owed() currency.Money

Owed is what this payable accrued, as money.

type Status

type Status string
const (
	Pending  Status = "pending"  // accrued, still inside the clawback buffer
	Disputed Status = "disputed" // held; not payable
	Payable  Status = "payable"  // matured; owed and payable now
	Refunded Status = "refunded" // the charge behind it came back
)

type Type

type Type string
const (
	Platform    Type = "platform"
	Affiliate   Type = "affiliate"
	Partner     Type = "partner"
	Contributor Type = "contributor"
)

Jump to

Keyboard shortcuts

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