sqlc

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID           string             `json:"id"`
	TenantID     string             `json:"tenant_id"`
	UserID       string             `json:"user_id"`
	Name         string             `json:"name"`
	Type         AccountType        `json:"type"`
	Currency     string             `json:"currency"`
	BalanceCents int64              `json:"balance_cents"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
	DeletedAt    pgtype.Timestamptz `json:"deleted_at"`
}

type AccountType

type AccountType string
const (
	AccountTypeChecking   AccountType = "checking"
	AccountTypeSavings    AccountType = "savings"
	AccountTypeCreditCard AccountType = "credit_card"
	AccountTypeInvestment AccountType = "investment"
)

func (*AccountType) Scan

func (e *AccountType) Scan(src interface{}) error

type AdminListAllAuditLogsParams

type AdminListAllAuditLogsParams struct {
	EntityType pgtype.Text        `json:"entity_type"`
	EntityID   pgtype.Text        `json:"entity_id"`
	ActorID    string             `json:"actor_id"`
	Action     NullAuditAction    `json:"action"`
	StartDate  pgtype.Timestamptz `json:"start_date"`
	EndDate    pgtype.Timestamptz `json:"end_date"`
	OffsetOff  int32              `json:"offset_off"`
	LimitOff   int32              `json:"limit_off"`
}

type AdminUpdateTenantPlanParams

type AdminUpdateTenantPlanParams struct {
	ID   string     `json:"id"`
	Plan TenantPlan `json:"plan"`
}

type Asset added in v1.13.0

type Asset struct {
	ID        string             `json:"id"`
	Ticker    string             `json:"ticker"`
	Isin      pgtype.Text        `json:"isin"`
	Name      string             `json:"name"`
	AssetType AssetType          `json:"asset_type"`
	Currency  string             `json:"currency"`
	Details   pgtype.Text        `json:"details"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type AssetType added in v1.13.0

type AssetType string
const (
	AssetTypeStock        AssetType = "stock"
	AssetTypeBond         AssetType = "bond"
	AssetTypeFund         AssetType = "fund"
	AssetTypeCrypto       AssetType = "crypto"
	AssetTypeRealEstate   AssetType = "real_estate"
	AssetTypeIncomeSource AssetType = "income_source"
)

func (*AssetType) Scan added in v1.13.0

func (e *AssetType) Scan(src interface{}) error

type AuditAction

type AuditAction string
const (
	AuditActionCreate       AuditAction = "create"
	AuditActionUpdate       AuditAction = "update"
	AuditActionSoftDelete   AuditAction = "soft_delete"
	AuditActionRestore      AuditAction = "restore"
	AuditActionLogin        AuditAction = "login"
	AuditActionLoginFailed  AuditAction = "login_failed"
	AuditActionOtpRequested AuditAction = "otp_requested"
	AuditActionOtpVerified  AuditAction = "otp_verified"
)

func (*AuditAction) Scan

func (e *AuditAction) Scan(src interface{}) error

type AuditLog

type AuditLog struct {
	ID         string             `json:"id"`
	TenantID   string             `json:"tenant_id"`
	ActorID    string             `json:"actor_id"`
	ActorRole  UserRole           `json:"actor_role"`
	Action     AuditAction        `json:"action"`
	EntityType string             `json:"entity_type"`
	EntityID   pgtype.Text        `json:"entity_id"`
	OldValues  []byte             `json:"old_values"`
	NewValues  []byte             `json:"new_values"`
	IpAddress  *netip.Addr        `json:"ip_address"`
	UserAgent  pgtype.Text        `json:"user_agent"`
	CreatedAt  pgtype.Timestamptz `json:"created_at"`
}

type Category

type Category struct {
	ID        string             `json:"id"`
	TenantID  string             `json:"tenant_id"`
	ParentID  pgtype.Text        `json:"parent_id"`
	Name      string             `json:"name"`
	Icon      pgtype.Text        `json:"icon"`
	Color     pgtype.Text        `json:"color"`
	Type      CategoryType       `json:"type"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
	DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}

type CategoryType

type CategoryType string
const (
	CategoryTypeIncome   CategoryType = "income"
	CategoryTypeExpense  CategoryType = "expense"
	CategoryTypeTransfer CategoryType = "transfer"
)

func (*CategoryType) Scan

func (e *CategoryType) Scan(src interface{}) error

type CreateAccountParams

type CreateAccountParams struct {
	ID           string      `json:"id"`
	TenantID     string      `json:"tenant_id"`
	UserID       string      `json:"user_id"`
	Name         string      `json:"name"`
	Type         AccountType `json:"type"`
	Currency     string      `json:"currency"`
	BalanceCents int64       `json:"balance_cents"`
}

type CreateAssetParams added in v1.13.0

type CreateAssetParams struct {
	ID        string      `json:"id"`
	Ticker    string      `json:"ticker"`
	Isin      pgtype.Text `json:"isin"`
	Name      string      `json:"name"`
	AssetType AssetType   `json:"asset_type"`
	Currency  string      `json:"currency"`
	Details   pgtype.Text `json:"details"`
}

type CreateAuditLogParams

type CreateAuditLogParams struct {
	ID         string      `json:"id"`
	TenantID   string      `json:"tenant_id"`
	ActorID    string      `json:"actor_id"`
	ActorRole  UserRole    `json:"actor_role"`
	Action     AuditAction `json:"action"`
	EntityType string      `json:"entity_type"`
	EntityID   pgtype.Text `json:"entity_id"`
	OldValues  []byte      `json:"old_values"`
	NewValues  []byte      `json:"new_values"`
	IpAddress  *netip.Addr `json:"ip_address"`
	UserAgent  pgtype.Text `json:"user_agent"`
}

type CreateCategoryParams

type CreateCategoryParams struct {
	ID       string       `json:"id"`
	TenantID string       `json:"tenant_id"`
	ParentID pgtype.Text  `json:"parent_id"`
	Name     string       `json:"name"`
	Icon     pgtype.Text  `json:"icon"`
	Color    pgtype.Text  `json:"color"`
	Type     CategoryType `json:"type"`
}

type CreateMasterPurchaseParams added in v1.10.0

type CreateMasterPurchaseParams struct {
	ID                   string      `json:"id"`
	TenantID             string      `json:"tenant_id"`
	AccountID            string      `json:"account_id"`
	CategoryID           string      `json:"category_id"`
	UserID               string      `json:"user_id"`
	Description          string      `json:"description"`
	TotalAmountCents     int64       `json:"total_amount_cents"`
	InstallmentCount     int16       `json:"installment_count"`
	ClosingDay           int16       `json:"closing_day"`
	FirstInstallmentDate pgtype.Date `json:"first_installment_date"`
}

type CreateOTPRequestParams

type CreateOTPRequestParams struct {
	ID        string             `json:"id"`
	Email     string             `json:"email"`
	CodeHash  string             `json:"code_hash"`
	Used      bool               `json:"used"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
}

