Skip to content

[PM 30576]Make Invoice Response currency culture invariant - #6812

Merged
cyprain-okeke merged 2 commits into
mainfrom
billing/pm-30576/make-invoice-response-currency-culture-invariant
Jan 15, 2026
Merged

[PM 30576]Make Invoice Response currency culture invariant#6812
cyprain-okeke merged 2 commits into
mainfrom
billing/pm-30576/make-invoice-response-currency-culture-invariant

Conversation

@cyprain-okeke

Copy link
Copy Markdown
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-30576

📔 Objective

The FormatForProvider method in InvoiceExtensions was using culture-aware decimal formatting ({pricePerItem:F2} and {taxAmount:F2}), which caused test failures on machines with non-US locales. On systems with comma decimal separators (e.g., European locales), the formatting would produce "$8,00" instead of the expected "$8.00", causing the FormatForProvider_ComplexScenario_HandlesAllLineTypes test to fail.

Example failure:

Expected: "1 × Tax (at $8.00 / month)"
Actual:   "1 × Tax (at $8,00 / month)"

Solution

Updated the currency formatting to use CultureInfo.InvariantCulture when formatting decimal values, ensuring consistent output regardless of system locale:

  1. Line 55: Changed tax line item price formatting from $"(at ${pricePerItem:F2} / month)" to string.Format(CultureInfo.InvariantCulture, "(at ${0:F2} / month)", pricePerItem)

  2. Line 74: Changed invoice-level tax formatting from $"1 × Tax (at ${taxAmount:F2} / month)" to string.Format(CultureInfo.InvariantCulture, "1 × Tax (at ${0:F2} / month)", taxAmount)

  3. Added import: Added using System.Globalization; to support CultureInfo.InvariantCulture

Impact

  • Fixes test failures: Tests now pass consistently on all machines regardless of system locale
  • Consistent formatting: Invoice currency values always use period (.) as decimal separator, which is correct for USD formatting
  • No breaking changes: On en-US systems, output remains identical ("$8.00")
  • Fixes locale-dependent bug: Systems with comma decimal separators now produce correct output

Testing

  • All existing tests pass, including FormatForProvider_ComplexScenario_HandlesAllLineTypes
  • Verified formatting is consistent across different system locales
  • No changes to test expectations needed (tests already expected period format)

Related

This addresses the issue where PR #6622 attempted to fix the test by setting thread culture, but the root cause was in the implementation using culture-aware formatting. This fix addresses the root cause in the implementation itself.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@cyprain-okeke
cyprain-okeke requested a review from a team as a code owner January 8, 2026 15:02
@cyprain-okeke
cyprain-okeke requested a review from kdenney January 8, 2026 15:02
@github-actions

github-actions Bot commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

Logo
Checkmarx One – Scan Summary & Detailsccb28656-dd89-4829-96fb-9b9522711495

Great job! No new security vulnerabilities introduced in this pull request

@codecov

codecov Bot commented Jan 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.94%. Comparing base (d1fdaa6) to head (492845e).
⚠️ Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6812      +/-   ##
==========================================
- Coverage   55.95%   55.94%   -0.02%     
==========================================
  Files        1964     1964              
  Lines       86791    86791              
  Branches     7729     7729              
==========================================
- Hits        48567    48558       -9     
- Misses      36425    36434       +9     
  Partials     1799     1799              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@cyprain-okeke
cyprain-okeke merged commit 2e0e103 into main Jan 15, 2026
42 checks passed
@cyprain-okeke
cyprain-okeke deleted the billing/pm-30576/make-invoice-response-currency-culture-invariant branch January 15, 2026 08:55
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.

3 participants