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>
|
<tr>
|
||||||
<th>Category</th>
|
<th>Category</th>
|
||||||
<th class="text-end">Total Spend</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">% of Total</th>
|
||||||
<th class="text-end">Txns</th>
|
<th class="text-end">Txns</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -85,6 +86,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
<td class="text-end">@c.TotalSpend.ToString("C")</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">
|
<td class="text-end">
|
||||||
<span class="badge bg-secondary">@c.PercentageOfTotal.ToString("F1")%</span>
|
<span class="badge bg-secondary">@c.PercentageOfTotal.ToString("F1")%</span>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace MoneyMap.Pages
|
|||||||
public decimal TotalSpend { get; set; }
|
public decimal TotalSpend { get; set; }
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public decimal PercentageOfTotal { get; set; }
|
public decimal PercentageOfTotal { get; set; }
|
||||||
|
public decimal AveragePerTransaction { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class RecentTxnRow
|
public class RecentTxnRow
|
||||||
@@ -194,7 +195,8 @@ namespace MoneyMap.Pages
|
|||||||
Category = g.Key,
|
Category = g.Key,
|
||||||
TotalSpend = g.Sum(x => -x.Amount),
|
TotalSpend = g.Sum(x => -x.Amount),
|
||||||
Count = g.Count(),
|
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)
|
.OrderByDescending(x => x.TotalSpend)
|
||||||
.Take(count)
|
.Take(count)
|
||||||
|
|||||||
Reference in New Issue
Block a user