diff --git a/frontend/mgramseva/android/app/src/main/AndroidManifest.xml b/frontend/mgramseva/android/app/src/main/AndroidManifest.xml
index 0b56321f4..a07cacafc 100644
--- a/frontend/mgramseva/android/app/src/main/AndroidManifest.xml
+++ b/frontend/mgramseva/android/app/src/main/AndroidManifest.xml
@@ -5,6 +5,11 @@
+
+
+
+
+
{
SizedBox(
height: 8,
),
- getprinterlabel(i18.consumerReciepts.CONSUMER_ACTUAL_DUE_AMOUNT,
+ getprinterlabel(
+ i18.consumerReciepts.CONSUMER_ACTUAL_DUE_AMOUNT,
('₹' + (item.totalDue).toString())),
getprinterlabel(i18.consumerReciepts.RECEIPT_AMOUNT_PAID,
('₹' + (item.totalAmountPaid).toString())),
@@ -227,8 +226,11 @@ class ConsumerBillPaymentsState extends State {
.convert('en-in', item.totalAmountPaid!.toInt())
.toString()) +
' only')),
- getprinterlabel(i18.consumerReciepts.CONSUMER_PENDING_AMOUNT,
- ('₹' + ((item.totalDue ?? 0) - (item.totalAmountPaid ?? 0)).toString())),
+ getprinterlabel(
+ i18.consumerReciepts.CONSUMER_PENDING_AMOUNT,
+ ('₹' +
+ ((item.totalDue ?? 0) - (item.totalAmountPaid ?? 0))
+ .toString())),
SizedBox(
height: 8,
),
@@ -254,7 +256,7 @@ class ConsumerBillPaymentsState extends State {
kIsWeb
? js.onButtonClick(
value, stateProvider.stateInfo!.stateLogoURL.toString())
- : CommonPrinter.printTicket(
+ : PrintBluetooth.printTicket(
img.decodeImage(value), navigatorKey.currentContext!)
});
}
@@ -346,7 +348,7 @@ class ConsumerBillPaymentsState extends State {
context),
])),
Padding(
- padding: const EdgeInsets.only(bottom : 8.0),
+ padding: const EdgeInsets.only(bottom: 8.0),
child: Row(children: [
Container(
padding: EdgeInsets.only(left: 8),
@@ -362,15 +364,15 @@ class ConsumerBillPaymentsState extends State {
'Metered'
? "ws-receipt"
: "ws-receipt-nm",
- "tenantId":
- commonProvider.userDetails!.selectedtenant!.code,
+ "tenantId": commonProvider
+ .userDetails!.selectedtenant!.code,
}, item.mobileNumber, item, "Share"),
style: ButtonStyle(
alignment: Alignment.center,
padding: MaterialStateProperty.all(
EdgeInsets.symmetric(vertical: 8)),
- shape:
- MaterialStateProperty.all(RoundedRectangleBorder(
+ shape: MaterialStateProperty.all(
+ RoundedRectangleBorder(
side: BorderSide(
width: 2,
color: Theme.of(context).primaryColor),
@@ -399,7 +401,8 @@ class ConsumerBillPaymentsState extends State {
icon: Icon(Icons.print),
label: Text(
ApplicationLocalizations.of(context).translate(
- i18.consumerReciepts.CONSUMER_RECEIPT_PRINT),
+ i18.consumerReciepts
+ .CONSUMER_RECEIPT_PRINT),
style: Theme.of(context)
.textTheme
.subtitle1!
diff --git a/frontend/mgramseva/lib/components/HouseConnectionandBill/NewConsumerBill.dart b/frontend/mgramseva/lib/components/HouseConnectionandBill/NewConsumerBill.dart
index 729fbb8e3..df0f2c3cb 100644
--- a/frontend/mgramseva/lib/components/HouseConnectionandBill/NewConsumerBill.dart
+++ b/frontend/mgramseva/lib/components/HouseConnectionandBill/NewConsumerBill.dart
@@ -206,9 +206,9 @@ class NewConsumerBillState extends State {
context),
if(CommonProvider.getPenaltyOrAdvanceStatus(widget.waterConnection?.mdmsData, true) && houseHoldProvider.isfirstdemand) getLabelText(
i18.common.CORE_ADVANCE_ADJUSTED,
- (((CommonProvider.getAdvanceAdjustedAmount(widget.demandList)) != '0.0'
- ? '- ' + '₹' + (CommonProvider.getAdvanceAdjustedAmount(widget.demandList)).toString()
- : '- ' + '₹' +(CommonProvider.getAdvanceAdjustedAmount(widget.demandList)).toString())),
+ ((double.parse(CommonProvider.getAdvanceAdjustedAmount(widget.demandList)).abs() != 0.0
+ ? '- ₹' + (CommonProvider.getAdvanceAdjustedAmount(widget.demandList)).toString()
+ : '₹' +(CommonProvider.getAdvanceAdjustedAmount(widget.demandList)).toString())),
context),
if(CommonProvider.getPenaltyOrAdvanceStatus(widget.waterConnection?.mdmsData, false, true) && houseHoldProvider.isfirstdemand && penalty.isDueDateCrossed) getLabelText(
diff --git a/frontend/mgramseva/lib/main.dart b/frontend/mgramseva/lib/main.dart
index 5e9cd63c9..b67d4f2b6 100644
--- a/frontend/mgramseva/lib/main.dart
+++ b/frontend/mgramseva/lib/main.dart
@@ -43,7 +43,7 @@ import 'package:mgramseva/utils/error_logging.dart';
import 'package:mgramseva/utils/global_variables.dart';
import 'package:mgramseva/utils/loaders.dart';
import 'package:mgramseva/utils/notifyers.dart';
-import 'package:open_file_safe/open_file_safe.dart';
+import 'package:open_file/open_file.dart';
import 'package:provider/provider.dart';
import 'package:url_strategy/url_strategy.dart';
diff --git a/frontend/mgramseva/lib/providers/bill_generation_details_provider.dart b/frontend/mgramseva/lib/providers/bill_generation_details_provider.dart
index 27b5a9ab1..a53abcbea 100644
--- a/frontend/mgramseva/lib/providers/bill_generation_details_provider.dart
+++ b/frontend/mgramseva/lib/providers/bill_generation_details_provider.dart
@@ -481,8 +481,20 @@ class BillGenerationProvider with ChangeNotifier {
/// Get months based on selected billing year
var months = CommonMethods.getPastMonthUntilFinancialYear(date1.year);
- /// if its current ytd year means removing current month
- if(isCurrentYtdSelected) months.removeAt(0);
+ /// if its current ytd year means removing till current month
+ if (isCurrentYtdSelected) {
+ switch (DateTime.now().month) {
+ case 1:
+ months.removeRange(0, 3);
+ break;
+ case 2:
+ months.removeRange(0, 2);
+ break;
+ case 3:
+ months.removeRange(0, 1);
+ break;
+ }
+ }
/// if selected year is future year means all the months will be removed
if(date1.year >= ytd.endDate.year) months.clear();
diff --git a/frontend/mgramseva/lib/providers/collect_payment.dart b/frontend/mgramseva/lib/providers/collect_payment.dart
index 211f84a0c..f4f095fa1 100644
--- a/frontend/mgramseva/lib/providers/collect_payment.dart
+++ b/frontend/mgramseva/lib/providers/collect_payment.dart
@@ -1,42 +1,41 @@
import 'dart:async';
import 'dart:typed_data';
-import 'package:mgramseva/model/demand/update_demand_list.dart';
-import 'package:mgramseva/model/mdms/payment_type.dart';
-import 'package:mgramseva/providers/language.dart';
-import '../components/HouseConnectionandBill/jsconnnector.dart' as js;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
-import 'package:mgramseva/Env/app_config.dart';
+import 'package:image/image.dart' as img;
import 'package:mgramseva/model/bill/bill_payments.dart';
+import 'package:mgramseva/model/bill/billing.dart';
import 'package:mgramseva/model/common/fetch_bill.dart';
+import 'package:mgramseva/model/demand/demand_list.dart';
+import 'package:mgramseva/model/demand/update_demand_list.dart';
+import 'package:mgramseva/model/mdms/payment_type.dart';
import 'package:mgramseva/model/success_handler.dart';
import 'package:mgramseva/providers/household_details_provider.dart';
+import 'package:mgramseva/providers/language.dart';
+import 'package:mgramseva/repository/billing_service_repo.dart';
import 'package:mgramseva/repository/consumer_details_repo.dart';
import 'package:mgramseva/repository/core_repo.dart';
import 'package:mgramseva/routers/Routers.dart';
import 'package:mgramseva/services/MDMS.dart';
+import 'package:mgramseva/utils/Constants/I18KeyConstants.dart';
import 'package:mgramseva/utils/Locilization/application_localizations.dart';
-import 'package:mgramseva/utils/common_printer.dart';
import 'package:mgramseva/utils/constants.dart';
import 'package:mgramseva/utils/custom_exception.dart';
import 'package:mgramseva/utils/date_formats.dart';
import 'package:mgramseva/utils/error_logging.dart';
-import 'package:mgramseva/utils/Constants/I18KeyConstants.dart';
import 'package:mgramseva/utils/global_variables.dart';
import 'package:mgramseva/utils/loaders.dart';
import 'package:mgramseva/utils/models.dart';
import 'package:mgramseva/utils/notifyers.dart';
+import 'package:mgramseva/utils/print_bluetooth.dart';
import 'package:mgramseva/widgets/CommonSuccessPage.dart';
import 'package:number_to_words/number_to_words.dart';
import 'package:provider/provider.dart';
import 'package:screenshot/screenshot.dart';
-import 'package:image/image.dart' as img;
-import '../model/localization/language.dart';
+
+import '../components/HouseConnectionandBill/jsconnnector.dart' as js;
import 'common_provider.dart';
-import 'package:mgramseva/repository/billing_service_repo.dart';
-import 'package:mgramseva/model/bill/billing.dart';
-import 'package:mgramseva/model/demand/demand_list.dart';
class CollectPaymentProvider with ChangeNotifier {
var paymentStreamController = StreamController.broadcast();
@@ -52,20 +51,22 @@ class CollectPaymentProvider with ChangeNotifier {
}
Future getBillDetails(
- BuildContext context, Map query, List? bill, List? demandList, PaymentType? mdmsData, List? updateDemandList ) async {
+ BuildContext context,
+ Map query,
+ List? bill,
+ List? demandList,
+ PaymentType? mdmsData,
+ List? updateDemandList) async {
try {
-
-
List? paymentDetails;
// if(bill == null) {
- paymentDetails = await ConsumerRepository().getBillDetails(query);
+ paymentDetails = await ConsumerRepository().getBillDetails(query);
// }else{
// paymentDetails = (bill.map((e)=> e.toJson()).toList()).map((e)=> FetchBill.fromJson(e)).toList();
// }
-
- if(demandList == null) {
+ if (demandList == null) {
var demand = await BillingServiceRepository().fetchdDemand({
"tenantId": query['tenantId'],
"consumerCode": query['consumerCode'],
@@ -76,67 +77,72 @@ class CollectPaymentProvider with ChangeNotifier {
demandList = demand.demands;
if (demandList != null && demandList.length > 0) {
- demandList.sort((a, b) =>
- b
- .demandDetails!.first.auditDetails!.createdTime!
- .compareTo(
- a.demandDetails!.first.auditDetails!.createdTime!));
+ demandList.sort((a, b) => b
+ .demandDetails!.first.auditDetails!.createdTime!
+ .compareTo(a.demandDetails!.first.auditDetails!.createdTime!));
}
}
- if (query['status'] != Constants.CONNECTION_STATUS.first){
+ if (query['status'] != Constants.CONNECTION_STATUS.first) {
if (updateDemandList == null) {
var demand = await BillingServiceRepository().fetchUpdateDemand({
"tenantId": query['tenantId'],
"consumerCodes": query['consumerCode'],
"isGetPenaltyEstimate": "true"
- },
- {
- "GetBillCriteria": {
- "tenantId": query['tenantId'],
- "billId": null,
- "isGetPenaltyEstimate": true,
- "consumerCodes": [query['consumerCode']]
- }
- });
+ }, {
+ "GetBillCriteria": {
+ "tenantId": query['tenantId'],
+ "billId": null,
+ "isGetPenaltyEstimate": true,
+ "consumerCodes": [query['consumerCode']]
+ }
+ });
updateDemandList = demand.demands;
updateDemand?.totalApplicablePenalty = demand.totalApplicablePenalty;
updateDemandList?.forEach((e) {
e.totalApplicablePenalty = demand.totalApplicablePenalty;
});
-
if (updateDemandList != null && updateDemandList.length > 0) {
- updateDemandList.sort((a, b) =>
- b
- .demandDetails!.first.auditDetails!.createdTime!
- .compareTo(
- a.demandDetails!.first.auditDetails!.createdTime!));
+ updateDemandList.sort((a, b) => b
+ .demandDetails!.first.auditDetails!.createdTime!
+ .compareTo(a.demandDetails!.first.auditDetails!.createdTime!));
}
}
- }
- else{}
+ } else {}
if (paymentDetails != null) {
- if(mdmsData == null){
+ if (mdmsData == null) {
mdmsData = await CommonProvider.getMdmsBillingService();
paymentDetails.first.mdmsData = mdmsData;
}
-
- paymentDetails.first.billDetails
+ paymentDetails.first.billDetails
?.sort((a, b) => b.fromPeriod!.compareTo(a.fromPeriod!));
- demandList = demandList?.where((element) => element.status != 'CANCELLED').toList();
- updateDemandList = updateDemandList?.where((element) => element.status != 'CANCELLED').toList();
+ demandList = demandList
+ ?.where((element) => element.status != 'CANCELLED')
+ .toList();
+ updateDemandList = updateDemandList
+ ?.where((element) => element.status != 'CANCELLED')
+ .toList();
// var demandDetails = await ConsumerRepository().getDemandDetails(query);
// if (demandDetails != null)
// paymentDetails.first.demand = demandDetails.first;
getPaymentModes(paymentDetails.first);
- paymentDetails.first.customAmountCtrl.text = paymentDetails.first.totalAmount!.toInt() > 0 ? paymentDetails.first.totalAmount!.toInt().toString() : '';
- paymentDetails.first.billDetails?.first.billAccountDetails?.last.advanceAdjustedAmount = double.parse(CommonProvider.getAdvanceAdjustedAmount(demandList ?? []));
- paymentDetails.first.billDetails?.first.billAccountDetails?.last.arrearsAmount = CommonProvider.getArrearsAmount(demandList ?? []);
- paymentDetails.first.billDetails?.first.billAccountDetails?.last.totalBillAmount = CommonProvider.getTotalBillAmount(demandList ?? []);
+ paymentDetails.first.customAmountCtrl.text =
+ paymentDetails.first.totalAmount!.toInt() > 0
+ ? paymentDetails.first.totalAmount!.toInt().toString()
+ : '';
+ paymentDetails.first.billDetails?.first.billAccountDetails?.last
+ .advanceAdjustedAmount =
+ double.parse(
+ CommonProvider.getAdvanceAdjustedAmount(demandList ?? []));
+ paymentDetails.first.billDetails?.first.billAccountDetails?.last
+ .arrearsAmount = CommonProvider.getArrearsAmount(demandList ?? []);
+ paymentDetails.first.billDetails?.first.billAccountDetails?.last
+ .totalBillAmount =
+ CommonProvider.getTotalBillAmount(demandList ?? []);
paymentDetails.first.demands = demandList?.first;
paymentDetails.first.demandList = demandList;
paymentDetails.first.updateDemands = updateDemandList?.first;
@@ -211,170 +217,175 @@ class CollectPaymentProvider with ChangeNotifier {
screenshotController
.captureFromWidget(
- Container(
- width: kIsWeb ? 375 : 150,
- margin: EdgeInsets.zero,
- padding: EdgeInsets.zero,
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceAround,
+ Container(
+ width: kIsWeb ? 375 : 150,
+ margin: EdgeInsets.zero,
+ padding: EdgeInsets.zero,
+ child: 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.blue,
+ 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),
+ 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!)
+ .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,
+ 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('- - *** - -',
textScaleFactor: kIsWeb ? 3 : 1,
- maxLines: 3,
+ textAlign: TextAlign.start,
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),
+ color: Colors.red,
+ fontSize: kIsWeb ? 5 : 6,
+ fontWeight: FontWeight.bold)),
+ Text(
+ "${ApplicationLocalizations.of(navigatorKey.currentContext!).translate(i18.common.RECEIPT_FOOTER)}",
textScaleFactor: kIsWeb ? 3 : 1,
+ textAlign: TextAlign.start,
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!)
- .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,
- 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('- - *** - -',
- textScaleFactor: 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)}",
- textScaleFactor: kIsWeb ? 3 : 1,
- textAlign: TextAlign.start,
- style: TextStyle(
- color: Colors.red,
- fontSize: kIsWeb ? 5 : 6,
- fontWeight: FontWeight.bold)),
- ],
- )),
- )
+ color: Colors.red,
+ fontSize: kIsWeb ? 5 : 6,
+ fontWeight: FontWeight.bold)),
+ ],
+ )),
+ )
.then((value) => {
- kIsWeb
- ? js.onButtonClick(
- value, stateProvider.stateInfo!.stateLogoURL.toString())
- : CommonPrinter.printTicket(
- img.decodeImage(value), navigatorKey.currentContext!)
- });
+ kIsWeb
+ ? js.onButtonClick(
+ value, stateProvider.stateInfo!.stateLogoURL.toString())
+ : PrintBluetooth.printTicket(
+ img.decodeImage(value), navigatorKey.currentContext!)
+ });
}
Future getPaymentModes(FetchBill fetchBill) async {
diff --git a/frontend/mgramseva/lib/providers/consumer_details_provider.dart b/frontend/mgramseva/lib/providers/consumer_details_provider.dart
index 778a241f5..2d45f6b4c 100644
--- a/frontend/mgramseva/lib/providers/consumer_details_provider.dart
+++ b/frontend/mgramseva/lib/providers/consumer_details_provider.dart
@@ -608,8 +608,20 @@ class ConsumerProvider with ChangeNotifier {
/// Get months based on selected billing year
var months = CommonMethods.getPastMonthUntilFinancialYear(date1.year);
- /// if its current ytd year means removing current month
- if(isCurrentYtdSelected) months.removeAt(0);
+ /// if its current ytd year means removing till current month
+ if (isCurrentYtdSelected) {
+ switch (DateTime.now().month) {
+ case 1:
+ months.removeRange(0, 3);
+ break;
+ case 2:
+ months.removeRange(0, 2);
+ break;
+ case 3:
+ months.removeRange(0, 1);
+ break;
+ }
+ }
for (var i = 0; i < months.length; i++) {
var prevMonth = months[i].startDate;
diff --git a/frontend/mgramseva/lib/providers/dashboard_provider.dart b/frontend/mgramseva/lib/providers/dashboard_provider.dart
index e715c04b6..cd6563fb0 100644
--- a/frontend/mgramseva/lib/providers/dashboard_provider.dart
+++ b/frontend/mgramseva/lib/providers/dashboard_provider.dart
@@ -97,6 +97,7 @@ class DashBoardProvider with ChangeNotifier {
fetchExpenseDashBoardDetails(context, limit, offset, true);
} else {
+ sortBy = SortBy('connectionNumber', false);
waterConnectionsDetails?.waterConnection = [];
waterConnectionsDetails?.totalCount = null;
@@ -419,7 +420,7 @@ class DashBoardProvider with ChangeNotifier {
sortBy != null && sortBy!.key == 'connectionNumber'
? sortBy!.isAscending
: null,
- apiKey: 'connectionNumber ',
+ apiKey: 'connectionNumber',
callBack: onExpenseSort),
TableHeader(i18.common.NAME,
isSortingRequired: true,
diff --git a/frontend/mgramseva/lib/screeens/common/collect_payment.dart b/frontend/mgramseva/lib/screeens/common/collect_payment.dart
index 3d84995fd..1eb5fc374 100644
--- a/frontend/mgramseva/lib/screeens/common/collect_payment.dart
+++ b/frontend/mgramseva/lib/screeens/common/collect_payment.dart
@@ -22,7 +22,6 @@ import 'package:mgramseva/widgets/FormWrapper.dart';
import 'package:mgramseva/widgets/HomeBack.dart';
import 'package:mgramseva/widgets/RadioButtonFieldBuilder.dart';
import 'package:mgramseva/widgets/SideBar.dart';
-import 'package:mgramseva/widgets/TextFieldBuilder.dart';
import 'package:provider/provider.dart';
import '../../components/HouseConnectionandBill/NewConsumerBill.dart';
@@ -30,6 +29,7 @@ import '../../model/demand/update_demand_list.dart';
import '../../providers/common_provider.dart';
import '../../utils/models.dart';
import '../../widgets/CustomDetails.dart';
+import '../../widgets/TextFieldBuilder.dart';
import '../../widgets/customAppbar.dart';
class ConnectionPaymentView extends StatefulWidget {
@@ -427,7 +427,7 @@ class _ConnectionPaymentViewState extends State {
0.0
? '- ₹ ' +
'${(fetchBill.billDetails?.first.billAccountDetails?.last.advanceAdjustedAmount)}'
- : '- ₹ ' +
+ : '₹ ' +
'${(fetchBill.billDetails?.first.billAccountDetails?.last.advanceAdjustedAmount)}')),
if (CommonProvider.getPenaltyOrAdvanceStatus(
fetchBill.mdmsData, false, true) &&
diff --git a/frontend/mgramseva/lib/utils/Constants/I18KeyConstants.dart b/frontend/mgramseva/lib/utils/Constants/I18KeyConstants.dart
index 0932ca8dd..425c745a4 100644
--- a/frontend/mgramseva/lib/utils/Constants/I18KeyConstants.dart
+++ b/frontend/mgramseva/lib/utils/Constants/I18KeyConstants.dart
@@ -507,6 +507,10 @@ class ConsumerReciepts {
String get CONSUMER_RECEIPT_PRINT => 'CONSUMER_RECEIPT_PRINT';
String get CONSUMER_ACTUAL_DUE_AMOUNT => 'CONSUMER_ACTUAL_DUE_AMOUNT';
String get CONSUMER_PENDING_AMOUNT => 'CONSUMER_PENDING_AMOUNT';
+ String get CONNECT_TO_DEVICE => 'CONNECT_TO_DEVICE';
+ String get CLICK_TO_CONNECT => 'CLICK_TO_CONNECT';
+ String get CONNECTION_NOT_ESTABLISHED => 'CONNECTION_NOT_ESTABLISHED';
+ String get CLOSE => 'CLOSE';
}
class _NetWorkException {
diff --git a/frontend/mgramseva/lib/utils/ExcelDownload/save_file_mobile.dart b/frontend/mgramseva/lib/utils/ExcelDownload/save_file_mobile.dart
index c7580c7e1..c7ddbff8b 100644
--- a/frontend/mgramseva/lib/utils/ExcelDownload/save_file_mobile.dart
+++ b/frontend/mgramseva/lib/utils/ExcelDownload/save_file_mobile.dart
@@ -1,6 +1,6 @@
import 'dart:io';
-import 'package:open_file_safe/open_file_safe.dart' as open_file;
+import 'package:open_file/open_file.dart' as open_file;
import 'package:path_provider/path_provider.dart' as path_provider;
// ignore: depend_on_referenced_packages
import 'package:path_provider_platform_interface/path_provider_platform_interface.dart';
diff --git a/frontend/mgramseva/lib/utils/print_bluetooth.dart b/frontend/mgramseva/lib/utils/print_bluetooth.dart
new file mode 100644
index 000000000..b8c5e163c
--- /dev/null
+++ b/frontend/mgramseva/lib/utils/print_bluetooth.dart
@@ -0,0 +1,109 @@
+import 'package:esc_pos_utils/esc_pos_utils.dart';
+import 'package:flutter/material.dart';
+import 'package:mgramseva/utils/Constants/I18KeyConstants.dart';
+import 'package:nearby_connections/nearby_connections.dart';
+import 'package:print_bluetooth_thermal/print_bluetooth_thermal.dart';
+
+import 'Locilization/application_localizations.dart';
+
+class PrintBluetooth {
+ static bool connected = false;
+
+ static setConnect(String mac, value, context) async {
+ if (connected) {
+ PrintBluetooth.printTicket(value, context);
+ Navigator.of(context).pop();
+ } else {
+ final result =
+ await PrintBluetoothThermal.connect(macPrinterAddress: mac);
+
+ if (result) {
+ connected = true;
+ PrintBluetooth.printTicket(value, context);
+ Navigator.of(context).pop();
+ }
+ }
+ }
+
+ static Future showMyDialog(context, value) async {
+ connected = false;
+ Widget setupAlertDialogContainer(
+ List availableBluetoothDevices, context) {
+ return Container(
+ height: 300.0, // Change as per your requirement
+ width: 300.0,
+ child: ListView.builder(
+ shrinkWrap: true,
+ itemCount: availableBluetoothDevices.length > 0
+ ? availableBluetoothDevices.length
+ : 0,
+ itemBuilder: (context, index) {
+ return ListTile(
+ onTap: () {
+ String select = availableBluetoothDevices[index].macAdress;
+ setConnect(select, value, context);
+ },
+ title: Text('${availableBluetoothDevices[index].name}'),
+ subtitle: Text(ApplicationLocalizations.of(context)
+ .translate(i18.consumerReciepts.CLICK_TO_CONNECT)),
+ );
+ },
+ ),
+ );
+ }
+
+ final List availableBluetoothDevices =
+ await PrintBluetoothThermal.pairedBluetooths;
+ return showDialog(
+ context: context,
+ barrierDismissible: false, // user must tap button!
+ builder: (BuildContext context) {
+ return AlertDialog(
+ title: Text(ApplicationLocalizations.of(context)
+ .translate(i18.consumerReciepts.CONNECT_TO_DEVICE)),
+ content:
+ setupAlertDialogContainer(availableBluetoothDevices, context),
+ actions: [
+ TextButton(
+ child: Text(ApplicationLocalizations.of(context)
+ .translate(i18.consumerReciepts.CLOSE)),
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ ),
+ ],
+ );
+ },
+ );
+ }
+
+ static Future printTicket(value, context) async {
+ bool? isPermissionGranted =
+ await PrintBluetoothThermal.isPermissionBluetoothGranted;
+ print(isPermissionGranted);
+ if (!isPermissionGranted) {
+ Nearby().askBluetoothPermission();
+ }
+ bool? isConnected = await PrintBluetoothThermal.connectionStatus;
+ if (isConnected) {
+ List bytes = await getTicket(value);
+ final result = await PrintBluetoothThermal.writeBytes(bytes);
+ } else {
+ PrintBluetooth.showMyDialog(context, value);
+ print(ApplicationLocalizations.of(context)
+ .translate(i18.consumerReciepts.CONNECTION_NOT_ESTABLISHED));
+ }
+ }
+
+ static Future> getTicket(value) async {
+ print(value);
+ List bytes = [];
+ CapabilityProfile profile = await CapabilityProfile.load();
+ final generator = Generator(PaperSize.mm80, profile);
+ bytes += generator.image(value);
+
+ // ticket.feed(2);
+ bytes += generator.cut();
+ return bytes;
+ }
+}
diff --git a/frontend/mgramseva/pubspec.lock b/frontend/mgramseva/pubspec.lock
index 1823cce40..3c06016a5 100644
--- a/frontend/mgramseva/pubspec.lock
+++ b/frontend/mgramseva/pubspec.lock
@@ -595,7 +595,7 @@ packages:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
- version: "4.0.1"
+ version: "4.1.0"
json_serializable:
dependency: "direct dev"
description:
@@ -645,6 +645,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
+ nearby_connections:
+ dependency: "direct main"
+ description:
+ name: nearby_connections
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "3.2.0"
nested:
dependency: transitive
description:
@@ -666,13 +673,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
- open_file_safe:
+ open_file:
dependency: "direct main"
description:
- name: open_file_safe
+ name: open_file
url: "https://pub.dartlang.org"
source: hosted
- version: "3.2.3"
+ version: "3.2.1"
package_config:
dependency: transitive
description:
@@ -841,6 +848,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
+ print_bluetooth_thermal:
+ dependency: "direct main"
+ description:
+ name: print_bluetooth_thermal
+ url: "https://pub.dartlang.org"
+ source: hosted
+ version: "1.0.5"
printing:
dependency: "direct main"
description:
diff --git a/frontend/mgramseva/pubspec.yaml b/frontend/mgramseva/pubspec.yaml
index c5bbfcd72..a51989a8f 100644
--- a/frontend/mgramseva/pubspec.yaml
+++ b/frontend/mgramseva/pubspec.yaml
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
-version: 1.2.1+19
+version: 1.2.2+20
environment:
sdk: ">=2.12.0 <3.0.0"
@@ -30,7 +30,7 @@ dependencies:
flutter_secure_storage: ^4.2.0
flutter_svg: ^0.22.0
datetime_picker_formfield: ^2.0.0
- horizontal_data_table: ^4.1.4
+ horizontal_data_table: ^4.1.3
file_picker: ^4.0.0
http: ^0.13.3
provider: ^6.0.0
@@ -67,8 +67,11 @@ dependencies:
sdk: flutter
firebase_analytics: ^8.3.4
package_info_plus: ^1.3.0
- open_file_safe: ^3.2.3
+ open_file: ^3.2.1 #use for web
+ #open_file_safe: ^3.2.3 #use for mobiles
syncfusion_flutter_xlsio: ^20.3.59-beta
+ print_bluetooth_thermal: ^1.0.5
+ nearby_connections: ^3.2.0
dev_dependencies:
flutter_launcher_icons: "^0.9.2"