Payslips: format amounts in the org currency

/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>
This commit is contained in:
athul rd
2026-10-19 22:34:56 +05:30
co-authored by Claude Opus 5.5
parent 2dbd1a2ea9
commit 2e0d825c24
4 changed files with 42 additions and 38 deletions
+18
View File
@@ -0,0 +1,18 @@
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);
}