Skip to content

fix: remove incorrect cents-to-dollars conversion in notification email amounts#75

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782715341-fix-notification-amount-display
Open

fix: remove incorrect cents-to-dollars conversion in notification email amounts#75
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1782715341-fix-notification-amount-display

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Order confirmation emails displayed wrong amounts (e.g., $149.99 order showed as $1.50) because NotificationRenderer.FormatCurrency() incorrectly divided by 100:

// NotificationRenderer.cs
  private static string FormatCurrency(decimal amount)
  {
-     // The OrderPlacedEvent.TotalAmount is transmitted in cents ...
-     var dollars = amount / 100m;
-     return dollars.ToString("C2");
+     return amount.ToString("C2");
  }

The comment claimed OrderPlacedEvent.TotalAmount was in cents, but the shared contract (Shared.Contracts.Events.OrderPlacedEvent) defines it as decimal TotalAmount — already in dollars. The division turned 149.99 into 1.4999, which rounded to $1.50.

Also fixes Notification.API.csproj project reference paths to Shared libraries (../../Shared -> ../../../Shared) to match the actual directory layout under src/.

Root Cause Analysis

The bug was introduced during microservice decomposition. The FormatCurrency method was written with an incorrect assumption (documented in a misleading comment) that the TotalAmount field was transmitted in cents for "floating-point precision" reasons. In reality, the OrderPlacedEvent contract uses decimal (which has no floating-point precision issues) and transmits the dollar amount directly.

Before

before

After

after

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/bf6d422091a1474691a1c26910179d93
Requested by: @alagarrajanm

…il amounts

FormatCurrency() divided the amount by 100 based on a wrong assumption that
OrderPlacedEvent.TotalAmount was in cents. The contract sends dollars (decimal),
so a $149.99 order displayed as $1.50 in confirmation emails.

Also fixes Notification.API.csproj Shared project reference paths (../../Shared
-> ../../../Shared) to match the actual directory structure.
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants