Use configured currency symbol in email templates #59

Merged
Copilot merged 5 commits from copilot/sub-pr-58 into v0.4.8 2025-11-15 18:59:16 -05:00
Copilot commented 2025-11-15 18:46:53 -05:00 (Migrated from github.com)

Email templates for high cost alerts and renewal reminders used hard-coded $ symbols instead of respecting the user's configured currency setting.

Changes

  • Modified SendHighCostAlert() and SendRenewalReminder() to retrieve currency symbol via GetCurrencySymbol()
  • Updated email templates to use {{.CurrencySymbol}} instead of hard-coded $
  • Updated email subject lines to include dynamic currency symbol

Example

// Before: Always showed $
subject := fmt.Sprintf("High Cost Alert: %s - $%.2f/month", subscription.Name, subscription.MonthlyCost())

// After: Uses configured currency (€, £, ¥, etc.)
currencySymbol := e.settingsService.GetCurrencySymbol()
subject := fmt.Sprintf("High Cost Alert: %s - %s%.2f/month", subscription.Name, currencySymbol, subscription.MonthlyCost())

Email notifications now display the correct currency symbol for users with non-USD currency preferences.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Email templates for high cost alerts and renewal reminders used hard-coded `$` symbols instead of respecting the user's configured currency setting. **Changes** - Modified `SendHighCostAlert()` and `SendRenewalReminder()` to retrieve currency symbol via `GetCurrencySymbol()` - Updated email templates to use `{{.CurrencySymbol}}` instead of hard-coded `$` - Updated email subject lines to include dynamic currency symbol **Example** ```go // Before: Always showed $ subject := fmt.Sprintf("High Cost Alert: %s - $%.2f/month", subscription.Name, subscription.MonthlyCost()) // After: Uses configured currency (€, £, ¥, etc.) currencySymbol := e.settingsService.GetCurrencySymbol() subject := fmt.Sprintf("High Cost Alert: %s - %s%.2f/month", subscription.Name, currencySymbol, subscription.MonthlyCost()) ``` Email notifications now display the correct currency symbol for users with non-USD currency preferences. <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
Copilot commented 2025-11-15 18:54:09 -05:00 (Migrated from github.com)

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • smtp.example.com
    • Triggering command: /tmp/go-build4191140555/b310/service.test -test.testlogfile=/tmp/go-build4191140555/b310/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details. > [!WARNING] > > <details> > <summary>Firewall rules blocked me from connecting to one or more addresses (expand for details)</summary> > > #### I tried to connect to the following addresses, but was blocked by firewall rules: > > - `smtp.example.com` > - Triggering command: `/tmp/go-build4191140555/b310/service.test -test.testlogfile=/tmp/go-build4191140555/b310/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true` (dns block) > > If you need me to access, download, or install something from one of these locations, you can either: > > - Configure [Actions setup steps](https://gh.io/copilot/actions-setup-steps) to set up my environment, which run before the firewall is enabled > - Add the appropriate URLs or hosts to the custom allowlist in this repository's [Copilot coding agent settings](https://github.com/bscott/subtrackr/settings/copilot/coding_agent) (admins only) > > </details>
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-11-15 18:55:32 -05:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR updates email notification templates to use dynamic currency symbols instead of hard-coded dollar signs. The changes ensure that high-cost alerts and renewal reminder emails display the user's configured currency symbol.

  • Updated email templates to use dynamic currency symbols retrieved from user settings
  • Refactored template data structures to pass currency symbol along with subscription data
  • Moved github.com/dromara/carbon/v2 from indirect to direct dependency

Reviewed Changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
internal/service/email.go Added currency symbol retrieval and updated email templates to use dynamic currency symbols in both high-cost alerts and renewal reminders
go.mod Moved github.com/dromara/carbon/v2 from indirect to direct dependency and removed unused github.com/stretchr/objx indirect dependency
go.sum Removed unused github.com/stretchr/objx v0.5.2 entries

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

## Pull Request Overview This PR updates email notification templates to use dynamic currency symbols instead of hard-coded dollar signs. The changes ensure that high-cost alerts and renewal reminder emails display the user's configured currency symbol. - Updated email templates to use dynamic currency symbols retrieved from user settings - Refactored template data structures to pass currency symbol along with subscription data - Moved `github.com/dromara/carbon/v2` from indirect to direct dependency ### Reviewed Changes Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments. | File | Description | | ---- | ----------- | | internal/service/email.go | Added currency symbol retrieval and updated email templates to use dynamic currency symbols in both high-cost alerts and renewal reminders | | go.mod | Moved `github.com/dromara/carbon/v2` from indirect to direct dependency and removed unused `github.com/stretchr/objx` indirect dependency | | go.sum | Removed unused `github.com/stretchr/objx v0.5.2` entries | --- 💡 <a href="/bscott/subtrackr/new/main/.github/instructions?filename=*.instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add Copilot custom instructions</a> for smarter, more guided reviews. <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn how to get started</a>.
@ -193,12 +196,12 @@ func (e *EmailService) SendHighCostAlert(subscription *models.Subscription) erro
</div>
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-11-15 18:55:32 -05:00

MonthlyCost is a method, not a field. The template should call it as a method: {{.Subscription.MonthlyCost}} without the printf since MonthlyCost() already returns a float64. The current code will fail at runtime because Go templates cannot call methods with printf directly on method return values in this way.

			<div class="detail-row"><span class="label">Monthly Cost:</span> {{.CurrencySymbol}}{{printf "%.2f" (.Subscription.MonthlyCost)}}</div>
MonthlyCost is a method, not a field. The template should call it as a method: `{{.Subscription.MonthlyCost}}` without the `printf` since `MonthlyCost()` already returns a float64. The current code will fail at runtime because Go templates cannot call methods with `printf` directly on method return values in this way. ```suggestion <div class="detail-row"><span class="label">Monthly Cost:</span> {{.CurrencySymbol}}{{printf "%.2f" (.Subscription.MonthlyCost)}}</div> ```
@ -251,16 +267,16 @@ func (e *EmailService) SendRenewalReminder(subscription *models.Subscription, da
<div class="container">
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-11-15 18:55:32 -05:00

MonthlyCost is a method, not a field. The template should call it as a method: {{.Subscription.MonthlyCost}} without the printf since MonthlyCost() already returns a float64. The current code will fail at runtime because Go templates cannot call methods with printf directly on method return values in this way.

			<div class="detail-row"><span class="label">Monthly Cost:</span> {{.CurrencySymbol}}{{printf "%.2f" (.Subscription.MonthlyCost)}}</div>
MonthlyCost is a method, not a field. The template should call it as a method: `{{.Subscription.MonthlyCost}}` without the `printf` since `MonthlyCost()` already returns a float64. The current code will fail at runtime because Go templates cannot call methods with `printf` directly on method return values in this way. ```suggestion <div class="detail-row"><span class="label">Monthly Cost:</span> {{.CurrencySymbol}}{{printf "%.2f" (.Subscription.MonthlyCost)}}</div> ```
bscott (Migrated from github.com) approved these changes 2025-11-15 18:59:03 -05:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
bscott/subtrackr!59
No description provided.