type CreateTenantParams

type CreateTenantParams struct {
	ID   string     `json:"id"`
	Name string     `json:"name"`
	Plan TenantPlan `json:"plan"`
}

type CreateTransactionParams

type CreateTransactionParams struct {
	ID               string             `json:"id"`
	TenantID         string             `json:"tenant_id"`
	AccountID        string             `json:"account_id"`
	CategoryID       string             `json:"category_id"`
	UserID           string             `json:"user_id"`
	MasterPurchaseID pgtype.Text        `json:"master_purchase_id"`
	Description      string             `json:"description"`
	AmountCents      int64              `json:"amount_cents"`
	Type             TransactionType    `json:"type"`
	OccurredAt       pgtype.Timestamptz `json:"occurred_at"`
}

type CreateUserParams

type CreateUserParams struct {
	ID       string   `json:"id"`
	TenantID string   `json:"tenant_id"`
	Email    string   `json:"email"`
	Name     string   `json:"name"`
	Role     UserRole `json:"role"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteMasterPurchaseParams added in v1.10.0

type DeleteMasterPurchaseParams struct {
	ID       string `json:"id"`
	TenantID string `json:"tenant_id"`
}

type GetAccountByIDParams

type GetAccountByIDParams struct {
	TenantID string `json:"tenant_id"`
	ID       string `json:"id"`
}

type GetAssetWithTenantConfigParams added in v1.13.0

type GetAssetWithTenantConfigParams struct {
	TenantID string `json:"tenant_id"`
	AssetID  string `json:"asset_id"`
}

type GetAssetWithTenantConfigRow added in v1.13.0

type GetAssetWithTenantConfigRow struct {
	ID            string             `json:"id"`
	Ticker        string             `json:"ticker"`
	Isin          pgtype.Text        `json:"isin"`
	AssetType     AssetType          `json:"asset_type"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	Name          string             `json:"name"`
	Currency      string             `json:"currency"`
	Details       pgtype.Text        `json:"details"`
	ConfigID      string             `json:"config_id"`
	TenantAddedAt pgtype.Timestamptz `json:"tenant_added_at"`
}

type GetCategoryByIDParams

type GetCategoryByIDParams struct {
	TenantID string `json:"tenant_id"`
	ID       string `json:"id"`
}

type GetMasterPurchaseByIDParams added in v1.10.0

type GetMasterPurchaseByIDParams struct {
	ID       string `json:"id"`
	TenantID string `json:"tenant_id"`
}

type GetTenantAssetConfigByAssetIDParams added in v1.13.0

type GetTenantAssetConfigByAssetIDParams struct {
	TenantID string `json:"tenant_id"`
	AssetID  string `json:"asset_id"`
}

type GetTransactionByIDParams

type GetTransactionByIDParams struct {
	TenantID string `json:"tenant_id"`
	ID       string `json:"id"`
}

type GetUserByIDParams

type GetUserByIDParams struct {
	TenantID string `json:"tenant_id"`
	ID       string `json:"id"`
}

type IncomeType added in v1.13.0

type IncomeType string
const (
	IncomeTypeNone     IncomeType = "none"
	IncomeTypeDividend IncomeType = "dividend"
	IncomeTypeCoupon   IncomeType = "coupon"
	IncomeTypeRent     IncomeType = "rent"
	IncomeTypeInterest IncomeType = "interest"
	IncomeTypeSalary   IncomeType = "salary"
)

func (*IncomeType) Scan added in v1.13.0

func (e *IncomeType) Scan(src interface{}) error

type IncrementPaidInstallmentsParams added in v1.10.0

type IncrementPaidInstallmentsParams struct {
	ID       string `json:"id"`
	TenantID string `json:"tenant_id"`
}

type ListAccountsByUserParams

type ListAccountsByUserParams struct {
	TenantID string `json:"tenant_id"`
	UserID   string `json:"user_id"`
}

type ListAuditLogsByEntityParams

