Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #755 from egovernments/PFM-5570
Browse files Browse the repository at this point in the history
Pfm 5570
  • Loading branch information
rahuldevgarg authored Mar 14, 2024
2 parents 22c1ffa + 279e66f commit ab85e71
Showing 4 changed files with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -118,7 +118,7 @@ class BillGenerationProvider with ChangeNotifier {

setMeterReading(meterRes) {
if (meterRes.meterReadings!.length > 0 &&
meterRes.meterReadings!.first.currentReading.toString() != '0') {
meterRes.meterReadings!.first.currentReading != null) {
readingExist = false;
var previousMeterReading = meterRes.meterReadings!.first.currentReading
.toString()
@@ -134,8 +134,7 @@ class BillGenerationProvider with ChangeNotifier {
var reqDate = readDate.add(Duration(days: 1)).toLocal().toString();
prevReadingDate = DateFormats.dateToTimeStamp(
DateFormats.getFilteredDate(reqDate, dateFormat: 'dd/MM/yyyy'));
} else if (waterconnection.additionalDetails!.meterReading.toString() !=
'0') {
} else {
readingExist = false;
var previousMeterReading = waterconnection.additionalDetails!.meterReading
.toString()
@@ -146,8 +145,6 @@ class BillGenerationProvider with ChangeNotifier {
billGenerateDetails.om_4Ctrl.text = previousMeterReading.toString()[3];
billGenerateDetails.om_5Ctrl.text = previousMeterReading.toString()[4];
prevReadingDate = waterconnection.previousReadingDate;
} else {
readingExist = true;
}
notifyListeners();
}
22 changes: 12 additions & 10 deletions frontend/mgramseva/lib/providers/household_details_provider.dart
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import 'package:mgramseva/utils/error_logging.dart';
import 'package:mgramseva/utils/global_variables.dart';
import 'package:provider/provider.dart';

import '../model/bill/meter_demand_details.dart';
import '../utils/constants.dart';
import 'common_provider.dart';
import 'fetch_bill_provider.dart';
@@ -24,30 +25,28 @@ class HouseHoldProvider with ChangeNotifier {
var streamController = StreamController.broadcast();
var isVisible = false;

Future<void> checkMeterDemand(
BillList data, WaterConnection waterConnection) async {
if (data.bill!.isNotEmpty) {
Future<List<MeterReadings>> checkMeterDemand(
BillList? data, WaterConnection? waterConnection) async {
if (data!=null && data.bill!.isNotEmpty) {
try {
var res = await BillGenerateRepository().searchMeteredDemand({
"tenantId": data.bill!.first.tenantId,
"connectionNos": data.bill!.first.consumerCode
});
if (res.meterReadings!.isNotEmpty) {
if (res.meterReadings!=null && res.meterReadings!.isNotEmpty) {
data.bill!.first.meterReadings = res.meterReadings;
}
if (data.bill!.first.billDetails != null) {
data.bill!.first.billDetails!
.sort((a, b) => b.toPeriod!.compareTo(a.toPeriod!));
}
data.bill!.first.waterConnection = waterConnection;
streamController.add(data);
return res.meterReadings!;
} catch (e, s) {
streamController.addError('error');
ErrorHandler().allExceptionsHandler(navigatorKey.currentContext!, e, s);
}
} else {
streamController.add(data);
}
return <MeterReadings>[];
}

Future<void> fetchDemand(data, List<UpdateDemands>? demandList,
@@ -120,13 +119,12 @@ class HouseHoldProvider with ChangeNotifier {
waterConnection?.demands = demandList;
updateDemandList?.demands = demandList;
} else {}

await BillingServiceRepository().fetchdDemand({
"tenantId": data.tenantId,
"consumerCode": data.connectionNo.toString(),
"businessService": "WS",
// "status": "ACTIVE"
}).then((value) {
}).then((value) async{
value.demands = value.demands
?.where((element) => element.status != 'CANCELLED')
.toList();
@@ -151,6 +149,10 @@ class HouseHoldProvider with ChangeNotifier {
} else {
isfirstdemand = true;
}
if(waterConnection?.connectionType == 'Metered' && waterConnection?.fetchBill?.bill?.isNotEmpty == true){
value.demands?.first.meterReadings = await checkMeterDemand(
waterConnection?.fetchBill, waterConnection);
}
streamController.add(value);

// fetchBill(data);
Original file line number Diff line number Diff line change
@@ -457,7 +457,7 @@ class _ConsumerDetailsState extends State<ConsumerDetails> {
inputFormatter: [
FilteringTextInputFormatter
.allow(RegExp(
"[a-zA-Z0-9]"))
r"^(?!0+$)[a-zA-Z0-9]+$"))
],
key: Keys.createConsumer
.CONSUMER_METER_NUMBER_KEY,
Original file line number Diff line number Diff line change
@@ -80,7 +80,7 @@ class _GenerateBillState extends State<GenerateBill> {
Provider.of<BillGenerationProvider>(context, listen: false).clearBillYear();
Navigator.pop(context);
},),
WaterConnectionCountWidget(),
widget.id == null ?WaterConnectionCountWidget():Container(),
Container(
width: MediaQuery.of(context).size.width,
child: Card(

0 comments on commit ab85e71

Please sign in to comment.