1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-23 07:09:39 +02:00

Show budget averages in family currency
Some checks failed
Publish Docker image / ci (push) Has been cancelled
Publish Docker image / Build docker image (push) Has been cancelled

Fixes #1689
This commit is contained in:
Zach Gollwitzer 2025-01-24 20:19:13 -05:00
parent 7e0ec4bd8f
commit e617d791d3
4 changed files with 19 additions and 7 deletions

View file

@ -107,6 +107,18 @@ class Category < ApplicationRecord
family.category_stats.month_total_for(self, date: date) family.category_stats.month_total_for(self, date: date)
end end
def avg_monthly_total_money
Money.new(avg_monthly_total, family.currency)
end
def median_monthly_total_money
Money.new(median_monthly_total, family.currency)
end
def month_total_money(date: Date.current)
Money.new(month_total(date: date), family.currency)
end
private private
def category_level_limit def category_level_limit
if subcategory? && parent.subcategory? if subcategory? && parent.subcategory?

View file

@ -32,7 +32,7 @@
<% end %> <% end %>
<% else %> <% else %>
<p class="text-sm text-gray-500 font-medium"> <p class="text-sm text-gray-500 font-medium">
<%= format_money(budget_category.category.avg_monthly_total) %> avg <%= format_money(budget_category.category.avg_monthly_total_money, precision: 0) %> avg
</p> </p>
<% end %> <% end %>
</div> </div>

View file

@ -8,7 +8,7 @@
<div class="text-sm mr-3"> <div class="text-sm mr-3">
<p class="text-gray-900 font-medium mb-0.5"><%= budget_category.category.name %></p> <p class="text-gray-900 font-medium mb-0.5"><%= budget_category.category.name %></p>
<p class="text-gray-500"><%= format_money(Money.new(budget_category.category.avg_monthly_total, budget_category.currency), precision: 0) %>/m average</p> <p class="text-gray-500"><%= format_money(budget_category.category.avg_monthly_total_money, precision: 0) %>/m average</p>
</div> </div>
<div class="ml-auto"> <div class="ml-auto">

View file

@ -10,10 +10,10 @@
<% if @budget_category.budget.initialized? %> <% if @budget_category.budget.initialized? %>
<p class="text-sm text-gray-500"> <p class="text-sm text-gray-500">
<span class="text-gray-900"> <span class="text-gray-900">
<%= format_money(@budget_category.actual_spending) %> <%= format_money(@budget_category.actual_spending_money) %>
</span> </span>
<span>/</span> <span>/</span>
<span><%= format_money(@budget_category.budgeted_spending) %></span> <span><%= format_money(@budget_category.budgeted_spending_money) %></span>
</p> </p>
<% end %> <% end %>
</div> </div>
@ -72,7 +72,7 @@
<div class="flex items-center justify-between text-sm"> <div class="flex items-center justify-between text-sm">
<dt class="text-gray-500">Budgeted</dt> <dt class="text-gray-500">Budgeted</dt>
<dd class="text-gray-900 font-medium"> <dd class="text-gray-900 font-medium">
<%= format_money @budget_category.budgeted_spending %> <%= format_money @budget_category.budgeted_spending_money %>
</dd> </dd>
</div> </div>
<% end %> <% end %>
@ -80,14 +80,14 @@
<div class="flex items-center justify-between text-sm"> <div class="flex items-center justify-between text-sm">
<dt class="text-gray-500">Monthly average spending</dt> <dt class="text-gray-500">Monthly average spending</dt>
<dd class="text-gray-900 font-medium"> <dd class="text-gray-900 font-medium">
<%= format_money @budget_category.category.avg_monthly_total %> <%= format_money @budget_category.category.avg_monthly_total_money, precision: 0 %>
</dd> </dd>
</div> </div>
<div class="flex items-center justify-between text-sm"> <div class="flex items-center justify-between text-sm">
<dt class="text-gray-500">Monthly median spending</dt> <dt class="text-gray-500">Monthly median spending</dt>
<dd class="text-gray-900 font-medium"> <dd class="text-gray-900 font-medium">
<%= format_money @budget_category.category.median_monthly_total %> <%= format_money @budget_category.category.median_monthly_total_money, precision: 0 %>
</dd> </dd>
</div> </div>
</dl> </dl>