diff --git a/app/javascript/controllers/goal_projection_chart_controller.js b/app/javascript/controllers/goal_projection_chart_controller.js index f7b02107c..41f77bea9 100644 --- a/app/javascript/controllers/goal_projection_chart_controller.js +++ b/app/javascript/controllers/goal_projection_chart_controller.js @@ -562,13 +562,18 @@ export default class extends Controller { maximumFractionDigits: 0, }).format(amount); } catch { - const symbol = currency === "EUR" ? "€" : currency === "GBP" ? "£" : "$"; + // Same server-shipped symbol path as `_fmtMoneyShort`. + const symbol = (this.dataValue && this.dataValue.currency_symbol) || "$"; return `${symbol}${Math.round(amount).toLocaleString()}`; } } - _fmtMoneyShort(amount, currency) { - const symbol = currency === "EUR" ? "€" : currency === "GBP" ? "£" : "$"; + _fmtMoneyShort(amount, _currency) { + // The server ships `currency_symbol` via projection_payload (resolved + // through Money.new(0, code).symbol so EUR/GBP/JPY/etc. render with + // the family-locale-correct glyph). Fall back to "$" if a stale + // payload reaches us mid-deploy. + const symbol = (this.dataValue && this.dataValue.currency_symbol) || "$"; const abs = Math.abs(amount); if (abs >= 1_000_000) { return `${symbol}${(amount / 1_000_000).toFixed(1).replace(/\.0$/, "")}M`; diff --git a/app/models/demo/generator.rb b/app/models/demo/generator.rb index 87965c72a..40be65630 100644 --- a/app/models/demo/generator.rb +++ b/app/models/demo/generator.rb @@ -1425,7 +1425,7 @@ class Demo::Generator .where("entries.amount < 0") .where("entries.date >= ?", 30.days.ago.to_date) .where("(transactions.extra -> 'goal' ->> 'pledge_id') IS NULL") - .order("entries.date DESC") + .order("entries.date DESC", "entries.id DESC") .first return unless recent_inflow_entry diff --git a/app/models/goal.rb b/app/models/goal.rb index 65937ef14..c34fff00b 100644 --- a/app/models/goal.rb +++ b/app/models/goal.rb @@ -200,6 +200,7 @@ class Goal < ApplicationRecord target_amount: target_amt.to_f, target_amount_label: Money.new(target_amt, currency).format(precision: 0), target_amount_short_label: short_money(target_amt, currency), + currency_symbol: Money.new(0, currency).symbol, current_amount: current_balance.to_f, avg_monthly: pace.to_f, required_monthly: monthly_target_amount.to_f,