feat: 新增账户服务层,实现账户的增删改查及转账功能,并初始化AI记账、交易服务和预算仓库。
This commit is contained in:
@@ -144,7 +144,13 @@ func (r *BudgetRepository) GetSpentAmount(budget *models.Budget, startDate, endD
|
||||
|
||||
// Filter by category if specified
|
||||
if budget.CategoryID != nil {
|
||||
query = query.Where("category_id = ?", *budget.CategoryID)
|
||||
// Get sub-categories
|
||||
var subCategoryIDs []uint
|
||||
r.db.Model(&models.Category{}).Where("parent_id = ?", *budget.CategoryID).Pluck("id", &subCategoryIDs)
|
||||
|
||||
// Include the category itself and all its children
|
||||
categoryIDs := append(subCategoryIDs, *budget.CategoryID)
|
||||
query = query.Where("category_id IN ?", categoryIDs)
|
||||
}
|
||||
|
||||
// Filter by account if specified
|
||||
|
||||
Reference in New Issue
Block a user