displayed comma seperated amount on expenses
This commit is contained in:
parent
2013447904
commit
9feb9d1b4b
@ -274,8 +274,7 @@ class ExpenseList extends StatelessWidget {
|
|||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
MyText.titleLarge("Delete Expense",
|
MyText.titleLarge("Delete Expense",
|
||||||
fontWeight: 600,
|
fontWeight: 600,
|
||||||
color:
|
color: Theme.of(context).colorScheme.onBackground),
|
||||||
Theme.of(context).colorScheme.onBackground),
|
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
MyText.bodySmall(
|
MyText.bodySmall(
|
||||||
"Are you sure you want to delete this draft expense?",
|
"Are you sure you want to delete this draft expense?",
|
||||||
@ -392,8 +391,7 @@ class ExpenseList extends StatelessWidget {
|
|||||||
fontWeight: 600),
|
fontWeight: 600),
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
MyText.bodyMedium(
|
MyText.bodyMedium('₹ ${expense.formattedAmount}',
|
||||||
'₹ ${expense.amount.toStringAsFixed(2)}',
|
|
||||||
fontWeight: 600),
|
fontWeight: 600),
|
||||||
if (expense.status.name.toLowerCase() == 'draft') ...[
|
if (expense.status.name.toLowerCase() == 'draft') ...[
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
import 'package:intl/intl.dart';
|
||||||
|
|
||||||
/// Parse the entire response
|
/// Parse the entire response
|
||||||
ExpenseResponse expenseResponseFromJson(String str) =>
|
ExpenseResponse expenseResponseFromJson(String str) =>
|
||||||
@ -112,8 +113,9 @@ class Filter {
|
|||||||
statusIds: List<String>.from(json["statusIds"] ?? []),
|
statusIds: List<String>.from(json["statusIds"] ?? []),
|
||||||
createdByIds: List<String>.from(json["createdByIds"] ?? []),
|
createdByIds: List<String>.from(json["createdByIds"] ?? []),
|
||||||
paidById: List<String>.from(json["paidById"] ?? []),
|
paidById: List<String>.from(json["paidById"] ?? []),
|
||||||
startDate:
|
startDate: json["startDate"] != null
|
||||||
json["startDate"] != null ? DateTime.tryParse(json["startDate"]) : null,
|
? DateTime.tryParse(json["startDate"])
|
||||||
|
: null,
|
||||||
endDate:
|
endDate:
|
||||||
json["endDate"] != null ? DateTime.tryParse(json["endDate"]) : null,
|
json["endDate"] != null ? DateTime.tryParse(json["endDate"]) : null,
|
||||||
);
|
);
|
||||||
@ -162,6 +164,16 @@ class ExpenseModel {
|
|||||||
required this.preApproved,
|
required this.preApproved,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/// ✅ Comma-separated amount getter with currency symbol
|
||||||
|
String get formattedAmount {
|
||||||
|
final formatter = NumberFormat.currency(
|
||||||
|
locale: 'en_IN',
|
||||||
|
symbol: '₹ ',
|
||||||
|
decimalDigits: 2,
|
||||||
|
);
|
||||||
|
return formatter.format(amount);
|
||||||
|
}
|
||||||
|
|
||||||
factory ExpenseModel.fromJson(Map<String, dynamic> json) => ExpenseModel(
|
factory ExpenseModel.fromJson(Map<String, dynamic> json) => ExpenseModel(
|
||||||
id: json["id"] ?? '',
|
id: json["id"] ?? '',
|
||||||
project: Project.fromJson(json["project"] ?? {}),
|
project: Project.fromJson(json["project"] ?? {}),
|
||||||
@ -171,8 +183,7 @@ class ExpenseModel {
|
|||||||
createdBy: CreatedBy.fromJson(json["createdBy"] ?? {}),
|
createdBy: CreatedBy.fromJson(json["createdBy"] ?? {}),
|
||||||
transactionDate:
|
transactionDate:
|
||||||
DateTime.tryParse(json["transactionDate"] ?? '') ?? DateTime.now(),
|
DateTime.tryParse(json["transactionDate"] ?? '') ?? DateTime.now(),
|
||||||
createdAt:
|
createdAt: DateTime.tryParse(json["createdAt"] ?? '') ?? DateTime.now(),
|
||||||
DateTime.tryParse(json["createdAt"] ?? '') ?? DateTime.now(),
|
|
||||||
supplerName: json["supplerName"] ?? '',
|
supplerName: json["supplerName"] ?? '',
|
||||||
amount: (json["amount"] ?? 0).toDouble(),
|
amount: (json["amount"] ?? 0).toDouble(),
|
||||||
status: Status.fromJson(json["status"] ?? {}),
|
status: Status.fromJson(json["status"] ?? {}),
|
||||||
@ -226,8 +237,7 @@ class Project {
|
|||||||
shortName: json["shortName"] ?? '',
|
shortName: json["shortName"] ?? '',
|
||||||
projectAddress: json["projectAddress"] ?? '',
|
projectAddress: json["projectAddress"] ?? '',
|
||||||
contactPerson: json["contactPerson"] ?? '',
|
contactPerson: json["contactPerson"] ?? '',
|
||||||
startDate:
|
startDate: DateTime.tryParse(json["startDate"] ?? '') ?? DateTime.now(),
|
||||||
DateTime.tryParse(json["startDate"] ?? '') ?? DateTime.now(),
|
|
||||||
endDate: DateTime.tryParse(json["endDate"] ?? '') ?? DateTime.now(),
|
endDate: DateTime.tryParse(json["endDate"] ?? '') ?? DateTime.now(),
|
||||||
projectStatusId: json["projectStatusId"] ?? '',
|
projectStatusId: json["projectStatusId"] ?? '',
|
||||||
);
|
);
|
||||||
@ -390,7 +400,7 @@ class Status {
|
|||||||
name: json["name"] ?? '',
|
name: json["name"] ?? '',
|
||||||
displayName: json["displayName"] ?? '',
|
displayName: json["displayName"] ?? '',
|
||||||
description: json["description"] ?? '',
|
description: json["description"] ?? '',
|
||||||
color: (json["color"] ?? '').replaceAll("'", ''),
|
color: (json["color"] ?? '').replaceAll("'", ''),
|
||||||
isSystem: json["isSystem"] ?? false,
|
isSystem: json["isSystem"] ?? false,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import 'package:marco/helpers/widgets/expense_main_components.dart';
|
|||||||
import 'package:marco/helpers/utils/permission_constants.dart';
|
import 'package:marco/helpers/utils/permission_constants.dart';
|
||||||
import 'package:marco/helpers/widgets/my_refresh_indicator.dart';
|
import 'package:marco/helpers/widgets/my_refresh_indicator.dart';
|
||||||
|
|
||||||
|
|
||||||
class ExpenseMainScreen extends StatefulWidget {
|
class ExpenseMainScreen extends StatefulWidget {
|
||||||
const ExpenseMainScreen({super.key});
|
const ExpenseMainScreen({super.key});
|
||||||
|
|
||||||
@ -105,7 +106,7 @@ class _ExpenseMainScreenState extends State<ExpenseMainScreen> {
|
|||||||
child: filteredList.isEmpty
|
child: filteredList.isEmpty
|
||||||
? ListView(
|
? ListView(
|
||||||
physics:
|
physics:
|
||||||
const AlwaysScrollableScrollPhysics(), // important
|
const AlwaysScrollableScrollPhysics(),
|
||||||
children: [
|
children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
height: MediaQuery.of(context).size.height * 0.5,
|
height: MediaQuery.of(context).size.height * 0.5,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user