mirror of
https://github.com/we-promise/sure.git
synced 2026-05-25 05:24:57 +00:00
* add missing Hungarian translations for newly extracted strings Replace hard-coded UI strings with I18n lookups across controllers, models and views (breadcrumbs, dashboard, reports, settings, transactions, balance sheet, MFA status). Update models to use translations for category defaults, account/display names, classification group and period labels; remove a few hardcoded display_name methods. Add and update numerous locale files (English and extensive Hungarian translations, plus model/view/doorkeeper entries) to provide the required keys. These changes centralize copy for localization and prepare the app for Hungarian/English UI text. * Pluralize account type labels; tidy Crypto model Update English locale account type labels to use plural forms for consistency (Investment(s), Properties, Vehicles, Other Assets, Credit Cards, Loans, Other Liabilities). Also remove an extra blank line in app/models/crypto.rb to tidy up formatting. * Back to singular * fix(i18n): separate singular and group account labels * Update _accountable_group.html.erb * Use I18n plural names for account types Change Accountable#display_name to look up pluralized account type names via I18n (accounts.types_plural.<underscored_class>) with a fallback to the legacy display logic. Add legacy_display_name helper to preserve previous behavior (singular for Depository and Crypto, pluralized otherwise). Add corresponding types_plural entries in English and Hungarian locale files for various account types. --------- Co-authored-by: Juan José Mata <jjmata@jjmata.com> Co-authored-by: sure-admin <sure-admin@splashblot.com>
62 lines
2.0 KiB
Ruby
62 lines
2.0 KiB
Ruby
class BalanceSheet::ClassificationGroup
|
|
include Monetizable
|
|
|
|
monetize :total, as: :total_money
|
|
|
|
attr_reader :classification, :currency
|
|
|
|
def initialize(classification:, currency:, accounts:)
|
|
@classification = normalize_classification!(classification)
|
|
@name = name
|
|
@currency = currency
|
|
@accounts = accounts
|
|
end
|
|
|
|
def name
|
|
I18n.t("pages.dashboard.balance_sheet.classifications.#{classification}", default: classification.titleize.pluralize)
|
|
end
|
|
|
|
def icon
|
|
classification == "asset" ? "plus" : "minus"
|
|
end
|
|
|
|
def total
|
|
accounts.select { |a| a.respond_to?(:included_in_finances?) ? a.included_in_finances? : true }.sum(&:converted_balance)
|
|
end
|
|
|
|
def syncing?
|
|
accounts.any?(&:syncing?)
|
|
end
|
|
|
|
# For now, we group by accountable type. This can be extended in the future to support arbitrary user groupings.
|
|
def account_groups
|
|
groups = accounts.group_by(&:accountable_type)
|
|
.transform_keys { |at| Accountable.from_type(at) }
|
|
.map do |accountable, account_rows|
|
|
BalanceSheet::AccountGroup.new(
|
|
name: accountable.display_name,
|
|
color: accountable.color,
|
|
accountable_type: accountable,
|
|
accounts: account_rows,
|
|
classification_group: self
|
|
)
|
|
end
|
|
|
|
# Sort the groups using the manual order defined by Accountable::TYPES so that
|
|
# the UI displays account groups in a predictable, domain-specific sequence.
|
|
groups.sort_by do |group|
|
|
manual_order = Accountable::TYPES
|
|
type_name = group.key.camelize
|
|
manual_order.index(type_name) || Float::INFINITY
|
|
end
|
|
end
|
|
|
|
private
|
|
attr_reader :accounts
|
|
|
|
def normalize_classification!(classification)
|
|
raise ArgumentError, "Invalid classification: #{classification}" unless %w[asset liability].include?(classification)
|
|
classification
|
|
end
|
|
end
|