Skip to main content

Generated from package comments and exported declarations. Edit the Go source, not this file.

ledger

import "codeberg.org/hemanta212/playgo/api/ledger"

Package ledger defines the double-entry accounting primitives behind every wallet.

Double-entry means each movement of money is recorded twice, once as a debit and once as a credit, and the two must balance. That is what makes the books provable: if the entries balance, money was moved rather than invented.

Admin reads expose accounts and transactions. Admin adjustments and payment operations post balanced entries through internal implementations - never by writing a balance directly, because a directly written balance has no matching entry and silently breaks the accounting.

Amounts here are cent-based and explicit, which keeps handlers from inventing alternate units or ad-hoc balance semantics.

Variables​

var (
ErrInvalidAmount = errors.New("ledger: amount must be positive")
ErrInvariant = errors.New("ledger: invariant violation")
)

type AccountID​

type AccountID uuid.UUID

type AccountStatus​

type AccountStatus string
const AccountStatusActive AccountStatus = "active"

type AccountType​

type AccountType string
const (
AccountTypeCashoutReviewHolding AccountType = "cashout_review_holding"
AccountTypeCash AccountType = "cash"
AccountTypeDepositBonus AccountType = "deposit_bonus"
AccountTypeWithdrawableCash AccountType = "withdrawable_cash"
AccountTypePendingWithdrawal AccountType = "pending_withdrawal"
AccountTypeForfeit AccountType = "forfeit"
AccountTypeDepositSubsidy AccountType = "deposit_subsidy"
AccountTypeHousePromo AccountType = "house_promo"
)

type Cents​

type Cents int64

func (Cents) Int64​

func (amount Cents) Int64() int64

type CurrencyCode​

type CurrencyCode string
const CurrencyUSD CurrencyCode = "USD"

type EntryDirection​

type EntryDirection string
const (
EntryDirectionDebit EntryDirection = "debit"
EntryDirectionCredit EntryDirection = "credit"
)

type OwnerType​

type OwnerType string
const (
OwnerTypeUser OwnerType = "user"
OwnerTypeSystem OwnerType = "system"
)

type TransactionID​

type TransactionID uuid.UUID

type TransactionKind​

type TransactionKind string
const (
TransactionKindProviderCashoutHold TransactionKind = "provider_cashout_hold"
TransactionKindProviderCashoutRestore TransactionKind = "provider_cashout_restore"
TransactionKindWalletCredit TransactionKind = "wallet_credit"
TransactionKindWalletDebit TransactionKind = "wallet_debit"
TransactionKindProviderCashoutForfeit TransactionKind = "provider_cashout_forfeit"
TransactionKindWithdrawalReserve TransactionKind = "withdrawal_reserve"
TransactionKindWithdrawalRelease TransactionKind = "withdrawal_release"
TransactionKindWithdrawalSettle TransactionKind = "withdrawal_settle"
TransactionKindProviderLoadReserve TransactionKind = "provider_load_reserve"
TransactionKindProviderLoadRefund TransactionKind = "provider_load_refund"
TransactionKindProviderCashoutSettle TransactionKind = "provider_cashout_settle"
// TransactionKindProviderReviewedUnloadSettle settles an admin-reviewed first
// unload of a linked account; it may include value PlayGo never loaded.
TransactionKindProviderReviewedUnloadSettle TransactionKind = "provider_reviewed_unload_settle"
TransactionKindDepositReversal TransactionKind = "deposit_reversal"
TransactionKindDepositBonusRecovery TransactionKind = "deposit_bonus_recovery"
TransactionKindDepositBonusClawback TransactionKind = "deposit_bonus_clawback"
TransactionKindDepositBonusGrant TransactionKind = "deposit_bonus_grant"
)

type WalletCreditMetadata​

type WalletCreditMetadata struct {
ActorID uuid.UUID `json:"actor_id"`
UserID uuid.UUID `json:"user_id"`
AccountID uuid.UUID `json:"account_id"`
AmountCents Cents `json:"amount_cents"`
BalanceAfterCents Cents `json:"balance_after_cents"`
}

type WalletDebitMetadata​

type WalletDebitMetadata struct {
ActorID uuid.UUID `json:"actor_id"`
UserID uuid.UUID `json:"user_id"`
AccountID uuid.UUID `json:"account_id"`
AmountCents Cents `json:"amount_cents"`
BalanceAfterCents Cents `json:"balance_after_cents"`
}

type WithdrawalMovementMetadata​

type WithdrawalMovementMetadata struct {
TipCents Cents `json:"tip_cents,omitempty"`
ActorID uuid.UUID `json:"actor_id"`
UserID uuid.UUID `json:"user_id"`
WithdrawalID uuid.UUID `json:"withdrawal_id"`
AmountCents Cents `json:"amount_cents"`
Reason string `json:"reason"`
}

type WithdrawalReservationMetadata​

type WithdrawalReservationMetadata struct {
ActorID uuid.UUID `json:"actor_id"`
UserID uuid.UUID `json:"user_id"`
WithdrawalID uuid.UUID `json:"withdrawal_id"`
AmountCents Cents `json:"amount_cents"`
SourceAccountType AccountType `json:"source_account_type,omitempty"`
}

Generated by gomarkdoc