mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
- Define shared payment types and interfaces in payment.ts - Create PaymentModal component for handling payment interactions - Implement payment API client for initiating and confirming payments - Add payment history management with localStorage - Create PaymentsPage for displaying payment status and history - Introduce utility functions for money conversion and formatting - Set up hooks for managing payment flow and state - Update SeamanBookApplicationPage to utilize new payment modal - Add tests for payment API functions and history management
21 lines
771 B
TypeScript
21 lines
771 B
TypeScript
/** Whole-birr major amount -> minor units (cents). Rounds to avoid float drift (19.99 -> 1999). */
|
|
export function toMinor(major: number): number {
|
|
return Math.round(major * 100);
|
|
}
|
|
|
|
export function fromMinor(minor: number): number {
|
|
return minor / 100;
|
|
}
|
|
|
|
/**
|
|
* Matches the format already used across the portal (`ETB ${n.toFixed(2)}`, e.g.
|
|
* SeamanBookApplicationPage.tsx) rather than Intl.NumberFormat({style:'currency'}), whose ETB
|
|
* output varies by ICU build. Not unifying the ~20 existing inline call sites — out of scope here.
|
|
*/
|
|
export function formatMinor(amountMinor: number, currency: string): string {
|
|
return `${currency} ${fromMinor(amountMinor).toLocaleString(undefined, {
|
|
minimumFractionDigits: 2,
|
|
maximumFractionDigits: 2,
|
|
})}`;
|
|
}
|