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
+17
-3
@@ -14,6 +14,8 @@ class Profile {
|
||||
final String gid, fullName, role;
|
||||
final String? employeeCode, departmentName, designationTitle, reportingManagerName;
|
||||
final bool isManager;
|
||||
/// Org base currency (ISO 4217); null on older servers ⇒ INR.
|
||||
final String? currency;
|
||||
Profile.fromJson(Map<String, dynamic> j)
|
||||
: gid = j['gid'] ?? '',
|
||||
fullName = j['fullName'] ?? '',
|
||||
@@ -22,7 +24,8 @@ class Profile {
|
||||
departmentName = j['departmentName'],
|
||||
designationTitle = j['designationTitle'],
|
||||
reportingManagerName = j['reportingManagerName'],
|
||||
isManager = j['isManager'] == true;
|
||||
isManager = j['isManager'] == true,
|
||||
currency = j['currency'] as String?;
|
||||
}
|
||||
|
||||
class Today {
|
||||
@@ -81,13 +84,16 @@ class LeaveRequest {
|
||||
class Payslip {
|
||||
final String gid, periodMonth, status;
|
||||
final num gross, totalDeductions, netPay;
|
||||
/// Org base currency (ISO 4217); null on older servers ⇒ INR.
|
||||
final String? currency;
|
||||
Payslip.fromJson(Map<String, dynamic> j)
|
||||
: gid = j['gid'] ?? '',
|
||||
periodMonth = j['periodMonth'] ?? '',
|
||||
status = j['status'] ?? '',
|
||||
gross = j['gross'] ?? 0,
|
||||
totalDeductions = j['totalDeductions'] ?? 0,
|
||||
netPay = j['netPay'] ?? 0;
|
||||
netPay = j['netPay'] ?? 0,
|
||||
currency = j['currency'] as String?;
|
||||
}
|
||||
|
||||
class TeamMember {
|
||||
@@ -110,6 +116,9 @@ class ApiService {
|
||||
final Settings settings;
|
||||
ApiService(this.settings);
|
||||
|
||||
/// Org base currency from the last profile seen (login or /me/profile).
|
||||
String? currency;
|
||||
|
||||
Uri _uri(String p, [Map<String, String>? q]) =>
|
||||
Uri.parse('${Settings.baseUrl}$p').replace(queryParameters: q);
|
||||
|
||||
@@ -135,12 +144,17 @@ class ApiService {
|
||||
throw ApiException(_msg(body) ?? 'Invalid email or PIN', res.statusCode);
|
||||
}
|
||||
final p = Profile.fromJson(body['profile'] as Map<String, dynamic>);
|
||||
currency = p.currency ?? currency;
|
||||
await settings.saveSession(token: body['accessToken'] as String, name: p.fullName, role: p.role);
|
||||
return p;
|
||||
}
|
||||
|
||||
// ---- me ----
|
||||
Future<Profile> profile() async => Profile.fromJson(await _get('/api/v1/me/profile'));
|
||||
Future<Profile> profile() async {
|
||||
final p = Profile.fromJson(await _get('/api/v1/me/profile'));
|
||||
currency = p.currency ?? currency;
|
||||
return p;
|
||||
}
|
||||
Future<Today> today() async => Today.fromJson(await _get('/api/v1/me/attendance/today'));
|
||||
|
||||
Future<void> checkIn({double? lat, double? lng, String? selfie}) =>
|
||||
|
||||
Reference in New Issue
Block a user