type ListAuditLogsByEntityParams struct {
	TenantID   string      `json:"tenant_id"`
	EntityType string      `json:"entity_type"`
	EntityID   pgtype.Text `json:"entity_id"`
}

type ListAuditLogsByTenantParams

type ListAuditLogsByTenantParams struct {
	TenantID  string `json:"tenant_id"`
	OffsetOff int32  `json:"offset_off"`
	LimitOff  int32  `json:"limit_off"`
}

type ListChildCategoriesParams

type ListChildCategoriesParams struct {
	TenantID string      `json:"tenant_id"`
	ParentID pgtype.Text `json:"parent_id"`
}

type ListMasterPurchasesByAccountParams added in v1.10.0

type ListMasterPurchasesByAccountParams struct {
	TenantID  string `json:"tenant_id"`
	AccountID string `json:"account_id"`
}

type ListPendingMasterPurchasesByClosingDayParams added in v1.10.0

type ListPendingMasterPurchasesByClosingDayParams struct {
	TenantID   string `json:"tenant_id"`
	ClosingDay int16  `json:"closing_day"`
}

type ListTransactionsByTenantParams

type ListTransactionsByTenantParams struct {
	TenantID    string              `json:"tenant_id"`
	AccountID   pgtype.Text         `json:"account_id"`
	CategoryID  pgtype.Text         `json:"category_id"`
	Type        NullTransactionType `json:"type"`
	StartDate   pgtype.Timestamptz  `json:"start_date"`
	EndDate     pgtype.Timestamptz  `json:"end_date"`
	OffsetCount int32               `json:"offset_count"`
	LimitCount  interface{}         `json:"limit_count"`
}

type MasterPurchase

type MasterPurchase struct {
	ID                   string               `json:"id"`
	TenantID             string               `json:"tenant_id"`
	AccountID            string               `json:"account_id"`
	CategoryID           string               `json:"category_id"`
	UserID               string               `json:"user_id"`
	Description          string               `json:"description"`
	Status               MasterPurchaseStatus `json:"status"`
	TotalAmountCents     int64                `json:"total_amount_cents"`
	InstallmentCount     int16                `json:"installment_count"`
	PaidInstallments     int16                `json:"paid_installments"`
	ClosingDay           int16                `json:"closing_day"`
	FirstInstallmentDate pgtype.Date          `json:"first_installment_date"`
	CreatedAt            pgtype.Timestamptz   `json:"created_at"`
	UpdatedAt            pgtype.Timestamptz   `json:"updated_at"`
	DeletedAt            pgtype.Timestamptz   `json:"deleted_at"`
}

type MasterPurchaseStatus added in v1.10.0

type MasterPurchaseStatus string
const (
	MasterPurchaseStatusOpen   MasterPurchaseStatus = "open"
	MasterPurchaseStatusClosed MasterPurchaseStatus = "closed"
)

func (*MasterPurchaseStatus) Scan added in v1.10.0

func (e *MasterPurchaseStatus) Scan(src interface{}) error

type NullAccountType

type NullAccountType struct {
	AccountType AccountType `json:"account_type"`
	Valid       bool        `json:"valid"` // Valid is true if AccountType is not NULL
}

func (*NullAccountType) Scan

func (ns *NullAccountType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullAccountType) Value

