data

package
v0.0.0-...-6f22b4a Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeletePerson

func DeletePerson(engine *xorm.Engine, IDPerson uint16) error

DeletePerson delete a person from database Before deleting we need to check if the person is involved in any transaction. Otherwise all debt will be wrong.

func DeleteTransaction

func DeleteTransaction(engine *xorm.Engine, IDTransaction uint16) error

DeleteTransaction delete a transaction from database

func GetEngine

func GetEngine(databaseFile string) (*xorm.Engine, error)

GetEngine get a database connection Create or update tables

func GetParticipants

func GetParticipants(engine *xorm.Engine, hash string) (*[]Person, error)

GetParticipants given a pognon hash return list of participants

func GetTransactions

func GetTransactions(engine *xorm.Engine, hash string) (*[]Transaction, error)

GetTransactions for a given pognon hash get the corresponding transactions

func PutPerson

func PutPerson(engine *xorm.Engine, person *Person) error

PutPerson perform update for a person. In practice it means changing it's name.

func PutTransaction

func PutTransaction(engine *xorm.Engine, transaction *Transaction) error

PutTransaction perform update on a transaction

func WritePognon

func WritePognon(engine *xorm.Engine, pognon *PognonJSON) error

WritePognon write a new Pognon to database

func WriteTransaction

func WriteTransaction(engine *xorm.Engine, transaction *Transaction) error

WriteTransaction write a transaction to database

Types

type Person

type Person struct {
	IDPerson   uint16 `xorm:"pk SERIAL"`
	Name       string
	PognonHash string `xorm:"INDEX DEFAULT ''" json:"-"`
}

Person is a participant to a pognon

type Pognon

type Pognon struct {
	IDPognon   uint16 `xorm:"pk SERIAL" json:"-"`
	PognonHash string `xorm:"unique index"` // Random hash to identify pognon
}

Pognon is a list of transactions and participants

func GetPognon

func GetPognon(engine *xorm.Engine, hash string) (*Pognon, error)

GetPognon for a hash returns corresponding pognon

type PognonJSON

type PognonJSON struct {
	Pognon       *Pognon
	Participants *[]Person
	Transactions *[]Transaction
}

PognonJSON is a structured response to a pongon request

func GetPognonJSON

func GetPognonJSON(engine *xorm.Engine, hash string) (*PognonJSON, error)

GetPognonJSON given a hash build a JSON response with corresponding pognon

type Purchase

type Purchase struct {
	IDPerson uint16
	Amount   float32
	Rest     bool
}

Purchase is an amount payed by someone or an amount used by someone

type Transaction

type Transaction struct {
	IDTransaction uint16     `xorm:"pk SERIAL"`
	PognonHash    string     `xorm:"NOT NULL INDEX DEFAULT ''" json:"-"` // Reference to a pognon
	Buyers        []Purchase // The ones who payed and how much
	For           []Purchase // The ones who used the money and how much
	Reason        string     // What was payed

	CreatedAt time.Time `xorm:"created"`
	UpdatedAt time.Time `xorm:"updated"`
}

Transaction is a money transaction for a Pognon

Jump to

Keyboard shortcuts

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