/api/v1/me/payslips items and /api/v1/me/profile now carry the org base currency. Payslip and Profile read it; the payslips screen formats with the payslip currency, else the last profile's, else INR. INR output is unchanged (rupee sign, lakh grouping, no decimals); other currencies show the ISO code with their own minor units (AED 1,234.50, BHD 1,234.500). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
19 lines
851 B
Dart
19 lines
851 B
Dart
import 'package:intl/intl.dart';
|
|
|
|
/// Formats a payroll amount in the organisation's currency.
|
|
///
|
|
/// [currency] is the ISO 4217 code the server sends on payslips / profile
|
|
/// (`currency`). Missing or blank ⇒ INR, which keeps the original output:
|
|
/// rupee sign, Indian lakh grouping, no decimals (e.g. `₹1,23,457`).
|
|
/// Other currencies print the ISO code and the currency's own minor units
|
|
/// (e.g. `AED 12,345.50`, `BHD 1,234.500`).
|
|
String formatMoney(num v, [String? currency]) {
|
|
final code = (currency ?? '').trim().toUpperCase();
|
|
if (code.isEmpty || code == 'INR') {
|
|
return '₹${NumberFormat('#,##,###').format(v)}';
|
|
}
|
|
// NumberFormat.currency picks the ISO default fraction digits for `name`
|
|
// (BHD/KWD/OMR 3, JPY 0, most others 2).
|
|
return NumberFormat.currency(locale: 'en', name: code, symbol: '$code ').format(v);
|
|
}
|