updated
Build and Test / build-and-test-backend (push) Successful in 1m24s
Build and Test / build-and-test-frontend (push) Successful in 37s

This commit is contained in:
wt committed 2025-10-08 12:46:10 +07:00
1 parent e16edd7744
commit 582ab5e7b9
3 files changed
+48 -46

No files matched your search

+3
View File
@@ -44,6 +44,9 @@ func GetAllOperations(userid string) ([]model.Operation, error) {
return nil, e return nil, e
} }
for i := range operations { for i := range operations {
if operations[i].CategoryID == "" {
continue
}
var category model.Category var category model.Category
e := Db.First(&category, "ID = ?", operations[i].CategoryID).Error e := Db.First(&category, "ID = ?", operations[i].CategoryID).Error
if e != nil { if e != nil {
+42 -43
View File
@@ -1,45 +1,44 @@
[ [
{ {
"title": "Operation 1", "title": "Operation 1",
"amount": 100, "amount": 100,
"date": "2022-01-01T00:00:00Z", "date": "2022-01-01T00:00:00Z",
"type": "income", "type": "income",
"icon": "😀", "icon": "😀"
"categoryid": "8f8b5f62-5d30-44a0-8de0-0485200f53a5" },
}, {
{ "title": "Operation 2",
"title": "Operation 2", "amount": 200,
"amount": 200, "date": "2022-01-02T00:00:00Z",
"date": "2022-01-02T00:00:00Z", "type": "expense",
"type": "expense", "icon": "😂"
"icon": "😂" },
}, {
{ "title": "Operation 2",
"title": "Operation 2", "amount": 200,
"amount": 200, "date": "2022-01-02T00:00:00Z",
"date": "2022-01-02T00:00:00Z", "type": "expense",
"type": "expense", "icon": "😂"
"icon": "😂" },
}, {
{ "title": "Operation 1",
"title": "Operation 1", "amount": 100,
"amount": 100, "date": "2022-01-02T00:00:00Z",
"date": "2022-01-02T00:00:00Z", "type": "income",
"type": "income", "icon": "😀"
"icon": "😀" },
}, {
{ "title": "Operation 2",
"title": "Operation 2", "amount": 200,
"amount": 200, "date": "2022-06-02T00:00:00Z",
"date": "2022-06-02T00:00:00Z", "type": "expense",
"type": "expense", "icon": "😂"
"icon": "😂" },
}, {
{ "title": "Operation 2",
"title": "Operation 2", "amount": 200,
"amount": 200, "date": "2022-06-22T00:00:00Z",
"date": "2022-06-22T00:00:00Z", "type": "expense",
"type": "expense", "icon": "😂"
"icon": "😂" }
}
] ]
+3 -3
View File
@@ -10,7 +10,7 @@ type Operation struct {
Date string `json:"date"` Date string `json:"date"`
UserID string `json:"userid"` UserID string `json:"userid"`
CategoryID string `json:"categoryid"` CategoryID string `json:"categoryid"`
SubcategoryID string `json:"subcategoryid"` SubcategoryID *string `json:"subcategoryid,omitempty"`
Category Category `gorm:"foreignKey:CategoryID"` Category Category `json:"category,omitzero"`
Subcategory Subcategory `gorm:"foreignKey:SubcategoryID"` Subcategory Subcategory `json:"subcategory,omitzero"`
} }