Add average cost per transaction to top expense categories
Display the average spend per transaction for each category on the dashboard's top expense categories table. This helps users understand spending patterns beyond just total amounts. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -71,6 +71,7 @@
|
||||
<tr>
|
||||
<th>Category</th>
|
||||
<th class="text-end">Total Spend</th>
|
||||
<th class="text-end">Avg Per Txn</th>
|
||||
<th class="text-end">% of Total</th>
|
||||
<th class="text-end">Txns</th>
|
||||
</tr>
|
||||
@@ -85,6 +86,7 @@
|
||||
</a>
|
||||
</td>
|
||||
<td class="text-end">@c.TotalSpend.ToString("C")</td>
|
||||
<td class="text-end text-muted">@c.AveragePerTransaction.ToString("C")</td>
|
||||
<td class="text-end">
|
||||
<span class="badge bg-secondary">@c.PercentageOfTotal.ToString("F1")%</span>
|
||||
</td>
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace MoneyMap.Pages
|
||||
public decimal TotalSpend { get; set; }
|
||||
public int Count { get; set; }
|
||||
public decimal PercentageOfTotal { get; set; }
|
||||
public decimal AveragePerTransaction { get; set; }
|
||||
}
|
||||
|
||||
public class RecentTxnRow
|
||||
@@ -194,7 +195,8 @@ namespace MoneyMap.Pages
|
||||
Category = g.Key,
|
||||
TotalSpend = g.Sum(x => -x.Amount),
|
||||
Count = g.Count(),
|
||||
PercentageOfTotal = totalSpend > 0 ? (g.Sum(x => -x.Amount) / totalSpend) * 100 : 0
|
||||
PercentageOfTotal = totalSpend > 0 ? (g.Sum(x => -x.Amount) / totalSpend) * 100 : 0,
|
||||
AveragePerTransaction = g.Count() > 0 ? g.Sum(x => -x.Amount) / g.Count() : 0
|
||||
})
|
||||
.OrderByDescending(x => x.TotalSpend)
|
||||
.Take(count)
|
||||
|
||||
Reference in New Issue
Block a user