feat: extract types to seperate files
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 4m27s
All checks were successful
Build Docker Image / Build-Docker-Image (push) Successful in 4m27s
This commit is contained in:
37
types/transaction.go
Normal file
37
types/transaction.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// At the center of the application is the transaction.
|
||||
//
|
||||
// Every piece of data should be calculated based on transactions.
|
||||
// This means potential calculation errors can be fixed later in time.
|
||||
//
|
||||
// If it becomes necessary to precalculate snapshots for performance reasons, this can be done in the future.
|
||||
// But the transaction should always be the source of truth.
|
||||
type Transaction struct {
|
||||
Id uuid.UUID
|
||||
UserId uuid.UUID `db:"user_id"`
|
||||
|
||||
AccountId uuid.UUID `db:"account_id"`
|
||||
// nil indicates that the transaction is not yet associated with a piggy bank
|
||||
TreasureChestId *uuid.UUID `db:"treasure_chest_id"`
|
||||
|
||||
// The internal transaction is amove between e.g. an account and a piggy bank to execute a savings plan
|
||||
Internal bool
|
||||
|
||||
// The value of the transacion. Negative for outgoing and positive for incoming
|
||||
Value int64
|
||||
Timestamp time.Time
|
||||
|
||||
Note string
|
||||
|
||||
CreatedAt time.Time `db:"created_at"`
|
||||
CreatedBy uuid.UUID `db:"created_by"`
|
||||
UpdatedAt *time.Time `db:"updated_at"`
|
||||
UpdatedBy *uuid.UUID `db:"updated_by"`
|
||||
}
|
||||
Reference in New Issue
Block a user