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:
co-authored by
Claude Opus 5.5
parent
2dbd1a2ea9
commit
2e0d825c24
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import '../api_service.dart';
|
||||
import '../money.dart';
|
||||
import '../theme.dart';
|
||||
|
||||
class PayslipsScreen extends StatefulWidget {
|
||||
@@ -40,7 +41,8 @@ class _PayslipsScreenState extends State<PayslipsScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
String _inr(num v) => '₹${NumberFormat('#,##,###').format(v)}';
|
||||
/// Payslip currency, else the profile's, else INR (older servers).
|
||||
String _money(Payslip p, num v) => formatMoney(v, p.currency ?? widget.api.currency);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -62,7 +64,7 @@ class _PayslipsScreenState extends State<PayslipsScreen> {
|
||||
title: Text(_month(p.periodMonth), style: const TextStyle(fontWeight: FontWeight.w600)),
|
||||
subtitle: const Text('Net pay'),
|
||||
trailing: Column(mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.end, children: [
|
||||
Text(_inr(p.netPay), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: AppColors.emerald)),
|
||||
Text(_money(p, p.netPay), style: const TextStyle(fontSize: 16, fontWeight: FontWeight.bold, color: AppColors.emerald)),
|
||||
Text(p.status, style: const TextStyle(fontSize: 11, color: AppColors.muted)),
|
||||
]),
|
||||
onTap: () => showModalBottomSheet(
|
||||
@@ -72,10 +74,10 @@ class _PayslipsScreenState extends State<PayslipsScreen> {
|
||||
child: Column(mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [
|
||||
Text(_month(p.periodMonth), style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: AppColors.navy)),
|
||||
const SizedBox(height: 16),
|
||||
_row('Gross earnings', _inr(p.gross)),
|
||||
_row('Total deductions', '− ${_inr(p.totalDeductions)}'),
|
||||
_row('Gross earnings', _money(p, p.gross)),
|
||||
_row('Total deductions', '− ${_money(p, p.totalDeductions)}'),
|
||||
const Divider(height: 24),
|
||||
_row('Net pay', _inr(p.netPay), bold: true),
|
||||
_row('Net pay', _money(p, p.netPay), bold: true),
|
||||
const SizedBox(height: 16),
|
||||
const Text('Full PDF payslip is available on the Scalar360 web portal.',
|
||||
style: TextStyle(fontSize: 12, color: AppColors.muted)),
|
||||
|
||||
Reference in New Issue
Block a user