Skip to content

Commit

Permalink
Merge pull request #354 from egovernments/PFM-2305
Browse files Browse the repository at this point in the history
PFM-2305:: Android > 10 Bluetooth Thermal Printer Connection Issues fixes
  • Loading branch information
egov-arindam authored Feb 6, 2023
2 parents 031f636 + 749bfd9 commit 49f482d
Show file tree
Hide file tree
Showing 15 changed files with 421 additions and 247 deletions.
5 changes: 5 additions & 0 deletions frontend/mgramseva/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

<application
android:label="mgramseva"
Expand Down
2 changes: 1 addition & 1 deletion frontend/mgramseva/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Docker flutter tags https://hub.docker.com/r/cirrusci/flutter/tags?page=1&name=1.16

FROM cirrusci/flutter:3.0.2 AS build
FROM cirrusci/flutter:3.3.8 AS build
ARG WORK_DIR
WORKDIR /app
# copy the project files
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import 'dart:typed_data';
import 'package:mgramseva/providers/language.dart';
import 'package:mgramseva/repository/core_repo.dart';
import 'package:mgramseva/utils/common_styles.dart';
import 'package:mgramseva/utils/models.dart';

import './jsconnnector.dart' as js;
import 'package:flutter/foundation.dart';
import 'package:image/image.dart' as img;
import 'package:flutter/cupertino.dart';
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/connection/water_connection.dart';
import 'package:mgramseva/providers/bill_payments_provider.dart';
import 'package:mgramseva/providers/common_provider.dart';
import 'package:mgramseva/providers/language.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/common_styles.dart';
import 'package:mgramseva/utils/date_formats.dart';
import 'package:mgramseva/utils/global_variables.dart';
import 'package:mgramseva/utils/loaders.dart';
import 'package:mgramseva/utils/notifyers.dart';
import 'package:mgramseva/utils/print_bluetooth.dart';
import 'package:mgramseva/widgets/ListLabelText.dart';
import 'package:number_to_words/number_to_words.dart';
import 'package:provider/provider.dart';
import 'package:screenshot/screenshot.dart';
import 'package:number_to_words/number_to_words.dart';

import './jsconnnector.dart' as js;

class ConsumerBillPayments extends StatefulWidget {
final WaterConnection? waterconnection;
Expand Down Expand Up @@ -216,7 +214,8 @@ class ConsumerBillPaymentsState extends State<ConsumerBillPayments> {
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())),
Expand All @@ -227,8 +226,11 @@ class ConsumerBillPaymentsState extends State<ConsumerBillPayments> {
.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,
),
Expand All @@ -254,7 +256,7 @@ class ConsumerBillPaymentsState extends State<ConsumerBillPayments> {
kIsWeb
? js.onButtonClick(
value, stateProvider.stateInfo!.stateLogoURL.toString())
: CommonPrinter.printTicket(
: PrintBluetooth.printTicket(
img.decodeImage(value), navigatorKey.currentContext!)
});
}
Expand Down Expand Up @@ -346,7 +348,7 @@ class ConsumerBillPaymentsState extends State<ConsumerBillPayments> {
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),
Expand All @@ -362,15 +364,15 @@ class ConsumerBillPaymentsState extends State<ConsumerBillPayments> {
'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),
Expand Down Expand Up @@ -399,7 +401,8 @@ class ConsumerBillPaymentsState extends State<ConsumerBillPayments> {
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!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ class NewConsumerBillState extends State<NewConsumerBill> {
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(
Expand Down
2 changes: 1 addition & 1 deletion frontend/mgramseva/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 49f482d

Please sign in to comment.