mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 07:49:01 +00:00
Merge branch 'main' into feat/goals-v2-architecture
This commit is contained in:
@@ -13,7 +13,7 @@ class BalanceSheet::ClassificationGroup
|
||||
end
|
||||
|
||||
def name
|
||||
classification.titleize.pluralize
|
||||
I18n.t("pages.dashboard.balance_sheet.classifications.#{classification}", default: classification.titleize.pluralize)
|
||||
end
|
||||
|
||||
def icon
|
||||
@@ -34,7 +34,7 @@ class BalanceSheet::ClassificationGroup
|
||||
.transform_keys { |at| Accountable.from_type(at) }
|
||||
.map do |accountable, account_rows|
|
||||
BalanceSheet::AccountGroup.new(
|
||||
name: I18n.t("accounts.types.#{accountable.name.underscore}", default: accountable.display_name),
|
||||
name: accountable.display_name,
|
||||
color: accountable.color,
|
||||
accountable_type: accountable,
|
||||
accounts: account_rows,
|
||||
|
||||
@@ -197,28 +197,28 @@ class Category < ApplicationRecord
|
||||
private
|
||||
def default_categories
|
||||
[
|
||||
[ "Income", "#22c55e", "circle-dollar-sign" ],
|
||||
[ "Food & Drink", "#f97316", "utensils" ],
|
||||
[ "Groceries", "#407706", "shopping-bag" ],
|
||||
[ "Shopping", "#3b82f6", "shopping-cart" ],
|
||||
[ "Transportation", "#0ea5e9", "bus" ],
|
||||
[ "Travel", "#2563eb", "plane" ],
|
||||
[ "Entertainment", "#a855f7", "drama" ],
|
||||
[ "Healthcare", "#4da568", "pill" ],
|
||||
[ "Personal Care", "#14b8a6", "scissors" ],
|
||||
[ "Home Improvement", "#d97706", "hammer" ],
|
||||
[ "Mortgage / Rent", "#b45309", "home" ],
|
||||
[ "Utilities", "#eab308", "lightbulb" ],
|
||||
[ "Subscriptions", "#6366f1", "wifi" ],
|
||||
[ "Insurance", "#0284c7", "shield" ],
|
||||
[ "Sports & Fitness", "#10b981", "dumbbell" ],
|
||||
[ "Gifts & Donations", "#61c9ea", "hand-helping" ],
|
||||
[ "Taxes", "#dc2626", "landmark" ],
|
||||
[ "Loan Payments", "#e11d48", "credit-card" ],
|
||||
[ "Services", "#7c3aed", "briefcase" ],
|
||||
[ "Fees", "#6b7280", "receipt" ],
|
||||
[ "Savings & Investments", "#059669", "piggy-bank" ],
|
||||
[ investment_contributions_name, "#0d9488", "trending-up" ]
|
||||
[ I18n.t("models.category.defaults.income"), "#22c55e", "circle-dollar-sign" ],
|
||||
[ I18n.t("models.category.defaults.food_and_drink"), "#f97316", "utensils" ],
|
||||
[ I18n.t("models.category.defaults.groceries"), "#407706", "shopping-bag" ],
|
||||
[ I18n.t("models.category.defaults.shopping"), "#3b82f6", "shopping-cart" ],
|
||||
[ I18n.t("models.category.defaults.transportation"), "#0ea5e9", "bus" ],
|
||||
[ I18n.t("models.category.defaults.travel"), "#2563eb", "plane" ],
|
||||
[ I18n.t("models.category.defaults.entertainment"), "#a855f7", "drama" ],
|
||||
[ I18n.t("models.category.defaults.healthcare"), "#4da568", "pill" ],
|
||||
[ I18n.t("models.category.defaults.personal_care"), "#14b8a6", "scissors" ],
|
||||
[ I18n.t("models.category.defaults.home_improvement"), "#d97706", "hammer" ],
|
||||
[ I18n.t("models.category.defaults.mortgage_rent"), "#b45309", "home" ],
|
||||
[ I18n.t("models.category.defaults.utilities"), "#eab308", "lightbulb" ],
|
||||
[ I18n.t("models.category.defaults.subscriptions"), "#6366f1", "wifi" ],
|
||||
[ I18n.t("models.category.defaults.insurance"), "#0284c7", "shield" ],
|
||||
[ I18n.t("models.category.defaults.sports_and_fitness"), "#10b981", "dumbbell" ],
|
||||
[ I18n.t("models.category.defaults.gifts_and_donations"), "#61c9ea", "hand-helping" ],
|
||||
[ I18n.t("models.category.defaults.taxes"), "#dc2626", "landmark" ],
|
||||
[ I18n.t("models.category.defaults.loan_payments"), "#e11d48", "credit-card" ],
|
||||
[ I18n.t("models.category.defaults.services"), "#7c3aed", "briefcase" ],
|
||||
[ I18n.t("models.category.defaults.fees"), "#6b7280", "receipt" ],
|
||||
[ I18n.t("models.category.defaults.savings_and_investments"), "#059669", "piggy-bank" ],
|
||||
[ investment_contributions_name, "#0d9488", "trending-up" ]
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -58,8 +58,29 @@ module Accountable
|
||||
classification == "asset" ? "up" : "down"
|
||||
end
|
||||
|
||||
def singular_display_name
|
||||
I18n.t("accounts.types.#{name.underscore}", default: legacy_singular_display_name)
|
||||
end
|
||||
|
||||
def display_name
|
||||
self.name.pluralize.titleize
|
||||
I18n.t("accounts.types_plural.#{name.underscore}", default: -> { legacy_display_name })
|
||||
end
|
||||
|
||||
def legacy_display_name
|
||||
return singular_display_name if name.in?([ "Depository", "Crypto" ])
|
||||
|
||||
singular_display_name.pluralize
|
||||
end
|
||||
|
||||
def legacy_singular_display_name
|
||||
case name
|
||||
when "Depository"
|
||||
"Cash"
|
||||
when "Crypto"
|
||||
"Crypto"
|
||||
else
|
||||
name.underscore.humanize
|
||||
end
|
||||
end
|
||||
|
||||
# Sums the balances of all active accounts of this type, converting foreign currencies to the family's currency.
|
||||
@@ -80,6 +101,10 @@ module Accountable
|
||||
end
|
||||
end
|
||||
|
||||
def singular_display_name
|
||||
self.class.singular_display_name
|
||||
end
|
||||
|
||||
def display_name
|
||||
self.class.display_name
|
||||
end
|
||||
|
||||
@@ -34,9 +34,5 @@ class Crypto < ApplicationRecord
|
||||
def icon
|
||||
"bitcoin"
|
||||
end
|
||||
|
||||
def display_name
|
||||
"Crypto"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,10 +12,6 @@ class Depository < ApplicationRecord
|
||||
}.freeze
|
||||
|
||||
class << self
|
||||
def display_name
|
||||
"Cash"
|
||||
end
|
||||
|
||||
def color
|
||||
"#875BF7"
|
||||
end
|
||||
|
||||
@@ -179,24 +179,24 @@ class Period
|
||||
end
|
||||
|
||||
def label
|
||||
if key_metadata
|
||||
key_metadata.fetch(:label)
|
||||
if key
|
||||
I18n.t("period.#{key}.label", default: key_metadata&.fetch(:label) || "Custom Period")
|
||||
else
|
||||
"Custom Period"
|
||||
I18n.t("period.custom.label", default: "Custom Period")
|
||||
end
|
||||
end
|
||||
|
||||
def label_short
|
||||
if key_metadata
|
||||
key_metadata.fetch(:label_short)
|
||||
if key
|
||||
I18n.t("period.#{key}.label_short", default: key_metadata&.fetch(:label_short) || "Custom")
|
||||
else
|
||||
"Custom"
|
||||
I18n.t("period.custom.label_short", default: "Custom")
|
||||
end
|
||||
end
|
||||
|
||||
def comparison_label
|
||||
if key_metadata
|
||||
key_metadata.fetch(:comparison_label)
|
||||
if key
|
||||
I18n.t("period.#{key}.comparison_label", default: key_metadata&.fetch(:comparison_label) || "#{start_date.strftime(@date_format)} to #{end_date.strftime(@date_format)}")
|
||||
else
|
||||
"#{start_date.strftime(@date_format)} to #{end_date.strftime(@date_format)}"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user