Skip to content

feat: standardize currency display across platform#447

Merged
codeZe-us merged 1 commit into
SafeVault:devfrom
abbakargarba:feature/Fix-and-Standardize-Currency-Display
Apr 26, 2026
Merged

feat: standardize currency display across platform#447
codeZe-us merged 1 commit into
SafeVault:devfrom
abbakargarba:feature/Fix-and-Standardize-Currency-Display

Conversation

@abbakargarba
Copy link
Copy Markdown

@abbakargarba abbakargarba commented Apr 26, 2026

closes #436

Title

feat: implement global currency formatting utility for standardized monetary display


Overview

This PR introduces a global currency formatting utility to standardize how money is displayed across the platform, securely converting backend bigint kobo values into displayable currency values.

It centralizes formatting logic, improves consistency across dashboards and financial views, and supports localized formatting using Intl.NumberFormat.


🚀 Implementation Approach

Key Changes

Global formatCurrency Utility

Created:

src/utils/formatters.ts

Features:

  • Uses Intl.NumberFormat for localized formatting

  • Converts kobo → NGN by dividing by 100

  • Supports multiple currencies:

    • NGN
    • USD
    • EUR
    • Extendable for others

Example output:

₦1,500.00

Graceful Value Handling

Safely handles:

  • null
  • undefined
  • invalid values

Includes fallback behavior to prevent UI failures.


Updated Components

Integrated the formatter across 6 component files:

Finance

  • NairaTransactionHistory.tsx

Payroll

  • PayoutHistory.tsx

Invoices

  • invoices/page.tsx
  • invoices/[id]/page.tsx
  • InvoiceSummary.tsx
  • InvoiceDetailsSection.tsx

🧪 Testing

Added:

src/utils/formatters.test.ts

Includes unit coverage for:

  • Kobo conversion
  • Decimal placement
  • Thousands separators
  • Currency symbols
  • Invalid input handling
  • Multi-currency formatting

🔧 Technical Details

Backend Integration

Safely converts:

bigint (kobo) → formatted NGN display

Localization

Uses:

Intl.NumberFormat

with proper locale-aware formatting.


Type Safety

  • Full TypeScript support
  • Typed interfaces for formatting options
  • Safe parameter handling

Error Handling

  • Graceful fallback for invalid values
  • Prevents runtime formatting failures

Consistency

All monetary displays now use a single formatting standard.


📁 Files Changed

New Files

  • src/utils/formatters.ts
  • src/utils/formatters.test.ts

Updated Files

  • src/app/(dashboard)/invoices/[id]/page.tsx
  • src/app/(dashboard)/invoices/page.tsx
  • src/app/(dashboard)/payroll/components/PayoutHistory.tsx
  • src/components/features/finance/NairaTransactionHistory.tsx
  • src/components/features/invoices/InvoiceSummary.tsx
  • src/components/features/invoices/InvoiceDetailsSection.tsx

✅ What Done Looks Like

  • ✅ Currency values formatted safely across dashboards, invoices, and payroll
  • ✅ Commas and decimals rendered consistently
  • ✅ Backend kobo values converted correctly to NGN display
  • ✅ Localized formatting via Intl.NumberFormat
  • ✅ Production-ready with comprehensive test coverage

📋 Testing Results

  • ✅ Unit tests pass for all formatting scenarios
  • ✅ TypeScript compiles with no errors
  • ✅ Existing functionality preserved
  • ✅ Backward compatibility maintained

📈 Impact

  • Consistency: One standard for all currency rendering
  • Accuracy: Prevents incorrect kobo-to-naira display
  • Maintainability: Centralized formatting logic reduces duplication
  • Localization: Supports future multi-currency expansion
  • Reliability: Handles invalid or missing values safely

⚠️ Breaking Changes

None — fully backward compatible.


🌿 Branch

Source:
feature/Fix-and-Standardize-Currency-Display

Target:
dev


✅ Checklist

  • ✅ Global formatter implemented
  • ✅ All target components updated
  • ✅ Tests added and passing
  • ✅ Type safety maintained
  • ✅ Localization supported
  • ✅ Backward compatibility preserved
  • ✅ Ready for review

- Add global formatCurrency utility in src/utils/formatters.ts
- Implement secure kobo-to-NGN conversion using Intl.NumberFormat
- Update 6 components to use centralized currency formatting
- Add comprehensive unit tests for formatter utility
- Ensure consistent currency display across finance, payroll, and invoices

Files changed:
- src/utils/formatters.ts (new)
- src/utils/formatters.test.ts (new)
- src/app/(dashboard)/invoices/[id]/page.tsx
- src/app/(dashboard)/invoices/page.tsx
- src/app/(dashboard)/payroll/components/PayoutHistory.tsx
- src/components/features/finance/NairaTransactionHistory.tsx
- src/components/features/invoices/InvoiceSummary.tsx
- src/components/features/invoices/InvoiceDetailsSection.tsx
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 26, 2026

@abbakargarba is attempting to deploy a commit to the vestroll's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

@codeZe-us codeZe-us left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abbakargarba Good work

@codeZe-us codeZe-us merged commit 19e23a4 into SafeVault:dev Apr 26, 2026
2 of 3 checks passed
@abbakargarba
Copy link
Copy Markdown
Author

@abbakargarba Good work

thank you boss

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants