Skip to content

Conversation

@cyprain-okeke
Copy link
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
Copy link
Contributor

github-actions bot commented Jan 8, 2026

Logo
Checkmarx One โ€“ Scan Summary & Details โ€“ 4e343ff5-5868-4f65-829d-b6798a7b6675

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

@codecov
Copy link

codecov bot commented Jan 8, 2026

Codecov Report

โœ… All modified and coverable lines are covered by tests.
โœ… Project coverage is 55.07%. Comparing base (6d69c9b) to head (501b929).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6812   +/-   ##
=======================================
  Coverage   55.07%   55.07%           
=======================================
  Files        1934     1934           
  Lines       85777    85777           
  Branches     7675     7675           
=======================================
+ Hits        47238    47245    +7     
+ Misses      36749    36741    -8     
- Partials     1790     1791    +1     

โ˜” 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.

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.

2 participants