From 2497d79f0cc3ec90dd0481f736442a91c77f4a91 Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Thu, 30 Nov 2023 02:24:03 +0530 Subject: [PATCH] Pfm 4081 (#672) --- .../consumer_bill_payment.dart | 319 ++++++++--------- .../model/connection/water_connection.dart | 4 +- .../model/connection/water_connection.g.dart | 4 +- .../providers/collect_payment_provider.dart | 325 +++++++++--------- .../household_register_provider.dart | 6 +- .../lib/utils/printer/image_utils.dart | 3 +- .../lib/widgets/bluetooth_printer.dart | 4 +- 7 files changed, 343 insertions(+), 322 deletions(-) diff --git a/frontend/mgramseva/lib/components/house_connection_and_bill/consumer_bill_payment.dart b/frontend/mgramseva/lib/components/house_connection_and_bill/consumer_bill_payment.dart index a6b235d27..c8b14b349 100644 --- a/frontend/mgramseva/lib/components/house_connection_and_bill/consumer_bill_payment.dart +++ b/frontend/mgramseva/lib/components/house_connection_and_bill/consumer_bill_payment.dart @@ -47,17 +47,20 @@ class ConsumerBillPaymentsState extends State { Container( margin: EdgeInsets.zero, padding: EdgeInsets.zero, - width: kIsWeb ? 150 : 65, + width: kIsWeb ? 150 : 80, child: Text(ApplicationLocalizations.of(context).translate(key), maxLines: 3, textScaleFactor: kIsWeb ? 2.5 : 1, textAlign: TextAlign.start, style: TextStyle( - color: Colors.red, - fontSize: kIsWeb ? 5 : 6, - fontWeight: FontWeight.w900))), + color: Colors.black, + fontSize: kIsWeb ? 5 : 9, + fontWeight: FontWeight.w500))), + SizedBox( + width: 5, + ), Container( - width: kIsWeb ? 215 : 85, + width: kIsWeb ? 215 : 110, child: Text( ApplicationLocalizations.of(navigatorKey.currentContext!) .translate(value), @@ -65,9 +68,9 @@ class ConsumerBillPaymentsState extends State { textAlign: TextAlign.start, textScaleFactor: kIsWeb ? 2.5 : 1, style: TextStyle( - color: Colors.red, - fontSize: kIsWeb ? 5 : 6, - fontWeight: FontWeight.w900), + color: Colors.black, + fontSize: kIsWeb ? 5 : 9, + fontWeight: FontWeight.w500), )), ], ); @@ -86,167 +89,173 @@ class ConsumerBillPaymentsState extends State { listen: false); screenshotController - .captureFromWidget( + .captureFromLongWidget( Container( - width: kIsWeb ? 375 : 150, + width: kIsWeb ? 375 : 195, margin: EdgeInsets.zero, padding: EdgeInsets.zero, - child: Column( - mainAxisSize: MainAxisSize.min, + child: Row( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + Column( + mainAxisSize: MainAxisSize.min, children: [ - kIsWeb - ? SizedBox( - width: 70, - height: 70, - ) - : Image( - width: 40, - height: 40, - image: NetworkImage(stateProvider - .stateInfo!.stateLogoURL - .toString())), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + kIsWeb + ? SizedBox( + width: 70, + height: 70, + ) + : Image( + width: 40, + height: 40, + color: Colors.black, + image: NetworkImage(stateProvider + .stateInfo!.stateLogoURL + .toString())), + Container( + width: kIsWeb ? 290 : 90, + margin: EdgeInsets.all(5), + child: Text( + ApplicationLocalizations.of( + navigatorKey.currentContext!) + .translate(i18.consumerReciepts + .GRAM_PANCHAYAT_WATER_SUPPLY_AND_SANITATION), + textScaler: TextScaler.linear(kIsWeb ? 3 : 1), + maxLines: 3, + style: TextStyle( + color: Colors.black, + fontSize: 10, + height: 1, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic), + textAlign: TextAlign.left, + ), + ) + ], + ), + SizedBox( + height: 8, + ), Container( - width: kIsWeb ? 290 : 90, - margin: EdgeInsets.all(5), - child: Text( - ApplicationLocalizations.of( - navigatorKey.currentContext!) - .translate(i18.consumerReciepts - .GRAM_PANCHAYAT_WATER_SUPPLY_AND_SANITATION), - textScaler: TextScaler.linear(kIsWeb ? 3 : 1), - maxLines: 3, - style: TextStyle( - color: Colors.black, - fontSize: 10, - height: 1, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.italic), - textAlign: TextAlign.left, - ), - ) - ], - ), - SizedBox( - height: 8, - ), - Container( - width: kIsWeb ? 375 : 90, - margin: EdgeInsets.all(5), - child: Text( - ApplicationLocalizations.of( - navigatorKey.currentContext!) - .translate(i18.consumerReciepts.WATER_RECEIPT), - textScaler: TextScaler.linear(kIsWeb ? 3 : 1), - style: TextStyle( - color: Colors.black, - fontSize: 10, - height: 1, - fontWeight: FontWeight.bold, - ))), - SizedBox( - height: 8, - ), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_GPWSC_NAME, - ApplicationLocalizations.of(navigatorKey.currentContext!) - .translate(commonProvider - .userDetails!.selectedtenant!.code!)), - getPrinterLabel(i18.consumerReciepts.RECEIPT_CONSUMER_NO, - widget.waterConnection!.connectionNo), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_CONSUMER_NAME, - widget.waterConnection!.connectionHolders!.first.name, - ), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_CONSUMER_MOBILE_NO, - item.mobileNumber), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_CONSUMER_ADDRESS, - ApplicationLocalizations.of(navigatorKey.currentContext!) - .translate(widget.waterConnection!.additionalDetails! - .doorNo - .toString()) + - " " + - ApplicationLocalizations.of(navigatorKey.currentContext!) - .translate(widget.waterConnection!.additionalDetails! - .street - .toString()) + - " " + - ApplicationLocalizations.of(navigatorKey.currentContext!) - .translate(widget - .waterConnection!.additionalDetails!.locality - .toString()) + - " " + + width: kIsWeb ? 375 : 90, + margin: EdgeInsets.all(5), + child: Text( + ApplicationLocalizations.of( + navigatorKey.currentContext!) + .translate(i18.consumerReciepts.WATER_RECEIPT), + textScaler: TextScaler.linear(kIsWeb ? 3 : 1), + style: TextStyle( + color: Colors.black, + fontSize: 10, + height: 1, + fontWeight: FontWeight.bold, + ))), + SizedBox( + height: 8, + ), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_GPWSC_NAME, ApplicationLocalizations.of(navigatorKey.currentContext!) .translate(commonProvider .userDetails!.selectedtenant!.code!)), - SizedBox( - height: 10, - ), - getPrinterLabel(i18.consumer.SERVICE_TYPE, - widget.waterConnection?.connectionType), - getPrinterLabel(i18.consumerReciepts.CONSUMER_RECEIPT_NO, - item.paymentDetails!.first.receiptNumber), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_ISSUE_DATE, - DateFormats.timeStampToDate(item.transactionDate, - format: "dd/MM/yyyy") - .toString()), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_BILL_PERIOD, - DateFormats.timeStampToDate( - item.paymentDetails?.last.bill!.billDetails!.first - .fromPeriod, - format: "dd/MM/yyyy") + - '-' + - DateFormats.timeStampToDate( - item.paymentDetails?.last.bill?.billDetails! - .first.toPeriod, + getPrinterLabel(i18.consumerReciepts.RECEIPT_CONSUMER_NO, + widget.waterConnection!.connectionNo), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_CONSUMER_NAME, + widget.waterConnection!.connectionHolders!.first.name, + ), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_CONSUMER_MOBILE_NO, + item.mobileNumber), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_CONSUMER_ADDRESS, + ApplicationLocalizations.of(navigatorKey.currentContext!) + .translate(widget.waterConnection!.additionalDetails! + .doorNo + .toString()) + + " " + + ApplicationLocalizations.of(navigatorKey.currentContext!) + .translate(widget.waterConnection!.additionalDetails! + .street + .toString()) + + " " + + ApplicationLocalizations.of(navigatorKey.currentContext!) + .translate(widget + .waterConnection!.additionalDetails!.locality + .toString()) + + " " + + ApplicationLocalizations.of(navigatorKey.currentContext!) + .translate(commonProvider + .userDetails!.selectedtenant!.code!)), + SizedBox( + height: 10, + ), + getPrinterLabel(i18.consumer.SERVICE_TYPE, + widget.waterConnection?.connectionType), + getPrinterLabel(i18.consumerReciepts.CONSUMER_RECEIPT_NO, + item.paymentDetails!.first.receiptNumber), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_ISSUE_DATE, + DateFormats.timeStampToDate(item.transactionDate, format: "dd/MM/yyyy") .toString()), - SizedBox( - height: 8, - ), - getPrinterLabel( - i18.consumerReciepts.CONSUMER_ACTUAL_DUE_AMOUNT, - ('₹' + (item.totalDue).toString())), - getPrinterLabel(i18.consumerReciepts.RECEIPT_AMOUNT_PAID, - ('₹' + (item.totalAmountPaid).toString())), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_AMOUNT_IN_WORDS, - ('Rupees ' + - (NumberToWord() - .convert('en-in', item.totalAmountPaid!.toInt()) - .toString()) + - ' only')), - getPrinterLabel( - i18.consumerReciepts.CONSUMER_PENDING_AMOUNT, - ('₹' + - ((item.totalDue ?? 0) - (item.totalAmountPaid ?? 0)) - .toString())), - SizedBox( - height: 8, + getPrinterLabel( + i18.consumerReciepts.RECEIPT_BILL_PERIOD, + DateFormats.timeStampToDate( + item.paymentDetails?.last.bill!.billDetails!.first + .fromPeriod, + format: "dd/MM/yyyy") + + '-' + + DateFormats.timeStampToDate( + item.paymentDetails?.last.bill?.billDetails! + .first.toPeriod, + format: "dd/MM/yyyy") + .toString()), + SizedBox( + height: 8, + ), + getPrinterLabel( + i18.consumerReciepts.CONSUMER_ACTUAL_DUE_AMOUNT, + ('₹' + (item.totalDue).toString())), + getPrinterLabel(i18.consumerReciepts.RECEIPT_AMOUNT_PAID, + ('₹' + (item.totalAmountPaid).toString())), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_AMOUNT_IN_WORDS, + ('Rupees ' + + (NumberToWord() + .convert('en-in', item.totalAmountPaid!.toInt()) + .toString()) + + ' only')), + getPrinterLabel( + i18.consumerReciepts.CONSUMER_PENDING_AMOUNT, + ('₹' + + ((item.totalDue ?? 0) - (item.totalAmountPaid ?? 0)) + .toString())), + SizedBox( + height: 8, + ), + Text('- - *** - -', + textScaler: TextScaler.linear(kIsWeb ? 3 : 1), + textAlign: TextAlign.start, + style: TextStyle( + color: Colors.black, + fontSize: kIsWeb ? 5 : 6, + fontWeight: FontWeight.bold)), + Text( + "${ApplicationLocalizations.of(navigatorKey.currentContext!).translate(i18.common.RECEIPT_FOOTER)}", + textScaler: TextScaler.linear(kIsWeb ? 3 : 1), + textAlign: TextAlign.start, + style: TextStyle( + color: Colors.black, + fontSize: kIsWeb ? 5 : 6, + fontWeight: FontWeight.bold)), + ], ), - Text('- - *** - -', - textScaler: TextScaler.linear(kIsWeb ? 3 : 1), - textAlign: TextAlign.start, - style: TextStyle( - color: Colors.red, - fontSize: kIsWeb ? 5 : 6, - fontWeight: FontWeight.bold)), - Text( - "${ApplicationLocalizations.of(navigatorKey.currentContext!).translate(i18.common.RECEIPT_FOOTER)}", - textScaler: TextScaler.linear(kIsWeb ? 3 : 1), - textAlign: TextAlign.start, - style: TextStyle( - color: Colors.red, - fontSize: kIsWeb ? 5 : 6, - fontWeight: FontWeight.bold)), ], )), + pixelRatio: 16/9 ) .then((value) => { kIsWeb diff --git a/frontend/mgramseva/lib/model/connection/water_connection.dart b/frontend/mgramseva/lib/model/connection/water_connection.dart index d2aec7e2d..37e2937b8 100644 --- a/frontend/mgramseva/lib/model/connection/water_connection.dart +++ b/frontend/mgramseva/lib/model/connection/water_connection.dart @@ -268,10 +268,10 @@ class AdditionalDetails { String? collectionPendingAmount; @JsonKey(name: "totalamount") - double? totalAmount; + String? totalAmount; @JsonKey(name: "appCreatedDate") - int? appCreatedDate; + num? appCreatedDate; @JsonKey(ignore: true) var initialMeterReadingCtrl = TextEditingController(); diff --git a/frontend/mgramseva/lib/model/connection/water_connection.g.dart b/frontend/mgramseva/lib/model/connection/water_connection.g.dart index 9a521acbf..1ff036767 100644 --- a/frontend/mgramseva/lib/model/connection/water_connection.g.dart +++ b/frontend/mgramseva/lib/model/connection/water_connection.g.dart @@ -98,8 +98,8 @@ AdditionalDetails _$AdditionalDetailsFromJson(Map json) => ..collectionAmount = json['collectionAmount'] as String? ..collectionPendingAmount = json['collectionPendingAmount'] as String? ..action = json['action'] as String? - ..totalAmount = json['totalamount']!=null?double.parse(json['totalamount'] as String):0.0 - ..appCreatedDate = json['appCreatedDate'] as int?; + ..totalAmount = json['totalamount'] as String? + ..appCreatedDate = json['appCreatedDate'] as num?; Map _$AdditionalDetailsToJson(AdditionalDetails instance) => { diff --git a/frontend/mgramseva/lib/providers/collect_payment_provider.dart b/frontend/mgramseva/lib/providers/collect_payment_provider.dart index c9fb773e5..6c1781a08 100644 --- a/frontend/mgramseva/lib/providers/collect_payment_provider.dart +++ b/frontend/mgramseva/lib/providers/collect_payment_provider.dart @@ -207,7 +207,7 @@ class CollectPaymentProvider with ChangeNotifier { Container( margin: EdgeInsets.zero, padding: EdgeInsets.zero, - width: kIsWeb ? 150 : 65, + width: kIsWeb ? 150 : 80, child: Text( ApplicationLocalizations.of(navigatorKey.currentContext!) .translate(key), @@ -215,11 +215,14 @@ class CollectPaymentProvider with ChangeNotifier { textScaleFactor: kIsWeb ? 2.5 : 1, textAlign: TextAlign.start, style: TextStyle( - color: Colors.red, - fontSize: kIsWeb ? 5 : 6, - fontWeight: FontWeight.w900))), + color: Colors.black, + fontSize: kIsWeb ? 5 : 9, + fontWeight: FontWeight.w500))), + SizedBox( + width: 5, + ), Container( - width: kIsWeb ? 215 : 85, + width: kIsWeb ? 215 : 110, child: Text( ApplicationLocalizations.of(navigatorKey.currentContext!) .translate(value), @@ -228,9 +231,9 @@ class CollectPaymentProvider with ChangeNotifier { textAlign: TextAlign.start, textScaleFactor: kIsWeb ? 2.5 : 1, style: TextStyle( - color: Colors.red, - fontSize: kIsWeb ? 5 : 6, - fontWeight: FontWeight.w900), + color: Colors.black, + fontSize: kIsWeb ? 5 : 9, + fontWeight: FontWeight.w500), )), ], ); @@ -255,172 +258,180 @@ class CollectPaymentProvider with ChangeNotifier { screenshotController .captureFromWidget( Container( - width: kIsWeb ? 375 : 150, + width: kIsWeb ? 375 : 195, margin: EdgeInsets.zero, padding: EdgeInsets.zero, - child: Column( - mainAxisSize: MainAxisSize.min, + child: Row( children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, + Column( + mainAxisSize: MainAxisSize.min, children: [ - kIsWeb - ? SizedBox( - width: 70, - height: 70, - ) - : Image( - width: 40, - height: 40, - image: NetworkImage(stateProvider - .stateInfo!.stateLogoURL - .toString())), + Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + kIsWeb + ? SizedBox( + width: 70, + height: 70, + ) + : Image( + width: 40, + height: 40, + image: NetworkImage(stateProvider + .stateInfo!.stateLogoURL + .toString())), + Container( + width: kIsWeb ? 290 : 90, + margin: EdgeInsets.all(5), + child: Text( + ApplicationLocalizations.of( + navigatorKey.currentContext!) + .translate(i18.consumerReciepts + .GRAM_PANCHAYAT_WATER_SUPPLY_AND_SANITATION), + textScaleFactor: kIsWeb ? 3 : 1, + maxLines: 3, + style: TextStyle( + color: Colors.black, + fontSize: 10, + height: 1, + fontWeight: FontWeight.bold, + fontStyle: FontStyle.italic), + textAlign: TextAlign.left, + ), + ) + ], + ), + SizedBox( + height: 8, + ), Container( - width: kIsWeb ? 290 : 90, - margin: EdgeInsets.all(5), - child: Text( - ApplicationLocalizations.of( - navigatorKey.currentContext!) - .translate(i18.consumerReciepts - .GRAM_PANCHAYAT_WATER_SUPPLY_AND_SANITATION), - textScaleFactor: kIsWeb ? 3 : 1, - maxLines: 3, - style: TextStyle( - color: Colors.blue, - fontSize: 10, - height: 1, - fontWeight: FontWeight.bold, - fontStyle: FontStyle.italic), - textAlign: TextAlign.left, - ), - ) - ], - ), - SizedBox( - height: 8, - ), - Container( - width: kIsWeb ? 375 : 90, - margin: EdgeInsets.all(5), - child: Text( - ApplicationLocalizations.of( - navigatorKey.currentContext!) - .translate(i18.consumerReciepts.WATER_RECEIPT), - textScaleFactor: kIsWeb ? 3 : 1, - style: TextStyle( - color: Colors.blue, - fontSize: 10, - height: 1, - fontWeight: FontWeight.bold, - ))), - SizedBox( - height: 8, - ), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_GPWSC_NAME, - ApplicationLocalizations.of(navigatorKey.currentContext!) - .translate(commonProvider - .userDetails!.selectedtenant!.code!)), - getPrinterLabel(i18.consumerReciepts.RECEIPT_CONSUMER_NO, - '${fetchBill.consumerCode}'), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_CONSUMER_NAME, - '${item.paidBy}', - ), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_CONSUMER_MOBILE_NO, - item.mobileNumber), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_CONSUMER_ADDRESS, - ApplicationLocalizations.of(navigatorKey.currentContext!) - .translate(houseHoldProvider - .waterConnection!.additionalDetails!.doorNo - .toString()) + - " " + - ApplicationLocalizations.of( - navigatorKey.currentContext!) - .translate( - '${houseHoldProvider.waterConnection?.additionalDetails?.street.toString()}') + - " " + - ApplicationLocalizations.of( - navigatorKey.currentContext!) - .translate( - '${houseHoldProvider.waterConnection?.additionalDetails?.locality.toString()}') + - " " + - ApplicationLocalizations.of( - navigatorKey.currentContext!) + width: kIsWeb ? 375 : 90, + margin: EdgeInsets.all(5), + child: Text( + ApplicationLocalizations.of( + navigatorKey.currentContext!) + .translate(i18.consumerReciepts.WATER_RECEIPT), + textScaleFactor: kIsWeb ? 3 : 1, + style: TextStyle( + color: Colors.black, + fontSize: 10, + height: 1, + fontWeight: FontWeight.bold, + ))), + SizedBox( + height: 8, + ), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_GPWSC_NAME, + ApplicationLocalizations.of(navigatorKey.currentContext!) .translate(commonProvider .userDetails!.selectedtenant!.code!)), - SizedBox( - height: 10, - ), - getPrinterLabel(i18.consumer.SERVICE_TYPE, - '${houseHoldProvider.waterConnection!.connectionType.toString()}'), - getPrinterLabel(i18.consumerReciepts.CONSUMER_RECEIPT_NO, - item.paymentDetails!.first.receiptNumber), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_ISSUE_DATE, - DateFormats.timeStampToDate(item.transactionDate, - format: "dd/MM/yyyy") - .toString()), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_BILL_PERIOD, - DateFormats.timeStampToDate( - item.paymentDetails?.last.bill!.billDetails!.first - .fromPeriod, - format: "dd/MM/yyyy") + - '-' + - DateFormats.timeStampToDate( - item.paymentDetails?.last.bill?.billDetails! - .first.toPeriod, + getPrinterLabel(i18.consumerReciepts.RECEIPT_CONSUMER_NO, + '${fetchBill.consumerCode}'), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_CONSUMER_NAME, + '${item.paidBy}', + ), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_CONSUMER_MOBILE_NO, + item.mobileNumber), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_CONSUMER_ADDRESS, + ApplicationLocalizations.of(navigatorKey.currentContext!) + .translate(houseHoldProvider + .waterConnection!.additionalDetails!.doorNo + .toString()) + + " " + + ApplicationLocalizations.of( + navigatorKey.currentContext!) + .translate( + '${houseHoldProvider.waterConnection?.additionalDetails?.street.toString()}') + + " " + + ApplicationLocalizations.of( + navigatorKey.currentContext!) + .translate( + '${houseHoldProvider.waterConnection?.additionalDetails?.locality.toString()}') + + " " + + ApplicationLocalizations.of( + navigatorKey.currentContext!) + .translate(commonProvider + .userDetails!.selectedtenant!.code!)), + SizedBox( + height: 10, + ), + getPrinterLabel(i18.consumer.SERVICE_TYPE, + '${houseHoldProvider.waterConnection!.connectionType.toString()}'), + getPrinterLabel(i18.consumerReciepts.CONSUMER_RECEIPT_NO, + item.paymentDetails!.first.receiptNumber), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_ISSUE_DATE, + DateFormats.timeStampToDate(item.transactionDate, format: "dd/MM/yyyy") .toString()), - SizedBox( - height: 8, - ), - getPrinterLabel( - i18.consumerReciepts.CONSUMER_ACTUAL_DUE_AMOUNT, - ('₹' + (item.totalDue).toString())), - getPrinterLabel(i18.consumerReciepts.RECEIPT_AMOUNT_PAID, - ('₹' + (item.totalAmountPaid).toString())), - getPrinterLabel( - i18.consumerReciepts.RECEIPT_AMOUNT_IN_WORDS, - ('Rupees ' + - (NumberToWord() - .convert('en-in', item.totalAmountPaid!.toInt()) - .toString()) + - ' only')), - getPrinterLabel( - i18.consumerReciepts.CONSUMER_PENDING_AMOUNT, - ('₹' + - ((item.totalDue ?? 0) - (item.totalAmountPaid ?? 0)) - .toString())), - SizedBox( - height: 8, + getPrinterLabel( + i18.consumerReciepts.RECEIPT_BILL_PERIOD, + DateFormats.timeStampToDate( + item.paymentDetails?.last.bill!.billDetails!.first + .fromPeriod, + format: "dd/MM/yyyy") + + '-' + + DateFormats.timeStampToDate( + item.paymentDetails?.last.bill?.billDetails! + .first.toPeriod, + format: "dd/MM/yyyy") + .toString()), + SizedBox( + height: 8, + ), + getPrinterLabel( + i18.consumerReciepts.CONSUMER_ACTUAL_DUE_AMOUNT, + ('₹' + (item.totalDue).toString())), + getPrinterLabel(i18.consumerReciepts.RECEIPT_AMOUNT_PAID, + ('₹' + (item.totalAmountPaid).toString())), + getPrinterLabel( + i18.consumerReciepts.RECEIPT_AMOUNT_IN_WORDS, + ('Rupees ' + + (NumberToWord() + .convert('en-in', item.totalAmountPaid!.toInt()) + .toString()) + + ' only')), + getPrinterLabel( + i18.consumerReciepts.CONSUMER_PENDING_AMOUNT, + ('₹' + + ((item.totalDue ?? 0) - (item.totalAmountPaid ?? 0)) + .toString())), + SizedBox( + height: 8, + ), + Text('- - *** - -', + textScaler: TextScaler.linear(kIsWeb ? 3 : 1), + textAlign: TextAlign.start, + style: TextStyle( + color: Colors.black, + fontSize: kIsWeb ? 5 : 6, + fontWeight: FontWeight.bold)), + Text( + "${ApplicationLocalizations.of(navigatorKey.currentContext!).translate(i18.common.RECEIPT_FOOTER)}", + textScaler: TextScaler.linear(kIsWeb ? 3 : 1), + textAlign: TextAlign.start, + style: TextStyle( + color: Colors.black, + fontSize: kIsWeb ? 5 : 6, + fontWeight: FontWeight.bold)), + ], ), - Text('- - *** - -', - textScaler: TextScaler.linear(kIsWeb ? 3 : 1), - textAlign: TextAlign.start, - style: TextStyle( - color: Colors.red, - fontSize: kIsWeb ? 5 : 6, - fontWeight: FontWeight.bold)), - Text( - "${ApplicationLocalizations.of(navigatorKey.currentContext!).translate(i18.common.RECEIPT_FOOTER)}", - textScaler: TextScaler.linear(kIsWeb ? 3 : 1), - textAlign: TextAlign.start, - style: TextStyle( - color: Colors.red, - fontSize: kIsWeb ? 5 : 6, - fontWeight: FontWeight.bold)), ], )), + pixelRatio: 16/9 ) .then((value) => { kIsWeb ? js.onButtonClick( value, stateProvider.stateInfo!.stateLogoURL.toString()) - :Navigator.push(navigatorKey.currentContext!, new MaterialPageRoute(builder: (context)=>BluetoothPrinterScreen(imageData: value))) + :showDialog( + context: navigatorKey.currentContext!, + builder: (_) => BluetoothPrinterScreen(imageData: value) + ) }); return null; } diff --git a/frontend/mgramseva/lib/providers/household_register_provider.dart b/frontend/mgramseva/lib/providers/household_register_provider.dart index 6f675d596..5ad6b715e 100644 --- a/frontend/mgramseva/lib/providers/household_register_provider.dart +++ b/frontend/mgramseva/lib/providers/household_register_provider.dart @@ -371,7 +371,7 @@ class HouseholdRegisterProvider with ChangeNotifier { '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-'}', ), TableData( - '${connection.additionalDetails?.appCreatedDate != null ? DateFormats.timeStampToDate(connection.additionalDetails?.appCreatedDate) : '-'}', + '${connection.additionalDetails?.appCreatedDate != null ? DateFormats.timeStampToDate(connection.additionalDetails?.appCreatedDate?.toInt()) : '-'}', ), TableData( '${connection.additionalDetails?.lastDemandGeneratedDate != null && connection.additionalDetails?.lastDemandGeneratedDate != '' ? DateFormats.timeStampToDate(int.parse(connection.additionalDetails?.lastDemandGeneratedDate ?? '')) : '-'}', @@ -570,7 +570,7 @@ class HouseholdRegisterProvider with ChangeNotifier { '${connection.additionalDetails?.collectionAmount != null ? '₹ ${connection.additionalDetails?.collectionAmount}' : '-'}', '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-' : '-'}', '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-'}', - '${connection.additionalDetails?.appCreatedDate != null ? DateFormats.timeStampToDate(connection.additionalDetails?.appCreatedDate) : '-'}', + '${connection.additionalDetails?.appCreatedDate != null ? DateFormats.timeStampToDate(connection.additionalDetails?.appCreatedDate?.toInt()) : '-'}', '${connection.additionalDetails?.lastDemandGeneratedDate != null && connection.additionalDetails?.lastDemandGeneratedDate != '' ? DateFormats.timeStampToDate(int.parse(connection.additionalDetails?.lastDemandGeneratedDate ?? '')) : '-'}', '${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}', ]) @@ -601,7 +601,7 @@ class HouseholdRegisterProvider with ChangeNotifier { '${connection.additionalDetails?.collectionAmount != null ? '₹ ${connection.additionalDetails?.collectionAmount}' : '-'}', '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-' : '-'}', '${connection.additionalDetails?.collectionPendingAmount != null ? double.parse(connection.additionalDetails?.collectionPendingAmount ?? '') < 0.0 ? '-' : '₹ ${double.parse(connection.additionalDetails?.collectionPendingAmount ?? '0').abs()}' : '-'}', - '${connection.additionalDetails?.appCreatedDate != null ? DateFormats.timeStampToDate(connection.additionalDetails?.appCreatedDate) : '-'}', + '${connection.additionalDetails?.appCreatedDate != null ? DateFormats.timeStampToDate(connection.additionalDetails?.appCreatedDate?.toInt()) : '-'}', '${connection.additionalDetails?.lastDemandGeneratedDate != null && connection.additionalDetails?.lastDemandGeneratedDate != '' ? DateFormats.timeStampToDate(int.parse(connection.additionalDetails?.lastDemandGeneratedDate ?? '')) : '-'}', '${connection.status.toString() == Constants.CONNECTION_STATUS.last ? 'Y' : 'N'}', ]) diff --git a/frontend/mgramseva/lib/utils/printer/image_utils.dart b/frontend/mgramseva/lib/utils/printer/image_utils.dart index 922981f0c..57649019f 100644 --- a/frontend/mgramseva/lib/utils/printer/image_utils.dart +++ b/frontend/mgramseva/lib/utils/printer/image_utils.dart @@ -20,7 +20,7 @@ img.Image drawImage(img.Image dst, img.Image src, srcY ??= 0; srcW ??= src.width; srcH ??= src.height; - dstW ??= (dst.width < src.width) ? dstW = dst.width : src.width; + dstW ??= (dst.width < src.width) ? dst.width : src.width; dstH ??= (dst.height < src.height) ? dst.height : src.height; if (blend) { @@ -45,3 +45,4 @@ img.Image drawImage(img.Image dst, img.Image src, return dst; } + diff --git a/frontend/mgramseva/lib/widgets/bluetooth_printer.dart b/frontend/mgramseva/lib/widgets/bluetooth_printer.dart index 37a76932a..729dd840a 100644 --- a/frontend/mgramseva/lib/widgets/bluetooth_printer.dart +++ b/frontend/mgramseva/lib/widgets/bluetooth_printer.dart @@ -180,9 +180,9 @@ class _BluetoothPrinterScreenState extends State { final decodedImage = img.decodeImage(imageBytes)!; // Create a black bottom layer // Resize the image to a 130x? thumbnail (maintaining the aspect ratio). - img.Image thumbnail = img.copyResize(decodedImage, height: decodedImage.height); + img.Image thumbnail = img.copyResize(decodedImage,width: PaperSize.mm58.width,maintainAspect: false,); // creates a copy of the original image with set dimensions - img.Image originalImg = img.copyResize(decodedImage, width: PaperSize.mm58.width, height: decodedImage.height); + img.Image originalImg = img.copyResize(decodedImage, width: PaperSize.mm58.width,maintainAspect: false, ); // fills the original image with a white background img.fill(originalImg, color: img.ColorRgb8(255, 255, 255)); // var padding = (originalImg.width - thumbnail.width) / 2;