models

package
v0.0.0-...-68a4f6b Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balance

type Balance struct {
	gorm.Model
	User   uint
	Group  uint
	Amount float64
}

type Expense

type Expense struct {
	gorm.Model
	Description  string
	Amount       float64
	GroupID      uint
	OwnerID      uint
	Owner        User    `gorm:"foreignKey:OwnerID"`
	Participants []*User `gorm:"many2many:expense_participants;"`
}

func NewExpense

func NewExpense(description string, amount float64, groupID uint, ownerID uint, participants []*User) (*Expense, error)

type Group

type Group struct {
	gorm.Model
	UUID         uuid.UUID `gorm:"type:uuid;unique"`
	Name         string
	Date         time.Time
	Users        []*User       `gorm:"many2many:user_groups;"`
	Expenses     []Expense     `gorm:"foreignKey:GroupID"`
	Transactions []Transaction `gorm:"foreignKey:Group"`
	Balances     []*Balance    `gorm:"foreignKey:Group"`
}

func NewGroup

func NewGroup(uuid uuid.UUID, name string, owner *User, participants []*User, date time.Time) (*Group, error)

type Transaction

type Transaction struct {
	gorm.Model
	Amount         float64
	Group          uint
	SenderUserID   uint
	ReceiverUserID uint
	Sender         User `gorm:"foreignkey:SenderUserID"`
	Receiver       User `gorm:"foreignkey:ReceiverUserID"`
}

type User

type User struct {
	gorm.Model
	Name                 string
	Email                string        `gorm:"unique"`
	Hashed_passwod       string        `gorm:"size:60"`
	Groups               []*Group      `gorm:"many2many:user_groups;"`
	Expenses             []Expense     `gorm:"foreignKey:OwnerID"`
	ParticipatedExpenses []*Expense    `gorm:"many2many:expense_participants;"`
	SenderTransactions   []Transaction `gorm:"foreignkey:SenderUserID"`
	ReceiverTransactions []Transaction `gorm:"foreignkey:ReceiverUserID"`
	Balances             []Balance     `gorm:"foreignKey:User"`
	IsGuest              bool          `gorm:"not null;default:false"`
}

Jump to

Keyboard shortcuts

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