v1

package
v0.0.0-...-dcafc8e Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CreateAccountAndLedger = gormigrate.Migration{
	ID: "2024-09-17:create-accounts-and-ledgers",
	Migrate: func(tx *gorm.DB) error {
		return tx.AutoMigrate(&Account{}, &Ledger{})
	},
	Rollback: func(tx *gorm.DB) error {
		return tx.Migrator().DropTable(&Ledger{}, &Account{})
	},
}

CreateAccountAndLedger defines the migration, which creates the accounts and ledgers.

Functions

This section is empty.

Types

type Account

type Account struct {
	ID        string `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	CreatedAt time.Time
	UpdatedAt time.Time
	Name      string          `gorm:"type:varchar(255);not null"`
	Status    string          `gorm:"type:varchar(20);not null"`
	Currency  string          `gorm:"type:varchar(3);not null"`
	Balance   decimal.Decimal `gorm:"type:decimal(20,2);not null"`

	Ledgers []Ledger
}

Account represents the database model for an account

type Ledger

type Ledger struct {
	ID           string `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
	CreatedAt    time.Time
	UpdatedAt    time.Time
	AccountID    string          `gorm:"type:uuid;not null"`
	Date         time.Time       `gorm:"not null"`
	Type         string          `gorm:"type:varchar(20);not null"`
	Amount       decimal.Decimal `gorm:"type:decimal(20,2);not null"`
	Note         string          `gorm:"type:text"`
	IsAdjustment bool            `gorm:"not null"`
	AdjustedFrom *string         `gorm:"type:uuid"`
	IsVoided     bool            `gorm:"not null"`
	VoidedAt     *time.Time
}

Ledger represents the database model for a ledger entry

Jump to

Keyboard shortcuts

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