entities

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amount

type Amount struct {
	ISOCurrency string `gorm:"type:varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;NOT NULL; "`
	GrossCent   int64
	VatRate     float64 `gorm:"type:decimal(10,2)"`
}

type Deletion

type Deletion struct {
	Status  TransactionStatus `gorm:"type:enum('tentative', 'pending', 'valid', 'deleted');NULL;default:NULL"`
	Comment string            `gorm:"type:text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"`
	By      string            `gorm:"type:text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"`
}

type PaymentMethod

type PaymentMethod string
const (
	PaymentMethodCredit   PaymentMethod = "credit"
	PaymentMethodPaypal   PaymentMethod = "paypal"
	PaymentMethodTransfer PaymentMethod = "transfer"
	PaymentMethodInternal PaymentMethod = "internal"
	PaymentMethodGift     PaymentMethod = "gift"
	PaymentMethodCash     PaymentMethod = "cash"
)

func (PaymentMethod) IsValid

func (p PaymentMethod) IsValid() bool

type Transaction

type Transaction struct {
	gorm.Model
	DebitorID         int64             `gorm:"index;type:bigint;NOT NULL"`
	TransactionID     string            `gorm:"uniqueIndex:idx_uq_tid;type:varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;NOT NULL"`
	TransactionType   TransactionType   `gorm:"type:enum('due', 'payment')"`
	PaymentMethod     PaymentMethod     `gorm:"type:enum('credit', 'paypal', 'transfer', 'internal', 'gift', 'cash')"`
	PaymentStartUrl   string            `gorm:"type:text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;default:NULL"`
	TransactionStatus TransactionStatus `gorm:"type:enum('tentative', 'pending', 'valid', 'deleted')"`
	Amount            Amount            `gorm:"embedded"`
	Comment           string            `gorm:"type:text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"`
	Deletion          Deletion          `gorm:"embedded;embeddedPrefix:deleted_"`
	EffectiveDate     sql.NullTime      `gorm:"type:date;NOT NULL"`
	DueDate           sql.NullTime      `gorm:"type:date;NULL;default:NULL"`
}

func (*Transaction) ToTransactionLog

func (t *Transaction) ToTransactionLog() TransactionLog

type TransactionLog

type TransactionLog struct {
	gorm.Model
	DebitorID         int64             `gorm:"index;type:bigint;NOT NULL"`
	TransactionID     string            `gorm:"index;type:varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;NOT NULL"`
	TransactionType   TransactionType   `gorm:"type:enum('due', 'payment')"`
	PaymentMethod     PaymentMethod     `gorm:"type:enum('credit', 'paypal', 'transfer', 'internal', 'gift', 'cash')"`
	PaymentStartUrl   string            `gorm:"type:text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;default:NULL"`
	TransactionStatus TransactionStatus `gorm:"type:enum('tentative', 'pending', 'valid', 'deleted')"`
	Amount            Amount            `gorm:"embedded"`
	Comment           string            `gorm:"type:text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci"`
	Deletion          Deletion          `gorm:"embedded;embeddedPrefix:deleted_"`
	EffectiveDate     sql.NullTime      `gorm:"type:date;NOT NULL"`
	DueDate           sql.NullTime      `gorm:"type:date;NULL;default:NULL"`
}

TransactionLog holds information about the state of a transaction for a given time

This table is append only

type TransactionQuery

type TransactionQuery struct {
	// description: The id of a debitor to filter by
	DebitorID int64
	// filter by transaction_identifier
	TransactionIdentifier string
	// filter by effective date (inclusive) lower bound
	EffectiveFrom time.Time
	// filter by effective date (exclusive) upper bound - this makes it easy to get everything in a given month
	EffectiveBefore time.Time
}

type TransactionStatus

type TransactionStatus string
const (
	TransactionStatusTentative TransactionStatus = "tentative"
	TransactionStatusPending   TransactionStatus = "pending"
	TransactionStatusValid     TransactionStatus = "valid"
	TransactionStatusDeleted   TransactionStatus = "deleted"
)

func (TransactionStatus) IsValid

func (t TransactionStatus) IsValid() bool

type TransactionType

type TransactionType string
const (
	TransactionTypeDue     TransactionType = "due"
	TransactionTypePayment TransactionType = "payment"
)

func (TransactionType) IsValid

func (t TransactionType) IsValid() bool

Jump to

Keyboard shortcuts

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