fix: remove erroneous cents-to-dollars division in notification currency formatting#32
Conversation
…ncy formatting The NotificationRenderer.FormatCurrency() method was dividing the amount by 100, incorrectly assuming TotalAmount was transmitted in cents. However, the OrderPlacedEvent contract (Shared.Contracts) defines TotalAmount as a decimal in dollars. This caused a $149.99 order to display as $1.50 in email previews. Also fixes incorrect project reference paths for Shared.Contracts and Shared.Infrastructure in Notification.API.csproj (was ../../ instead of ../../../).
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Can you double check that this is the only place this bug exists? Also, please add inline comments around what you changed |
|
@bsmitches Searched the entire I've also pushed a follow-up commit (fc0f935) adding an inline XML doc comment on |
Summary
Fixes incorrect order amounts displayed in notification email previews. A $149.99 order was rendering as $1.50 due to an erroneous division by 100 in the
NotificationRenderer.FormatCurrency()method.Root Cause
During the microservice decomposition, the
NotificationRenderer.FormatCurrency()method was written with an incorrect assumption documented in a misleading comment:However, the
OrderPlacedEventcontract inShared.ContractsdefinesTotalAmountas adecimalrepresenting dollars, not cents. The Order service sends149.99(dollars), but the renderer divides by 100, producing1.4999→ rounded to$1.50.Fix
Removed the
/100mdivision — the amount is already in dollars and just needs formatting:Also fixed incorrect
ProjectReferencepaths inNotification.API.csproj(../../Shared/→../../../Shared/) which prevented the project from building when referenced directly.Before / After
Review & Testing Checklist for Human
TotalAmountin dollars (not cents) when publishingOrderPlacedEventvia RabbitMQ in production — this fix assumes the HTTP testing endpoint matches the real contractNotes
¤symbol in screenshots is the generic currency symbol used by .NET'sToString("C2")when running in invariant culture. In production with proper locale settings, this would display as$..csprojpath fix (../../→../../../) was necessary to allow the Notification.API project to build standalone (resolves project reference to Shared.Contracts).Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/23895db2644343bca01a035cc250ced1
Requested by: @bsmitches