database

package
v0.2.36 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbTypeMaster   = DbType(1)
	DbTypeReadonly = DbType(2)
)
View Source
const (
	SystemConfigKeyJwtPrivateKey = "jwt_private_key"
)

Variables

This section is empty.

Functions

func FromContext

func FromContext(ctx context.Context, defaultInstance *gorm.DB) *gorm.DB

func GetDb

func GetDb(t DbType) *gorm.DB

func GetDbWithContext

func GetDbWithContext(ctx context.Context, t DbType) *gorm.DB

func InitDb

func InitDb() error

func WithContext

func WithContext(ctx context.Context, db *gorm.DB) context.Context

func WithContextType

func WithContextType(ctx context.Context, dbType DbType) context.Context

Types

type Account

type Account struct {
	ID int32

	Name     string
	Currency string // code

	CurrentBalance decimal.Decimal
	Extra          map[string]string `gorm:"serializer:json"`
	Flags          AccountFlag

	LastUpdatedAt time.Time
	CreatedAt     time.Time

	DeletedAt        gorm.DeletedAt
	Type             gomoneypbv1.AccountType
	Note             string
	AccountNumber    string
	Iban             string
	LiabilityPercent decimal.NullDecimal
	DisplayOrder     *int32

	FirstTransactionAt *time.Time
}

func (*Account) IsDefault added in v0.2.0

func (a *Account) IsDefault() bool

type AccountFlag added in v0.2.0

type AccountFlag = int64
const (
	AccountFlagIsDefault AccountFlag = 1 << 0
)

type AppConfig added in v0.2.25

type AppConfig struct {
	ID        string
	Value     string
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt
}

func (AppConfig) TableName added in v0.2.25

func (AppConfig) TableName() string

type Category

type Category struct {
	ID        int32 `gorm:"primaryKey"`
	Name      string
	CreatedAt time.Time

	DeletedAt gorm.DeletedAt
}

func (*Category) TableName

func (*Category) TableName() string

type Currency

type Currency struct {
	ID   string // Currency ID
	Rate decimal.Decimal

	IsActive bool

	DecimalPlaces int32
	UpdatedAt     time.Time
	DeletedAt     gorm.DeletedAt
}

func (*Currency) TableName

func (c *Currency) TableName() string

type DailyStat

type DailyStat struct {
	AccountID int32     `gorm:"primaryKey"`
	Date      time.Time `gorm:"primaryKey"`

	Amount decimal.Decimal
}

func (*DailyStat) TableName

func (*DailyStat) TableName() string

type DbType

type DbType int

type DoubleEntry added in v0.2.0

type DoubleEntry struct {
	ID            int64
	TransactionID int64
	IsDebit       bool

	AmountInBaseCurrency decimal.Decimal
	BaseCurrency         string

	AccountID int32

	TransactionDate time.Time
	CreatedAt       time.Time
	DeletedAt       gorm.DeletedAt
}

type ImportDeduplication

type ImportDeduplication struct {
	ImportSource  importv1.ImportSource
	Key           string
	CreatedAt     time.Time
	TransactionID int64
}

func (*ImportDeduplication) TableName

func (*ImportDeduplication) TableName() string

type JtiRevocation added in v0.2.26

type JtiRevocation struct {
	ID        string    `gorm:"type:text;primaryKey"`
	ExpiresAt time.Time `gorm:"type:timestamp;not null"`
}

func (JtiRevocation) TableName added in v0.2.26

func (JtiRevocation) TableName() string

type MonthlyStat

type MonthlyStat struct {
	AccountID int32     `gorm:"primaryKey"`
	Date      time.Time `gorm:"primaryKey"`

	Balance decimal.Decimal
}

type Rule

type Rule struct {
	ID              int32
	Title           string
	Script          string
	InterpreterType gomoneypbv1.RuleInterpreterType
	SortOrder       int32
	CreatedAt       time.Time
	UpdatedAt       time.Time
	Enabled         bool
	IsFinalRule     bool
	DeletedAt       gorm.DeletedAt
	GroupName       string
}

type ScheduleRule added in v0.1.1

type ScheduleRule struct {
	ID              int32
	Title           string
	Script          string
	InterpreterType gomoneypbv1.RuleInterpreterType
	CreatedAt       time.Time
	UpdatedAt       time.Time
	Enabled         bool
	DeletedAt       gorm.DeletedAt
	CronExpression  string
	LastRunAt       *time.Time
	GroupName       string
}

type ServiceToken added in v0.2.26

type ServiceToken struct {
	ID string `gorm:"type:uuid;primaryKey"`

	Name      string         `gorm:"type:text;not null"`
	ExpiresAt time.Time      `gorm:"type:timestamp;not null"`
	DeletedAt gorm.DeletedAt `gorm:"index"`
	CreatedAt time.Time      `gorm:"type:timestamp;not null"`
}

type SystemConfig added in v0.2.29

type SystemConfig struct {
	ID        string
	Value     string
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (SystemConfig) TableName added in v0.2.29

func (SystemConfig) TableName() string

type SystemConfigRepository added in v0.2.29

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

func NewSystemConfigRepository added in v0.2.29

func NewSystemConfigRepository(db *gorm.DB) *SystemConfigRepository

func (*SystemConfigRepository) Get added in v0.2.29

func (*SystemConfigRepository) Set added in v0.2.29

func (r *SystemConfigRepository) Set(ctx context.Context, key, value string) error

type Tag

type Tag struct {
	ID        int32
	Name      string
	Color     string
	Icon      string
	DeletedAt gorm.DeletedAt
	CreatedAt time.Time
}

func (Tag) TableName

func (Tag) TableName() string

type Transaction

type Transaction struct {
	ID int64

	SourceAmount               decimal.NullDecimal
	SourceCurrency             string
	SourceAmountInBaseCurrency decimal.NullDecimal

	FxSourceAmount   decimal.NullDecimal // withdrawals only
	FxSourceCurrency string              // withdrawals only

	DestinationAmount               decimal.NullDecimal
	DestinationCurrency             string
	DestinationAmountInBaseCurrency decimal.NullDecimal

	SourceAccountID      int32
	DestinationAccountID int32

	TagIDs pq.Int32Array `gorm:"type:integer[]"`

	CreatedAt time.Time
	UpdatedAt time.Time

	Notes string
	Extra map[string]string `gorm:"serializer:json"`

	TransactionDateTime time.Time `gorm:"type:timestamp"`
	TransactionDateOnly time.Time `gorm:"type:date"`

	TransactionType gomoneypbv1.TransactionType `gorm:"type:int"`
	Flags           TransactionFlags            `gorm:"type:bigint"`

	VoidedByTransactionID *int64
	Title                 string

	DeletedAt gorm.DeletedAt

	ReferenceNumber          *string
	InternalReferenceNumbers pq.StringArray `gorm:"type:text[]"`
	CategoryID               *int32
}

type TransactionFlags

type TransactionFlags int64

type User

type User struct {
	ID       int32
	Login    string
	Password string

	CreatedAt time.Time
	DeletedAt gorm.DeletedAt
}

Jump to

Keyboard shortcuts

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