From ac4dd0110028ead733a2dd0500815298a55608ef Mon Sep 17 00:00:00 2001 From: Hari-egov Date: Fri, 9 Aug 2024 18:02:08 +0530 Subject: [PATCH] Ledger update --- .../mgramseva/lib/model/reports/leadger_report.dart | 10 +++++++++- .../mgramseva/lib/providers/reports_provider.dart | 11 ++++++++--- .../mgramseva/lib/screeens/reports/leadger_table.dart | 3 --- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/frontend/mgramseva/lib/model/reports/leadger_report.dart b/frontend/mgramseva/lib/model/reports/leadger_report.dart index d8158f6b5..c0549bba7 100644 --- a/frontend/mgramseva/lib/model/reports/leadger_report.dart +++ b/frontend/mgramseva/lib/model/reports/leadger_report.dart @@ -38,8 +38,14 @@ class LedgerData { class MonthData { final LeadgerDemand? demand; final List? payment; + final num? totalPaymentInMonth; + final num? totalBalanceLeftInMonth; - MonthData({this.demand, this.payment}); + MonthData( + {this.demand, + this.payment, + this.totalPaymentInMonth, + this.totalBalanceLeftInMonth}); factory MonthData.fromJson(Map json) { return MonthData( @@ -47,6 +53,8 @@ class MonthData { payment: (json['payment'] as List?) ?.map((e) => LeadgerPayment.fromJson(e)) .toList(), + totalPaymentInMonth: json['totalPaymentInMonth'] as num?, + totalBalanceLeftInMonth: json['totalBalanceLeftInMonth'] as num?, ); } } diff --git a/frontend/mgramseva/lib/providers/reports_provider.dart b/frontend/mgramseva/lib/providers/reports_provider.dart index d572810cc..7b69a0f12 100644 --- a/frontend/mgramseva/lib/providers/reports_provider.dart +++ b/frontend/mgramseva/lib/providers/reports_provider.dart @@ -193,6 +193,10 @@ class ReportsProvider with ChangeNotifier { } } + String formatPaymentReceipts(List? payments) { + return payments?.map((payment) => payment.receiptNo)?.join(', ') ?? ''; + } + TableDataRow getLedgerRow(LedgerData data, {bool isExcel = false}) { return TableDataRow([ TableData( @@ -207,10 +211,11 @@ class ReportsProvider with ChangeNotifier { '${DateFormats.leadgerTimeStampToDate(data.months?.values.first.demand?.dueDateOfPayment)}'), TableData( '${DateFormats.leadgerTimeStampToDate(data.months?.values.first.payment?.first.paymentCollectionDate)}'), - TableData('${data.months?.values.first.payment?.first.receiptNo}'), - TableData('₹ ${data.months?.values.first.payment?.first.amountPaid}'), + // TableData('${data.months?.values.first.payment?.first.receiptNo}'), + TableData('${formatPaymentReceipts(data.months?.values?.first.payment)}'), + TableData('₹ ${data.months?.values.first.totalPaymentInMonth}'), TableData( - '₹ ${(double.parse("${data.months?.values.first.demand?.totalDues}") - double.parse("${data.months?.values.first.payment?.first.amountPaid}"))}'), + '₹ ${(double.parse("${data.months?.values.first.demand?.totalDues}") - double.parse("${data.months?.values.first.totalPaymentInMonth}"))}'), TableData( '${DateFormats.leadgerTimeStampToDate(data.months?.values.first.demand?.penaltyAppliedOnDate)}'), TableData('₹ ${data.months?.values.first.demand?.penalty}'), diff --git a/frontend/mgramseva/lib/screeens/reports/leadger_table.dart b/frontend/mgramseva/lib/screeens/reports/leadger_table.dart index 8f04672ce..49d1e6a90 100644 --- a/frontend/mgramseva/lib/screeens/reports/leadger_table.dart +++ b/frontend/mgramseva/lib/screeens/reports/leadger_table.dart @@ -3,9 +3,6 @@ import 'package:mgramseva/model/connection/water_connection.dart'; import 'package:mgramseva/utils/constants/i18_key_constants.dart'; import 'package:provider/provider.dart'; import '../../providers/reports_provider.dart'; -import '../../utils/constants.dart'; -import '../../utils/date_formats.dart'; -import '../../utils/global_variables.dart'; import '../../utils/localization/application_localizations.dart'; import '../../widgets/label_text.dart'; import '../../widgets/pagination.dart';