Compare commits
No commits in common. "4d452737cda0afff2ab1602142c8c35a649773c1" and "46ab4ee7a0ff4807743168f1a0c5860c2287161a" have entirely different histories.
4d452737cd
...
46ab4ee7a0
|
@ -12,10 +12,8 @@ import (
|
|||
|
||||
var cardTransform func(inp *db.Card) types.DbCard = func(inp *db.Card) types.DbCard {
|
||||
var curr types.DbCurrency
|
||||
symbolPostfixForCard := ""
|
||||
if inp.Currency != nil {
|
||||
curr = currencyTransform(inp.Currency)
|
||||
symbolPostfixForCard = fmt.Sprintf(" (%s)", inp.Currency.Symbol)
|
||||
} else {
|
||||
curr = types.DbCurrency{}
|
||||
}
|
||||
|
@ -28,7 +26,7 @@ var cardTransform func(inp *db.Card) types.DbCard = func(inp *db.Card) types.DbC
|
|||
LastDigits: inp.LastDigits,
|
||||
CurrencyID: inp.CurrencyID,
|
||||
Currency: curr,
|
||||
DisplayName: fmt.Sprintf("%s •%s%s", inp.Name, inp.LastDigits, symbolPostfixForCard),
|
||||
DisplayName: fmt.Sprintf("%s •%s", inp.Name, inp.LastDigits),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,26 +1,12 @@
|
|||
package handlers
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.qowevisa.me/Qowevisa/fin-check-api/db"
|
||||
"git.qowevisa.me/Qowevisa/fin-check-api/types"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
var expenseTransform func(inp *db.Expense) types.DbExpense = func(inp *db.Expense) types.DbExpense {
|
||||
var card types.DbCard
|
||||
expenseValueSymbolPostfix := ""
|
||||
if inp.Card != nil {
|
||||
card = cardTransform(inp.Card)
|
||||
if inp.Card.Currency != nil {
|
||||
expenseValueSymbolPostfix = fmt.Sprintf(" (%s)", inp.Card.Currency.Symbol)
|
||||
}
|
||||
} else {
|
||||
card = types.DbCard{}
|
||||
}
|
||||
var showValue string
|
||||
showValue = fmt.Sprintf("%d.%02d%s", inp.Value/100, inp.Value%100, expenseValueSymbolPostfix)
|
||||
return types.DbExpense{
|
||||
ID: inp.ID,
|
||||
CardID: inp.CardID,
|
||||
|
@ -28,8 +14,6 @@ var expenseTransform func(inp *db.Expense) types.DbExpense = func(inp *db.Expens
|
|||
Value: inp.Value,
|
||||
Comment: inp.Comment,
|
||||
Date: inp.Date,
|
||||
Card: card,
|
||||
ShowValue: showValue,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,7 +53,7 @@ func ExpenseGetAll(c *gin.Context) {
|
|||
}
|
||||
dbc := db.Connect()
|
||||
var entities []*db.Expense
|
||||
if err := dbc.Preload("Card.Currency").Find(&entities, db.Expense{UserID: userID}).Error; err != nil {
|
||||
if err := dbc.Find(&entities, db.Expense{UserID: userID}).Error; err != nil {
|
||||
c.JSON(500, types.ErrorResponse{Message: err.Error()})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -82,9 +82,6 @@ type DbExpense struct {
|
|||
Value uint64 `json:"value" example:"20000"`
|
||||
Comment string `json:"comment" example:"pizza"`
|
||||
Date time.Time `json:"date" example:"29/11/2001 12:00"`
|
||||
// Purely UI things
|
||||
Card DbCard `json:"card"`
|
||||
ShowValue string `json:"show_value" example:"10.35$"`
|
||||
}
|
||||
|
||||
type DbTransfer struct {
|
||||
|
|
Loading…
Reference in New Issue
Block a user