func (ns NullAccountType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullAssetType added in v1.13.0

type NullAssetType struct {
	AssetType AssetType `json:"asset_type"`
	Valid     bool      `json:"valid"` // Valid is true if AssetType is not NULL
}

func (*NullAssetType) Scan added in v1.13.0

func (ns *NullAssetType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullAssetType) Value added in v1.13.0

func (ns NullAssetType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullAuditAction

type NullAuditAction struct {
	AuditAction AuditAction `json:"audit_action"`
	Valid       bool        `json:"valid"` // Valid is true if AuditAction is not NULL
}

func (*NullAuditAction) Scan

func (ns *NullAuditAction) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullAuditAction) Value

func (ns NullAuditAction) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullCategoryType

type NullCategoryType struct {
	CategoryType CategoryType `json:"category_type"`
	Valid        bool         `json:"valid"` // Valid is true if CategoryType is not NULL
}

func (*NullCategoryType) Scan

func (ns *NullCategoryType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullCategoryType) Value

func (ns NullCategoryType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullIncomeType added in v1.13.0

type NullIncomeType struct {
	IncomeType IncomeType `json:"income_type"`
	Valid      bool       `json:"valid"` // Valid is true if IncomeType is not NULL
}

func (*NullIncomeType) Scan added in v1.13.0

func (ns *NullIncomeType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullIncomeType) Value added in v1.13.0

func (ns NullIncomeType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullMasterPurchaseStatus added in v1.10.0

type NullMasterPurchaseStatus struct {
	MasterPurchaseStatus MasterPurchaseStatus `json:"master_purchase_status"`
	Valid                bool                 `json:"valid"` // Valid is true if MasterPurchaseStatus is not NULL
}

func (*NullMasterPurchaseStatus) Scan added in v1.10.0

func (ns *NullMasterPurchaseStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullMasterPurchaseStatus) Value added in v1.10.0

Value implements the driver Valuer interface.

type NullReceivableStatus added in v1.13.0

type NullReceivableStatus struct {
	ReceivableStatus ReceivableStatus `json:"receivable_status"`
	Valid            bool             `json:"valid"` // Valid is true if ReceivableStatus is not NULL
}

func (*NullReceivableStatus) Scan added in v1.13.0

func (ns *NullReceivableStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullReceivableStatus) Value added in v1.13.0

func (ns NullReceivableStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullTenantPlan

type NullTenantPlan struct {
	TenantPlan TenantPlan `json:"tenant_plan"`
	Valid      bool       `json:"valid"` // Valid is true if TenantPlan is not NULL
}

func (*NullTenantPlan) Scan

func (ns *NullTenantPlan) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTenantPlan) Value

func (ns NullTenantPlan) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullTransactionType

type NullTransactionType struct {
	TransactionType TransactionType `json:"transaction_type"`
	Valid           bool            `json:"valid"` // Valid is true if TransactionType is not NULL
}

func (*NullTransactionType) Scan

func (ns *NullTransactionType) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullTransactionType) Value

func (ns NullTransactionType) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type NullUserRole

type NullUserRole struct {
	UserRole UserRole `json:"user_role"`
	Valid    bool     `json:"valid"` // Valid is true if UserRole is not NULL
}

func (*NullUserRole) Scan

func (ns *NullUserRole) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullUserRole) Value

func (ns NullUserRole) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type OtpRequest

type OtpRequest struct {
	ID        string             `json:"id"`
	Email     string             `json:"email"`
	CodeHash  string             `json:"code_hash"`
	Used      bool               `json:"used"`
	ExpiresAt pgtype.Timestamptz `json:"expires_at"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
}

type PortfolioSnapshot added in v1.13.0

type PortfolioSnapshot struct {
	ID               string             `json:"id"`
	TenantID         string             `json:"tenant_id"`
	SnapshotDate     pgtype.Date        `json:"snapshot_date"`
	TotalValueCents  int64              `json:"total_value_cents"`
	TotalIncomeCents int64              `json:"total_income_cents"`
	Currency         string             `json:"currency"`
	Details          []byte             `json:"details"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
}

type Position added in v1.13.0

type Position struct {
	ID                 string             `json:"id"`
	TenantID           string             `json:"tenant_id"`
	AssetID            string             `json:"asset_id"`
	AccountID          string             `json:"account_id"`
	Quantity           pgtype.Numeric     `json:"quantity"`
	AvgCostCents       int64              `json:"avg_cost_cents"`
	LastPriceCents     int64              `json:"last_price_cents"`
	Currency           string             `json:"currency"`
	PurchasedAt        pgtype.Timestamptz `json:"purchased_at"`
	IncomeType         IncomeType         `json:"income_type"`
	IncomeIntervalDays pgtype.Int4        `json:"income_interval_days"`
	IncomeAmountCents  pgtype.Int8        `json:"income_amount_cents"`
	IncomeRateBps      pgtype.Int4        `json:"income_rate_bps"`
	NextIncomeAt       pgtype.Timestamptz `json:"next_income_at"`
	MaturityAt         pgtype.Timestamptz `json:"maturity_at"`
	CreatedAt          pgtype.Timestamptz `json:"created_at"`
	UpdatedAt          pgtype.Timestamptz `json:"updated_at"`
	DeletedAt          pgtype.Timestamptz `json:"deleted_at"`
}

type PositionIncomeEvent added in v1.13.0

type PositionIncomeEvent struct {
	ID          string             `json:"id"`
	TenantID    string             `json:"tenant_id"`
	PositionID  string             `json:"position_id"`
	IncomeType  IncomeType         `json:"income_type"`
	AmountCents int64              `json:"amount_cents"`
	Currency    string             `json:"currency"`
	EventDate   pgtype.Date        `json:"event_date"`
	Status      ReceivableStatus   `json:"status"`
	RealizedAt  pgtype.Timestamptz `json:"realized_at"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
	UpdatedAt   pgtype.Timestamptz `json:"updated_at"`
}

type PositionSnapshot added in v1.13.0

type PositionSnapshot struct {
	ID             string             `json:"id"`
	TenantID       string             `json:"tenant_id"`
	PositionID     string             `json:"position_id"`
	SnapshotDate   pgtype.Date        `json:"snapshot_date"`
	Quantity       pgtype.Numeric     `json:"quantity"`
	AvgCostCents   int64              `json:"avg_cost_cents"`
	LastPriceCents int64              `json:"last_price_cents"`
	Currency       string             `json:"currency"`
	CreatedAt      pgtype.Timestamptz `json:"created_at"`
}

type Querier

type Querier interface {
	AdminForceDeleteUser(ctx context.Context, id string) error
	AdminGetTenantByID(ctx context.Context, id string) (Tenant, error)
	AdminGetUserByID(ctx context.Context, id string) (User, error)
	AdminHardDeleteTenant(ctx context.Context, id string) error
	AdminListAllAuditLogs(ctx context.Context, arg AdminListAllAuditLogsParams) ([]AuditLog, error)
	AdminListAllTenants(ctx context.Context, withDeleted bool) ([]Tenant, error)
	AdminListAllUsers(ctx context.Context) ([]User, error)
	AdminRestoreTenant(ctx context.Context, id string) error
	AdminSuspendTenant(ctx context.Context, id string) error
	AdminUpdateTenantPlan(ctx context.Context, arg AdminUpdateTenantPlanParams) (Tenant, error)
	CreateAccount(ctx context.Context, arg CreateAccountParams) (Account, error)
	CreateAsset(ctx context.Context, arg CreateAssetParams) (Asset, error)
	CreateAuditLog(ctx context.Context, arg CreateAuditLogParams) (AuditLog, error)
	CreateCategory(ctx context.Context, arg CreateCategoryParams) (Category, error)
	CreateMasterPurchase(ctx context.Context, arg CreateMasterPurchaseParams) (MasterPurchase, error)
	CreateOTPRequest(ctx context.Context, arg CreateOTPRequestParams) (OtpRequest, error)
	CreateTenant(ctx context.Context, arg CreateTenantParams) (Tenant, error)
	CreateTransaction(ctx context.Context, arg CreateTransactionParams) (Transaction, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	DeleteAsset(ctx context.Context, id string) error
	DeleteExpiredOTPs(ctx context.Context) error
	DeleteMasterPurchase(ctx context.Context, arg DeleteMasterPurchaseParams) error
	GetAccountByID(ctx context.Context, arg GetAccountByIDParams) (Account, error)
	GetActiveOTPByEmail(ctx context.Context, email string) (OtpRequest, error)
	GetAssetByID(ctx context.Context, id string) (Asset, error)
	GetAssetByTicker(ctx context.Context, ticker string) (Asset, error)
	// Returns the global asset with tenant overrides applied via COALESCE.
	// Use this query in all asset-display contexts (ADR §2.7).
	GetAssetWithTenantConfig(ctx context.Context, arg GetAssetWithTenantConfigParams) (GetAssetWithTenantConfigRow, error)
	GetCategoryByID(ctx context.Context, arg GetCategoryByIDParams) (Category, error)
	GetMasterPurchaseByID(ctx context.Context, arg GetMasterPurchaseByIDParams) (MasterPurchase, error)
	GetTenantAssetConfigByAssetID(ctx context.Context, arg GetTenantAssetConfigByAssetIDParams) (TenantAssetConfig, error)
	GetTenantByID(ctx context.Context, id string) (Tenant, error)
	GetTransactionByID(ctx context.Context, arg GetTransactionByIDParams) (Transaction, error)
	GetUserByEmail(ctx context.Context, email string) (User, error)
	GetUserByID(ctx context.Context, arg GetUserByIDParams) (User, error)
	IncrementPaidInstallments(ctx context.Context, arg IncrementPaidInstallmentsParams) (MasterPurchase, error)
	ListAccountsByTenant(ctx context.Context, tenantID string) ([]Account, error)
	ListAccountsByUser(ctx context.Context, arg ListAccountsByUserParams) ([]Account, error)
	ListAssets(ctx context.Context) ([]Asset, error)
	ListAuditLogsByEntity(ctx context.Context, arg ListAuditLogsByEntityParams) ([]AuditLog, error)
	ListAuditLogsByTenant(ctx context.Context, arg ListAuditLogsByTenantParams) ([]AuditLog, error)
	ListCategoriesByTenant(ctx context.Context, tenantID string) ([]Category, error)
	ListChildCategories(ctx context.Context, arg ListChildCategoriesParams) ([]Category, error)
	ListMasterPurchasesByAccount(ctx context.Context, arg ListMasterPurchasesByAccountParams) ([]MasterPurchase, error)
	ListMasterPurchasesByTenant(ctx context.Context, tenantID string) ([]MasterPurchase, error)
	ListPendingMasterPurchasesByClosingDay(ctx context.Context, arg ListPendingMasterPurchasesByClosingDayParams) ([]MasterPurchase, error)
	ListTenantAssetConfigs(ctx context.Context, tenantID string) ([]TenantAssetConfig, error)
	ListTenants(ctx context.Context) ([]Tenant, error)
	ListTransactionsByTenant(ctx context.Context, arg ListTransactionsByTenantParams) ([]Transaction, error)
	ListUsersByTenant(ctx context.Context, tenantID string) ([]User, error)
	MarkOTPUsed(ctx context.Context, id string) error
	SoftDeleteAccount(ctx context.Context, arg SoftDeleteAccountParams) error
	SoftDeleteCategory(ctx context.Context, arg SoftDeleteCategoryParams) error
	SoftDeleteTenant(ctx context.Context, id string) error
	SoftDeleteTenantAssetConfig(ctx context.Context, arg SoftDeleteTenantAssetConfigParams) error
	SoftDeleteTransaction(ctx context.Context, arg SoftDeleteTransactionParams) error
	SoftDeleteUser(ctx context.Context, arg SoftDeleteUserParams) error
	UpdateAccount(ctx context.Context, arg UpdateAccountParams) (Account, error)
	UpdateAccountBalance(ctx context.Context, arg UpdateAccountBalanceParams) error
	UpdateCategory(ctx context.Context, arg UpdateCategoryParams) (Category, error)
	UpdateMasterPurchase(ctx context.Context, arg UpdateMasterPurchaseParams) (MasterPurchase, error)
	UpdateTenant(ctx context.Context, arg UpdateTenantParams) (Tenant, error)
	UpdateTransaction(ctx context.Context, arg UpdateTransactionParams) (Transaction, error)
	UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
	UpdateUserLastLogin(ctx context.Context, id string) error
	UpsertTenantAssetConfig(ctx context.Context, arg UpsertTenantAssetConfigParams) (TenantAssetConfig, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AdminForceDeleteUser

func (q *Queries) AdminForceDeleteUser(ctx context.Context, id string) error

func (*Queries) AdminGetTenantByID

func (q *Queries) AdminGetTenantByID(ctx context.Context, id string) (Tenant, error)

func (*Queries) AdminGetUserByID

func (q *Queries) AdminGetUserByID(ctx context.Context, id string) (User, error)

func (*Queries) AdminHardDeleteTenant

func (q *Queries) AdminHardDeleteTenant(ctx context.Context, id string) error

func (*Queries) AdminListAllAuditLogs

func (q *Queries) AdminListAllAuditLogs(ctx context.Context, arg AdminListAllAuditLogsParams) ([]AuditLog, error)

func (*Queries) AdminListAllTenants

func (q *Queries) AdminListAllTenants(ctx context.Context, withDeleted bool) ([]Tenant, error)

func (*Queries) AdminListAllUsers

func (q *Queries) AdminListAllUsers(ctx context.Context) ([]User, error)

func (*Queries) AdminRestoreTenant

func (q *Queries) AdminRestoreTenant(ctx context.Context, id string) error

func (*Queries) AdminSuspendTenant

func (q *Queries) AdminSuspendTenant(ctx context.Context, id string) error

func (*Queries) AdminUpdateTenantPlan

func (q *Queries) AdminUpdateTenantPlan(ctx context.Context, arg AdminUpdateTenantPlanParams) (Tenant, error)

func (*Queries) CreateAccount

func (q *Queries) CreateAccount(ctx context.Context, arg CreateAccountParams) (Account, error)

func (*Queries) CreateAsset added in v1.13.0

func (q *Queries) CreateAsset(ctx context.Context, arg CreateAssetParams) (Asset, error)

func (*Queries) CreateAuditLog

func (q *Queries) CreateAuditLog(ctx context.Context, arg CreateAuditLogParams) (AuditLog, error)

func (*Queries) CreateCategory

func (q *Queries) CreateCategory(ctx context.Context, arg CreateCategoryParams) (Category, error)

func (*Queries) CreateMasterPurchase added in v1.10.0

func (q *Queries) CreateMasterPurchase(ctx context.Context, arg CreateMasterPurchaseParams) (MasterPurchase, error)

func (*Queries) CreateOTPRequest

func (q *Queries) CreateOTPRequest(ctx context.Context, arg CreateOTPRequestParams) (OtpRequest, error)

func (*Queries) CreateTenant

func (q *Queries) CreateTenant(ctx context.Context, arg CreateTenantParams) (Tenant, error)

func (*Queries) CreateTransaction

func (q *Queries) CreateTransaction(ctx context.Context, arg CreateTransactionParams) (Transaction, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) DeleteAsset added in v1.13.0

func (q *Queries) DeleteAsset(ctx context.Context, id string) error

func (*Queries) DeleteExpiredOTPs

func (q *Queries) DeleteExpiredOTPs(ctx context.Context) error

func (*Queries) DeleteMasterPurchase added in v1.10.0

func (q *Queries) DeleteMasterPurchase(ctx context.Context, arg DeleteMasterPurchaseParams) error

func (*Queries) GetAccountByID

func (q *Queries) GetAccountByID(ctx context.Context, arg GetAccountByIDParams) (Account, error)

func (*Queries) GetActiveOTPByEmail

func (q *Queries) GetActiveOTPByEmail(ctx context.Context, email string) (OtpRequest, error)

func (*Queries) GetAssetByID added in v1.13.0

func (q *Queries) GetAssetByID(ctx context.Context, id string) (Asset, error)

func (*Queries) GetAssetByTicker added in v1.13.0

func (q *Queries) GetAssetByTicker(ctx context.Context, ticker string) (Asset, error)

func (*Queries) GetAssetWithTenantConfig added in v1.13.0

Returns the global asset with tenant overrides applied via COALESCE. Use this query in all asset-display contexts (ADR §2.7).

func (*Queries) GetCategoryByID

func (q *Queries) GetCategoryByID(ctx context.Context, arg GetCategoryByIDParams) (Category, error)

func (*Queries) GetMasterPurchaseByID added in v1.10.0

func (q *Queries) GetMasterPurchaseByID(ctx context.Context, arg GetMasterPurchaseByIDParams) (MasterPurchase, error)

func (*Queries) GetTenantAssetConfigByAssetID added in v1.13.0

func (q *Queries) GetTenantAssetConfigByAssetID(ctx context.Context, arg GetTenantAssetConfigByAssetIDParams) (TenantAssetConfig, error)

func (*Queries) GetTenantByID

func (q *Queries) GetTenantByID(ctx context.Context, id string) (Tenant, error)

func (*Queries) GetTransactionByID

func (q *Queries) GetTransactionByID(ctx context.Context, arg GetTransactionByIDParams) (Transaction, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error)

func (*Queries) GetUserByID

func (q *Queries) GetUserByID(ctx context.Context, arg GetUserByIDParams) (User, error)

func (*Queries) IncrementPaidInstallments added in v1.10.0

func (q *Queries) IncrementPaidInstallments(ctx context.Context, arg IncrementPaidInstallmentsParams) (MasterPurchase, error)

func (*Queries) ListAccountsByTenant

func (q *Queries) ListAccountsByTenant(ctx context.Context, tenantID string) ([]Account, error)

func (*Queries) ListAccountsByUser

func (q *Queries) ListAccountsByUser(ctx context.Context, arg ListAccountsByUserParams) ([]Account, error)

func (*Queries) ListAssets added in v1.13.0

func (q *Queries) ListAssets(ctx context.Context) ([]Asset, error)

func (*Queries) ListAuditLogsByEntity

func (q *Queries) ListAuditLogsByEntity(ctx context.Context, arg ListAuditLogsByEntityParams) ([]AuditLog, error)

func (*Queries) ListAuditLogsByTenant

func (q *Queries) ListAuditLogsByTenant(ctx context.Context, arg ListAuditLogsByTenantParams) ([]AuditLog, error)

func (*Queries) ListCategoriesByTenant

func (q *Queries) ListCategoriesByTenant(ctx context.Context, tenantID string) ([]Category, error)

func (*Queries) ListChildCategories

func (q *Queries) ListChildCategories(ctx context.Context, arg ListChildCategoriesParams) ([]Category, error)

func (*Queries) ListMasterPurchasesByAccount added in v1.10.0

func (q *Queries) ListMasterPurchasesByAccount(ctx context.Context, arg ListMasterPurchasesByAccountParams) ([]MasterPurchase, error)

func (*Queries) ListMasterPurchasesByTenant added in v1.10.0

func (q *Queries) ListMasterPurchasesByTenant(ctx context.Context, tenantID string) ([]MasterPurchase, error)

func (*Queries) ListPendingMasterPurchasesByClosingDay added in v1.10.0

func (q *Queries) ListPendingMasterPurchasesByClosingDay(ctx context.Context, arg ListPendingMasterPurchasesByClosingDayParams) ([]MasterPurchase, error)

func (*Queries) ListTenantAssetConfigs added in v1.13.0

func (q *Queries) ListTenantAssetConfigs(ctx context.Context, tenantID string) ([]TenantAssetConfig, error)

func (*Queries) ListTenants

func (q *Queries) ListTenants(ctx context.Context) ([]Tenant, error)

func (*Queries) ListTransactionsByTenant

func (q *Queries) ListTransactionsByTenant(ctx context.Context, arg ListTransactionsByTenantParams) ([]Transaction, error)

func (*Queries) ListUsersByTenant

func (q *Queries) ListUsersByTenant(ctx context.Context, tenantID string) ([]User, error)

func (*Queries) MarkOTPUsed

func (q *Queries) MarkOTPUsed(ctx context.Context, id string) error

func (*Queries) SoftDeleteAccount

func (q *Queries) SoftDeleteAccount(ctx context.Context, arg SoftDeleteAccountParams) error

func (*Queries) SoftDeleteCategory

func (q *Queries) SoftDeleteCategory(ctx context.Context, arg SoftDeleteCategoryParams) error

func (*Queries) SoftDeleteTenant

func (q *Queries) SoftDeleteTenant(ctx context.Context, id string) error

func (*Queries) SoftDeleteTenantAssetConfig added in v1.13.0

func (q *Queries) SoftDeleteTenantAssetConfig(ctx context.Context, arg SoftDeleteTenantAssetConfigParams) error

func (*Queries) SoftDeleteTransaction

func (q *Queries) SoftDeleteTransaction(ctx context.Context, arg SoftDeleteTransactionParams) error

func (*Queries) SoftDeleteUser

func (q *Queries) SoftDeleteUser(ctx context.Context, arg SoftDeleteUserParams) error

func (*Queries) UpdateAccount

func (q *Queries) UpdateAccount(ctx context.Context, arg UpdateAccountParams) (Account, error)

func (*Queries) UpdateAccountBalance

func (q *Queries) UpdateAccountBalance(ctx context.Context, arg UpdateAccountBalanceParams) error

func (*Queries) UpdateCategory

func (q *Queries) UpdateCategory(ctx context.Context, arg UpdateCategoryParams) (Category, error)

func (*Queries) UpdateMasterPurchase added in v1.10.0

func (q *Queries) UpdateMasterPurchase(ctx context.Context, arg UpdateMasterPurchaseParams) (MasterPurchase, error)

func (*Queries) UpdateTenant

func (q *Queries) UpdateTenant(ctx context.Context, arg UpdateTenantParams) (Tenant, error)

func (*Queries) UpdateTransaction

func (q *Queries) UpdateTransaction(ctx context.Context, arg UpdateTransactionParams) (Transaction, error)

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)

func (*Queries) UpdateUserLastLogin

func (q *Queries) UpdateUserLastLogin(ctx context.Context, id string) error

func (*Queries) UpsertTenantAssetConfig added in v1.13.0

func (q *Queries) UpsertTenantAssetConfig(ctx context.Context, arg UpsertTenantAssetConfigParams) (TenantAssetConfig, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type ReceivableStatus added in v1.13.0

type ReceivableStatus string
const (
	ReceivableStatusPending   ReceivableStatus = "pending"
	ReceivableStatusReceived  ReceivableStatus = "received"
	ReceivableStatusCancelled ReceivableStatus = "cancelled"
)

func (*ReceivableStatus) Scan added in v1.13.0

func (e *ReceivableStatus) Scan(src interface{}) error

type SoftDeleteAccountParams

type SoftDeleteAccountParams struct {
	TenantID string `json:"tenant_id"`
	ID       string `json:"id"`
}

type SoftDeleteCategoryParams

type SoftDeleteCategoryParams struct {
	TenantID string `json:"tenant_id"`
	ID       string `json:"id"`
}

type SoftDeleteTenantAssetConfigParams added in v1.13.0

type SoftDeleteTenantAssetConfigParams struct {
	TenantID string `json:"tenant_id"`
	AssetID  string `json:"asset_id"`
}

type SoftDeleteTransactionParams

type SoftDeleteTransactionParams struct {
	TenantID string `json:"tenant_id"`
	ID       string `json:"id"`
}

type SoftDeleteUserParams

type SoftDeleteUserParams struct {
	TenantID string `json:"tenant_id"`
	ID       string `json:"id"`
}

type Tenant

type Tenant struct {
	ID        string             `json:"id"`
	Name      string             `json:"name"`
	Plan      TenantPlan         `json:"plan"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
	DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}

type TenantAssetConfig added in v1.13.0

type TenantAssetConfig struct {
	ID        string             `json:"id"`
	TenantID  string             `json:"tenant_id"`
	AssetID   string             `json:"asset_id"`
	Name      pgtype.Text        `json:"name"`
	Currency  pgtype.Text        `json:"currency"`
	Details   pgtype.Text        `json:"details"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
	DeletedAt pgtype.Timestamptz `json:"deleted_at"`
}

type TenantPlan

type TenantPlan string
const (
	TenantPlanFree    TenantPlan = "free"
	TenantPlanBasic   TenantPlan = "basic"
	TenantPlanPremium TenantPlan = "premium"
)

func (*TenantPlan) Scan

func (e *TenantPlan) Scan(src interface{}) error

type Transaction

type Transaction struct {
	ID               string             `json:"id"`
	TenantID         string             `json:"tenant_id"`
	AccountID        string             `json:"account_id"`
	CategoryID       string             `json:"category_id"`
	UserID           string             `json:"user_id"`
	MasterPurchaseID pgtype.Text        `json:"master_purchase_id"`
	Description      string             `json:"description"`
	AmountCents      int64              `json:"amount_cents"`
	Type             TransactionType    `json:"type"`
	OccurredAt       pgtype.Timestamptz `json:"occurred_at"`
	CreatedAt        pgtype.Timestamptz `json:"created_at"`
	UpdatedAt        pgtype.Timestamptz `json:"updated_at"`
	DeletedAt        pgtype.Timestamptz `json:"deleted_at"`
}

type TransactionType

type TransactionType string
const (
	TransactionTypeIncome   TransactionType = "income"
	TransactionTypeExpense  TransactionType = "expense"
	TransactionTypeTransfer TransactionType = "transfer"
)

func (*TransactionType) Scan

func (e *TransactionType) Scan(src interface{}) error

type UpdateAccountBalanceParams

type UpdateAccountBalanceParams struct {
	TenantID     string `json:"tenant_id"`
	ID           string `json:"id"`
	BalanceCents int64  `json:"balance_cents"`
}

type UpdateAccountParams

type UpdateAccountParams struct {
	TenantID string      `json:"tenant_id"`
	ID       string      `json:"id"`
	Name     string      `json:"name"`
	Type     AccountType `json:"type"`
	Currency string      `json:"currency"`
}

type UpdateCategoryParams

type UpdateCategoryParams struct {
	ParentID pgtype.Text  `json:"parent_id"`
	Name     string       `json:"name"`
	Icon     pgtype.Text  `json:"icon"`
	Color    pgtype.Text  `json:"color"`
	Type     CategoryType `json:"type"`
	TenantID string       `json:"tenant_id"`
	ID       string       `json:"id"`
}

type UpdateMasterPurchaseParams added in v1.10.0

type UpdateMasterPurchaseParams struct {
	ID               string                   `json:"id"`
	TenantID         string                   `json:"tenant_id"`
	CategoryID       interface{}              `json:"category_id"`
	Description      pgtype.Text              `json:"description"`
	Status           NullMasterPurchaseStatus `json:"status"`
	PaidInstallments pgtype.Int2              `json:"paid_installments"`
}

type UpdateTenantParams

type UpdateTenantParams struct {
	ID   string     `json:"id"`
	Name string     `json:"name"`
	Plan TenantPlan `json:"plan"`
}

type UpdateTransactionParams

type UpdateTransactionParams struct {
	TenantID    string             `json:"tenant_id"`
	ID          string             `json:"id"`
	AccountID   string             `json:"account_id"`
	CategoryID  string             `json:"category_id"`
	Description string             `json:"description"`
	AmountCents int64              `json:"amount_cents"`
	Type        TransactionType    `json:"type"`
	OccurredAt  pgtype.Timestamptz `json:"occurred_at"`
}

type UpdateUserParams

type UpdateUserParams struct {
	TenantID string   `json:"tenant_id"`
	ID       string   `json:"id"`
	Email    string   `json:"email"`
	Name     string   `json:"name"`
	Role     UserRole `json:"role"`
}

type UpsertTenantAssetConfigParams added in v1.13.0

type UpsertTenantAssetConfigParams struct {
	ID       string      `json:"id"`
	TenantID string      `json:"tenant_id"`
	AssetID  string      `json:"asset_id"`
	Name     pgtype.Text `json:"name"`
	Currency pgtype.Text `json:"currency"`
	Details  pgtype.Text `json:"details"`
}

type User

type User struct {
	ID          string             `json:"id"`
	TenantID    string             `json:"tenant_id"`
	Email       string             `json:"email"`
	Name        string             `json:"name"`
	Role        UserRole           `json:"role"`
	LastLoginAt pgtype.Timestamptz `json:"last_login_at"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
	UpdatedAt   pgtype.Timestamptz `json:"updated_at"`
	DeletedAt   pgtype.Timestamptz `json:"deleted_at"`
}

type UserRole

type UserRole string
const (
	UserRoleSysadmin UserRole = "sysadmin"
	UserRoleAdmin    UserRole = "admin"
	UserRoleMember   UserRole = "member"
)

func (*UserRole) Scan

func (e *UserRole) Scan(src interface{}) error

Jump to

Keyboard shortcuts

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