WA-10 - Implemented transactions

This commit is contained in:
Fran Jurmanović
2021-05-16 17:43:58 +02:00
parent 55010c83d6
commit a99b44194a
8 changed files with 251 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
package models
type TransactionType struct {
tableName struct{} `pg:"transactionTypes,alias:transactionTypes"`
BaseModel
Name string `json:"name" pg:"name"`
Type string `json:"type" pg:"type"`
}
type NewTransactionTypeBody struct {
Name string `json:"name"`
Type string `json:"type"`
}

View File

@@ -0,0 +1,21 @@
package models
import "time"
type Transaction struct {
tableName struct{} `pg:"transactions,alias:transactions"`
BaseModel
Description string `json:"description" pg:"description"`
TransactionTypeID string `json:"transactionTypeId", pg:"transaction_type_id"`
TransactionType *TransactionType `json:"transactionType", pg:"rel:has-one, fk:transaction_type_id"`
WalletID string `json:"walletId", pg:"wallet_id"`
Wallet *Wallet `json:"wallet" pg:"rel:has-one, fk:wallet_id"`
TransactionDate time.Time `json:"transactionDate" pg:"transaction_date"`
}
type NewTransactionBody struct {
WalletID string `json:"walletId"`
TransactionTypeID string `json:"transactionTypeId"`
TransactionDate time.Time `json:"transactionDate"`
Description string `json:"description"`
}