mirror of
https://github.com/FJurmanovic/wallet-go-api.git
synced 2026-02-06 06:08:16 +00:00
added transaction status to model
This commit is contained in:
@@ -8,17 +8,17 @@ import (
|
||||
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"`
|
||||
TransactionStatusID string `json:"transactionStatusId", pg:"transaction_status_id"`
|
||||
TransactionStatus *TransactionStatus `json:"transactionStatus", pg:"rel:has-one, fk:transaction_status_id"`
|
||||
WalletID string `json:"walletId", pg:"wallet_id"`
|
||||
Amount float32 `json:"amount", pg:"amount,default:0"`
|
||||
Wallet *Wallet `json:"wallet" pg:"rel:has-one, fk:wallet_id"`
|
||||
TransactionDate time.Time `json:"transactionDate" pg:"transaction_date, type:timestamptz"`
|
||||
SubscriptionID string `json:"subscriptionId", pg:"subscription_id"`
|
||||
Subscription *Subscription `json:"subscription", pg:"rel:has-one, fk:subscription_id"`
|
||||
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"`
|
||||
TransactionStatusID string `json:"transactionStatusId", pg:"transaction_status_id"`
|
||||
TransactionStatus *TransactionStatus `json:"transactionStatus", pg:"rel:has-one, fk:transaction_status_id"`
|
||||
WalletID string `json:"walletId", pg:"wallet_id"`
|
||||
Amount float32 `json:"amount", pg:"amount,default:0"`
|
||||
Wallet *Wallet `json:"wallet" pg:"rel:has-one, fk:wallet_id"`
|
||||
TransactionDate time.Time `json:"transactionDate" pg:"transaction_date, type:timestamptz"`
|
||||
SubscriptionID string `json:"subscriptionId", pg:"subscription_id"`
|
||||
Subscription *Subscription `json:"subscription", pg:"rel:has-one, fk:subscription_id"`
|
||||
}
|
||||
|
||||
type NewTransactionBody struct {
|
||||
@@ -30,10 +30,11 @@ type NewTransactionBody struct {
|
||||
}
|
||||
|
||||
type TransactionEdit struct {
|
||||
Id string `json:"id" form:"id"`
|
||||
WalletID string `json:"walletId" form:"walletId"`
|
||||
TransactionTypeID string `json:"transactionTypeId" form:"transactionTypeId"`
|
||||
TransactionDate time.Time `json:"transactionDate" form:"transactionDate"`
|
||||
Description string `json:"description" form:"description"`
|
||||
Amount json.Number `json:"amount" form:"amount"`
|
||||
Id string `json:"id" form:"id"`
|
||||
WalletID string `json:"walletId" form:"walletId"`
|
||||
TransactionTypeID string `json:"transactionTypeId" form:"transactionTypeId"`
|
||||
TransactionDate time.Time `json:"transactionDate" form:"transactionDate"`
|
||||
TransactionStatusID string `json:"transactionStatusId" form:"transactionStatusId"`
|
||||
Description string `json:"description" form:"description"`
|
||||
Amount json.Number `json:"amount" form:"amount"`
|
||||
}
|
||||
|
||||
@@ -158,6 +158,7 @@ func (as *TransactionService) Edit(ctx context.Context, body *models.Transaction
|
||||
tm.WalletID = body.WalletID
|
||||
tm.TransactionTypeID = body.TransactionTypeID
|
||||
tm.TransactionDate = body.TransactionDate
|
||||
tm.TransactionStatusID = body.TransactionStatusID
|
||||
tm.Amount = float32(math.Round(amount*100) / 100)
|
||||
|
||||
tx, _ := db.Begin()
|
||||
|
||||
Reference in New Issue
Block a user