48 lines
1.3 KiB
Go
48 lines
1.3 KiB
Go
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"`
|
|
|
|
Timestamp time.Time
|
|
Company string
|
|
Party string
|
|
Description string
|
|
|
|
// account id is only nil, if the transaction is a deposit to a treasure chest
|
|
AccountId *uuid.UUID `db:"account_id"`
|
|
TreasureChestId *uuid.UUID `db:"treasure_chest_id"`
|
|
// The value of the transacion. Negative for outgoing and positive for incoming transactions.
|
|
Value int64
|
|
|
|
// If an error is present, then the transaction is not valid and should not be used for calculations.
|
|
Error *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"`
|
|
}
|
|
|
|
type TransactionInput struct {
|
|
Id string
|
|
AccountId string
|
|
TreasureChestId string
|
|
Value string
|
|
Timestamp string
|
|
Party string
|
|
Description string
|
|
}
|