Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DB *gorm.DB
DB is the database used by the backend
Functions ¶
func ConnectDatabase ¶ added in v0.1.0
func ConnectDatabase() error
ConnectDatabase connects to the database DB
Types ¶
type Account ¶ added in v0.1.0
type Account struct {
Model
Name string `json:"name,omitempty"`
BudgetID int `json:"budgetId"`
Budget Budget `json:"-"`
OnBudget bool `json:"onBudget"`
Visible bool `json:"visible"`
Note string `json:"note,omitempty"`
Balance decimal.Decimal `json:"balance" gorm:"-"`
}
Account represents an asset account, e.g. a bank account
func (Account) Transactions ¶ added in v0.1.0
func (a Account) Transactions() []Transaction
Transactions returns all transactions for this account
func (Account) WithBalance ¶ added in v0.1.0
WithBalance returns a pointer to the account with the balance calculated
type Allocation ¶ added in v0.1.0
type Allocation struct {
Model
Month uint8 `json:"month" gorm:"uniqueIndex:year_month;check:month >= 1 AND month <= 12"`
Year uint `json:"year" gorm:"uniqueIndex:year_month"`
Amount decimal.Decimal `json:"amount" gorm:"type:DECIMAL(20,8)"`
EnvelopeID int `json:"envelopeId,omitempty"`
Envelope Envelope `json:"-"`
}
Allocation represents the allocation of money to an Envelope for a specific month
type Budget ¶
type Budget struct {
Model
Name string `json:"name,omitempty"`
Note string `json:"note,omitempty"`
}
Budget represents a budget
A budget is the highest level of organization in Envelope Zero, all other resources reference it directly or transitively.
type Category ¶ added in v0.1.0
type Category struct {
Model
Name string `json:"name,omitempty"`
BudgetID int `json:"budgetId"`
Budget Budget `json:"-"`
Note string `json:"note,omitempty"`
}
Category represents a category of envelopes
type Envelope ¶ added in v0.1.0
type Envelope struct {
Model
Name string `json:"name,omitempty"`
CategoryID int `json:"categoryId"`
Category Category `json:"-"`
Note string `json:"note,omitempty"`
}
Envelope represents an envelope in your budget
type Model ¶ added in v0.1.0
type Model struct {
ID uint `json:"id"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
DeletedAt *gorm.DeletedAt `json:"deletedAt,omitempty" gorm:"index"`
}
Model is the base model for all other models in Envelope Zero
type Transaction ¶ added in v0.1.0
type Transaction struct {
Model
Date *time.Time `json:"date,omitempty"`
Amount decimal.Decimal `json:"amount" gorm:"type:DECIMAL(20,8)"`
Note string `json:"note,omitempty"`
BudgetID int `json:"budgetId,omitempty"`
Budget Budget `json:"-"`
SourceAccountID int `json:"sourceAccountId,omitempty"`
SourceAccount Account `json:"-"`
DestinationAccountID int `json:"destinationAccountId,omitempty"`
DestinationAccount Account `json:"-"`
EnvelopeID int `json:"envelopeId,omitempty"`
Envelope Envelope `json:"-"`
}
Transaction represents a transaction between two accounts