update expense item name

This commit is contained in:
2026-05-29 13:25:38 +07:00
parent f7399fd0e7
commit 1b7bec4f81
14 changed files with 77 additions and 37 deletions
+2 -2
View File
@@ -531,7 +531,7 @@ func (r *AnalyticsRepositoryImpl) getOperationalExpenseItems(ctx context.Context
query := r.db.WithContext(ctx).
Table("expense_items ei").
Select(`COALESCE(ei.description, coa.name) as description, COALESCE(SUM(ei.amount), 0) as amount`).
Select(`COALESCE(NULLIF(ei.item, ''), ei.description, coa.name) as item, COALESCE(SUM(ei.amount), 0) as amount`).
Joins("JOIN expenses e ON ei.expense_id = e.id").
Joins("JOIN chart_of_accounts coa ON ei.chart_of_account_id = coa.id").
Where("e.organization_id = ?", organizationID).
@@ -542,7 +542,7 @@ func (r *AnalyticsRepositoryImpl) getOperationalExpenseItems(ctx context.Context
}
err := query.
Group("COALESCE(ei.description, coa.name)").
Group("COALESCE(NULLIF(ei.item, ''), ei.description, coa.name)").
Order("amount DESC").
Scan(&results).Error