ledger

package
v0.1.8-alpha Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CurrencyUSDMicro = "USD_MICRO"

	AccountCustomerUsage        = "customer_usage_charge"
	AccountHostPendingCredit    = "host_pending_credit"
	AccountHostAvailableCredit  = "host_available_credit"
	AccountPlatformMargin       = "platform_margin"
	AccountPlatformVerification = "platform_verification_overhead"
	AccountPlatformPayoutCash   = "platform_payout_cash"
	AccountPlatformFailed       = "platform_failed_attempt_overhead"

	TransactionJobAcceptance       = "job_acceptance"
	TransactionHostCreditRelease   = "host_credit_release"
	TransactionHostPayout          = "host_payout"
	TransactionLedgerReversal      = "ledger_reversal"
	TransactionVerificationCost    = "verification_overhead"
	TransactionFailedAttemptCost   = "failed_attempt_overhead"
	DefaultPlatformLedgerOwnerID   = "platform_thirdshift"
	DefaultPayoutMemoPrefix        = "Thirdshift host payout"
	DefaultCreditHoldDurationHours = 24
)

Variables

View Source
var (
	ErrDuplicatePosting  = errors.New("ledger posting already exists")
	ErrNoAvailableCredit = errors.New("no available host credit")
)

Functions

This section is empty.

Types

type AcceptedJobLedger

type AcceptedJobLedger struct {
	TransactionID         string
	CreditHoldID          string
	CustomerCharge        int64
	HostCredit            int64
	PlatformMargin        int64
	PriceVersion          string
	AvailableAt           time.Time
	CoordinatorDurationMS int64
}

type AcceptedJobPosting

type AcceptedJobPosting struct {
	JobID                            string
	AttemptID                        string
	ReceivedAt                       time.Time
	CreditHold                       time.Duration
	PromptTokens                     int
	CompletionTokens                 int
	CoordinatorDurationMillis        int64
	VerificationOverheadMicrodollars int64
}

type EconomicsReport

type EconomicsReport struct {
	CustomerRevenueMicrodollars       int64
	HostCreditsMicrodollars           int64
	VerificationOverheadMicrodollars  int64
	FailedAttemptOverheadMicrodollars int64
	ContributionMarginMicrodollars    int64
}

type PayoutBatch

type PayoutBatch struct {
	ID                  string
	Status              string
	TotalMicrodollars   int64
	ItemCount           int
	TransactionID       string
	ExportedCSVChecksum string
}

type Store

type Store struct {
	Pool *pgxpool.Pool
}

func (Store) ConfirmPayoutBatch

func (s Store) ConfirmPayoutBatch(ctx context.Context, batchID string, confirmation io.Reader, now time.Time) (PayoutBatch, error)

func (Store) CreatePayoutBatch

func (s Store) CreatePayoutBatch(ctx context.Context, organizationID string, now time.Time) (PayoutBatch, error)

func (Store) EconomicsReport

func (s Store) EconomicsReport(ctx context.Context, from, until time.Time) (EconomicsReport, error)

func (Store) ExportPayoutBatch

func (s Store) ExportPayoutBatch(ctx context.Context, batchID string, now time.Time) ([]byte, PayoutBatch, error)

func (Store) PostAcceptedJob

func (s Store) PostAcceptedJob(ctx context.Context, posting AcceptedJobPosting) (AcceptedJobLedger, error)

func (Store) PostAcceptedJobTx

func (s Store) PostAcceptedJobTx(ctx context.Context, tx pgx.Tx, posting AcceptedJobPosting) (AcceptedJobLedger, error)

func (Store) PostVerificationOverhead

func (s Store) PostVerificationOverhead(ctx context.Context, posting VerificationOverheadPosting) (AcceptedJobLedger, error)

func (Store) PromoteAvailableCredits

func (s Store) PromoteAvailableCredits(ctx context.Context, now time.Time) (int64, error)

func (Store) ReverseTransaction

func (s Store) ReverseTransaction(ctx context.Context, transactionID, memo string, now time.Time) (string, error)

func (Store) VoidPayoutBatch

func (s Store) VoidPayoutBatch(ctx context.Context, batchID, memo string, now time.Time) (PayoutBatch, error)

type VerificationOverheadPosting

type VerificationOverheadPosting struct {
	JobID                     string
	AttemptID                 string
	ReceivedAt                time.Time
	CreditHold                time.Duration
	CompletionTokens          int
	CoordinatorDurationMillis int64
}

Jump to

Keyboard shortcuts

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