From 43b67e92ad471c109ec99037db697a8635125e94 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Fri, 19 Dec 2025 15:43:49 -0600 Subject: [PATCH 1/2] Ensure 2 decimal precision when dealing with currency decimals --- app/helpers/subscriptions_helper.rb | 5 +++++ saas/app/helpers/subscriptions_helper.rb | 2 +- saas/app/views/account/settings/_free_plan.html.erb | 4 ++-- saas/app/views/account/settings/_paid_plan.html.erb | 2 +- saas/app/views/account/settings/_subscription.html.erb | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 app/helpers/subscriptions_helper.rb diff --git a/app/helpers/subscriptions_helper.rb b/app/helpers/subscriptions_helper.rb new file mode 100644 index 000000000..e03c5e153 --- /dev/null +++ b/app/helpers/subscriptions_helper.rb @@ -0,0 +1,5 @@ +module SubscriptionsHelper + def currency(amount) + number_to_currency(amount, precision: (amount % 1).zero? ? 0 : 2) + end +end diff --git a/saas/app/helpers/subscriptions_helper.rb b/saas/app/helpers/subscriptions_helper.rb index 48ce0372f..cf8ceb4a9 100644 --- a/saas/app/helpers/subscriptions_helper.rb +++ b/saas/app/helpers/subscriptions_helper.rb @@ -9,7 +9,7 @@ def subscription_period_end_action(subscription) elsif subscription.canceled? "Your Fizzy subscription ended on" else - "Your next payment is #{ number_to_currency(subscription.next_amount_due, strip_insignificant_zeros: true) } on".html_safe + "Your next payment is #{ currency(subscription.next_amount_due) } on".html_safe end end end diff --git a/saas/app/views/account/settings/_free_plan.html.erb b/saas/app/views/account/settings/_free_plan.html.erb index 1f59ff49f..729c443e6 100644 --- a/saas/app/views/account/settings/_free_plan.html.erb +++ b/saas/app/views/account/settings/_free_plan.html.erb @@ -10,9 +10,9 @@ <% end %> -

To keep using Fizzy <%= "past #{ number_with_delimiter(Plan.free.card_limit) } cards," unless Current.account.exceeding_storage_limit? %> it’s only <%= number_to_currency(Plan.paid.price, strip_insignificant_zeros: true) %>/month for unlimited cards, unlimited users, and <%= storage_to_human_size(Plan.paid.storage_limit) %> of storage.

+

To keep using Fizzy <%= "past #{ number_with_delimiter(Plan.free.card_limit) } cards," unless Current.account.exceeding_storage_limit? %> it’s only <%= currency(Plan.paid.price) %>/month for unlimited cards, unlimited users, and <%= storage_to_human_size(Plan.paid.storage_limit) %> of storage.

-<%= button_to "Upgrade to #{Plan.paid.name} for #{ number_to_currency(Plan.paid.price, strip_insignificant_zeros: true) }/month", account_subscription_path, class: "btn settings-subscription__button txt-medium", form: { data: { turbo: false } } %> +<%= button_to "Upgrade to #{Plan.paid.name} for #{ currency(Plan.paid.price) }/month", account_subscription_path, class: "btn settings-subscription__button txt-medium", form: { data: { turbo: false } } %>

Cancel anytime, no contracts, take your data with you whenever.

diff --git a/saas/app/views/account/settings/_paid_plan.html.erb b/saas/app/views/account/settings/_paid_plan.html.erb index 426568eae..c0997d5f1 100644 --- a/saas/app/views/account/settings/_paid_plan.html.erb +++ b/saas/app/views/account/settings/_paid_plan.html.erb @@ -10,7 +10,7 @@ <% if Current.account.nearing_plan_storage_limit? || Current.account.exceeding_storage_limit? %>

- The <%= Current.account.plan.name %> plan includes <%= storage_to_human_size(Plan.paid.storage_limit) %>. Upgrade to get <%= storage_to_human_size(Plan.paid_with_extra_storage.storage_limit) %> extra storage for <%= number_to_currency(Plan.paid_with_extra_storage.price - Plan.paid.price, strip_insignificant_zeros: true) %>/month more. + The <%= Current.account.plan.name %> plan includes <%= storage_to_human_size(Plan.paid.storage_limit) %>. Upgrade to get <%= storage_to_human_size(Plan.paid_with_extra_storage.storage_limit) %> extra storage for <%= currency(Plan.paid_with_extra_storage.price - Plan.paid.price) %>/month more.

<% end %> diff --git a/saas/app/views/account/settings/_subscription.html.erb b/saas/app/views/account/settings/_subscription.html.erb index c3e629607..5f39347fa 100644 --- a/saas/app/views/account/settings/_subscription.html.erb +++ b/saas/app/views/account/settings/_subscription.html.erb @@ -11,7 +11,7 @@ <% if subscription.plan == Plan.paid %> <%= button_to "Upgrade", account_subscription_upgrade_path, class: "btn btn--plain settings-subscription__link txt-link", form: { class: "flex-inline flex-wrap", data: { turbo: false } } %> - to <%= storage_to_human_size(Plan.paid_with_extra_storage.storage_limit) %> storage for <%= number_to_currency(Plan.paid_with_extra_storage.price - Plan.paid.price, strip_insignificant_zeros: true) %>/month more. + to <%= storage_to_human_size(Plan.paid_with_extra_storage.storage_limit) %> storage for <%= currency(Plan.paid_with_extra_storage.price - Plan.paid.price) %>/month more. <% elsif subscription.plan == Plan.paid_with_extra_storage && !Current.account.exceeding_storage_limit? %> <%= button_to "Downgrade", account_subscription_downgrade_path, class: "btn btn--plain settings-subscription__link txt-link", form: { class: "flex-inline flex-wrap", data: { turbo: false } } %> to <%= storage_to_human_size(Plan.paid.storage_limit) %> storage. From 1f16936b2ef9d9e87554f3f9bc09a15df4fdd3d7 Mon Sep 17 00:00:00 2001 From: Andy Smith Date: Fri, 19 Dec 2025 15:47:04 -0600 Subject: [PATCH 2/2] Move currency helper to existing subscriptions helpers file --- app/helpers/subscriptions_helper.rb | 5 ----- saas/app/helpers/subscriptions_helper.rb | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) delete mode 100644 app/helpers/subscriptions_helper.rb diff --git a/app/helpers/subscriptions_helper.rb b/app/helpers/subscriptions_helper.rb deleted file mode 100644 index e03c5e153..000000000 --- a/app/helpers/subscriptions_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module SubscriptionsHelper - def currency(amount) - number_to_currency(amount, precision: (amount % 1).zero? ? 0 : 2) - end -end diff --git a/saas/app/helpers/subscriptions_helper.rb b/saas/app/helpers/subscriptions_helper.rb index cf8ceb4a9..2b1438d3e 100644 --- a/saas/app/helpers/subscriptions_helper.rb +++ b/saas/app/helpers/subscriptions_helper.rb @@ -12,4 +12,8 @@ def subscription_period_end_action(subscription) "Your next payment is #{ currency(subscription.next_amount_due) } on".html_safe end end + + def currency(amount) + number_to_currency(amount, precision: (amount % 1).zero? ? 0 : 2) + end end