From 4e4ad1f9384721441bcdfb0cf874310344d17a1c Mon Sep 17 00:00:00 2001 From: Hari-egov Date: Tue, 28 May 2024 14:27:56 +0530 Subject: [PATCH] ISTE-141 - FIX --- .../new_consumer_bill.dart | 31 ++++++----- frontend/mgramseva/lib/env/app_config.dart | 3 ++ .../model/connection/water_connection.dart | 48 ++++++++--------- .../providers/authentication_provider.dart | 10 ++-- .../lib/providers/common_provider.dart | 11 ++-- .../providers/household_details_provider.dart | 12 +++-- .../lib/repository/authentication_repo.dart | 39 ++++++++++++++ .../connection_details_card.dart | 51 ++++++++++--------- .../connection_results.dart | 9 +++- .../household_detail/household_detail.dart | 6 +-- frontend/mgramseva/lib/services/urls.dart | 1 + 11 files changed, 144 insertions(+), 77 deletions(-) diff --git a/frontend/mgramseva/lib/components/house_connection_and_bill/new_consumer_bill.dart b/frontend/mgramseva/lib/components/house_connection_and_bill/new_consumer_bill.dart index 95e97098b..71b4f3a55 100644 --- a/frontend/mgramseva/lib/components/house_connection_and_bill/new_consumer_bill.dart +++ b/frontend/mgramseva/lib/components/house_connection_and_bill/new_consumer_bill.dart @@ -104,18 +104,13 @@ class NewConsumerBillState extends State { buildBillView(BillList billList) { var houseHoldProvider = Provider.of(context, listen: false); - - // if(houseHoldProvider.isLoading){ - // return CircularProgressIndicator(); - // } - // AggragateDemandDetails? updateDemandList = houseHoldProvider.aggDemandItems; var commonProvider = Provider.of(context, listen: false); var penalty = billList.bill!.isEmpty ? Penalty(0.0, '0', false) : CommonProvider.getPenalty(widget.waterConnection?.demands); - var penaltyApplicable = billList.bill!.isEmpty - ? PenaltyApplicable(0.0) - : CommonProvider.getPenaltyApplicable(widget.demandList); + // var penaltyApplicable = billList.bill!.isEmpty + // ? PenaltyApplicable(0.0) + // : CommonProvider.getPenaltyApplicable(widget.demandList); return LayoutBuilder(builder: (context, constraints) { // Handler Status @@ -238,25 +233,27 @@ class NewConsumerBillState extends State { i18.billDetails.TOTAL_AMOUNT, "₹ ${(houseHoldProvider.aggDemandItems?.netDueWithPenalty ?? 0.0) + double.parse(CommonProvider.getAdvanceAdjustedAmount(widget.demandList))}", context), + // Advance Avaialble if (houseHoldProvider.aggDemandItems ?.remainingAdvance != null && houseHoldProvider.aggDemandItems ?.remainingAdvance != - 0) + 0 && + !houseHoldProvider.isfirstdemand) getLabelText( i18.common.ADVANCE_AVAILABLE, - "${houseHoldProvider.aggDemandItems?.remainingAdvance?.sign == -1 ? "-" : ""} ₹ ${(houseHoldProvider.aggDemandItems?.remainingAdvance?.abs() ?? 0.0)}", + "${houseHoldProvider.aggDemandItems?.remainingAdvance?.sign == -1 ? "-" : ""} ₹ ${(houseHoldProvider.aggDemandItems?.remainingAdvance?.abs())}", context), + + // Advance Adjust Amount if (CommonProvider .getPenaltyOrAdvanceStatus( widget.waterConnection ?.mdmsData, true) && houseHoldProvider.isfirstdemand) - - // Advance Adjust Amount getLabelText( i18.common.CORE_ADVANCE_ADJUSTED, double.parse(CommonProvider @@ -264,7 +261,7 @@ class NewConsumerBillState extends State { widget .demandList)) <= 0 - ? "₹ 0" + ? "₹ ${double.parse(CommonProvider.getAdvanceAdjustedAmount(widget.demandList))}" : '- ₹${double.parse(CommonProvider.getAdvanceAdjustedAmount(widget.demandList))}', context), // Net Due Amount @@ -641,6 +638,14 @@ class NewConsumerBillState extends State { } } else if (demandDetail.taxAmount! < demandDetail.collectionAmount!) { return true; + } else if ((houseHoldRegister.aggDemandItems?.remainingAdvance ?? + 0) == + 0) { + return false; + } else if (((houseHoldRegister.aggDemandItems?.remainingAdvance ?? + 0) != + 0)) { + return true; } } } diff --git a/frontend/mgramseva/lib/env/app_config.dart b/frontend/mgramseva/lib/env/app_config.dart index a906cafad..d94f65699 100644 --- a/frontend/mgramseva/lib/env/app_config.dart +++ b/frontend/mgramseva/lib/env/app_config.dart @@ -27,6 +27,9 @@ dynamic get apiBaseUrl { } Map devConstants = { + // PROD + // _baseUrl: "https://mgramseva-dwss.punjab.gov.in/", + // UAT _baseUrl: "https://mgramseva-uat.psegs.in/", // _baseUrl: kIsWeb // ? (window.location.origin) + "/" diff --git a/frontend/mgramseva/lib/model/connection/water_connection.dart b/frontend/mgramseva/lib/model/connection/water_connection.dart index 720e7333c..62fc87b72 100644 --- a/frontend/mgramseva/lib/model/connection/water_connection.dart +++ b/frontend/mgramseva/lib/model/connection/water_connection.dart @@ -254,30 +254,30 @@ class WaterConnection { @override int get hashCode { return id.hashCode ^ - connectionNo.hashCode ^ - propertyId.hashCode ^ - applicationNo.hashCode ^ - tenantId.hashCode ^ - action.hashCode ^ - status.hashCode ^ - meterInstallationDate.hashCode ^ - documents.hashCode ^ - proposedTaps.hashCode ^ - noOfTaps.hashCode ^ - arrears.hashCode ^ - connectionType.hashCode ^ - oldConnectionNo.hashCode ^ - meterId.hashCode ^ - propertyType.hashCode ^ - previousReadingDate.hashCode ^ - previousReading.hashCode ^ - proposedPipeSize.hashCode ^ - connectionHolders.hashCode ^ - additionalDetails.hashCode ^ - processInstance.hashCode ^ - paymentType.hashCode ^ - penalty.hashCode ^ - advance.hashCode; + connectionNo.hashCode ^ + propertyId.hashCode ^ + applicationNo.hashCode ^ + tenantId.hashCode ^ + action.hashCode ^ + status.hashCode ^ + meterInstallationDate.hashCode ^ + documents.hashCode ^ + proposedTaps.hashCode ^ + noOfTaps.hashCode ^ + arrears.hashCode ^ + connectionType.hashCode ^ + oldConnectionNo.hashCode ^ + meterId.hashCode ^ + propertyType.hashCode ^ + previousReadingDate.hashCode ^ + previousReading.hashCode ^ + proposedPipeSize.hashCode ^ + connectionHolders.hashCode ^ + additionalDetails.hashCode ^ + processInstance.hashCode ^ + paymentType.hashCode ^ + penalty.hashCode ^ + advance.hashCode; } } diff --git a/frontend/mgramseva/lib/providers/authentication_provider.dart b/frontend/mgramseva/lib/providers/authentication_provider.dart index 7e7943d55..a294b09d7 100644 --- a/frontend/mgramseva/lib/providers/authentication_provider.dart +++ b/frontend/mgramseva/lib/providers/authentication_provider.dart @@ -3,6 +3,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:mgramseva/providers/common_provider.dart'; import 'package:mgramseva/routers/routers.dart'; + import 'package:mgramseva/utils/custom_exception.dart'; import 'package:mgramseva/utils/error_logging.dart'; import 'package:mgramseva/utils/global_variables.dart'; @@ -12,7 +13,9 @@ import 'package:provider/provider.dart'; import '../repository/authentication_repo.dart'; import 'language.dart'; -class AuthenticationProvider with ChangeNotifier { +import 'package:mgramseva/services/base_service.dart'; + +class AuthenticationProvider with ChangeNotifier, BaseService { validateLogin(BuildContext context, String userName, String password) async { /// Unfocus the text field FocusScope.of(context).unfocus(); @@ -48,8 +51,7 @@ class AuthenticationProvider with ChangeNotifier { "id": [loginResponse.userRequest!.id], "mobileNumber": loginResponse.userRequest!.mobileNumber }, loginResponse.accessToken!); - var commonProvider = - Provider.of(context, listen: false); + var commonProvider = Provider.of(context, listen: false); loginResponse.isFirstTimeLogin = userInfo.user!.first.defaultPwdChgd; commonProvider.loginCredentials = loginResponse; if (userInfo.user!.first.defaultPwdChgd == false) { @@ -61,7 +63,7 @@ class AuthenticationProvider with ChangeNotifier { Navigator.of(context).pushNamedAndRemoveUntil( Routes.HOME, (Route route) => false); } - } on CustomException catch (e, s) { + } on CustomException catch (e, s) { Navigator.pop(context); if (ErrorHandler.handleApiException(context, e, s)) { Notifiers.getToastMessage(context, e.message, 'ERROR'); diff --git a/frontend/mgramseva/lib/providers/common_provider.dart b/frontend/mgramseva/lib/providers/common_provider.dart index b3ab04559..8eb71078e 100644 --- a/frontend/mgramseva/lib/providers/common_provider.dart +++ b/frontend/mgramseva/lib/providers/common_provider.dart @@ -16,6 +16,7 @@ import 'package:mgramseva/model/mdms/payment_type.dart'; import 'package:mgramseva/model/user/user_details.dart'; import 'package:mgramseva/model/user_profile/user_profile.dart'; import 'package:mgramseva/providers/language.dart'; +import 'package:mgramseva/repository/authentication_repo.dart'; import 'package:mgramseva/repository/core_repo.dart'; import 'package:mgramseva/routers/routers.dart'; import 'package:mgramseva/services/local_storage.dart'; @@ -325,10 +326,12 @@ class CommonProvider with ChangeNotifier { return userDetails; } - void onLogout() { - navigatorKey.currentState - ?.pushNamedAndRemoveUntil(Routes.SELECT_LANGUAGE, (route) => false); - loginCredentials = null; + void onLogout() async { + await AuthenticationRepository().logoutUser().then((onValue) { + navigatorKey.currentState + ?.pushNamedAndRemoveUntil(Routes.SELECT_LANGUAGE, (route) => false); + loginCredentials = null; + }); } void onTapOfAttachment(FileStore store, context) async { diff --git a/frontend/mgramseva/lib/providers/household_details_provider.dart b/frontend/mgramseva/lib/providers/household_details_provider.dart index dd22bb4cd..895c16347 100644 --- a/frontend/mgramseva/lib/providers/household_details_provider.dart +++ b/frontend/mgramseva/lib/providers/household_details_provider.dart @@ -34,13 +34,16 @@ class HouseHoldProvider with ChangeNotifier { Future> checkMeterDemand( BillList? data, WaterConnection? waterConnection) async { - if (data!=null && data.bill!=null && data.bill!.isNotEmpty&& data.bill!.isNotEmpty) { + if (data != null && + data.bill != null && + data.bill!.isNotEmpty && + data.bill!.isNotEmpty) { try { var res = await BillGenerateRepository().searchMeteredDemand({ "tenantId": data.bill!.first.tenantId, "connectionNos": data.bill!.first.consumerCode }); - if (res.meterReadings!=null && res.meterReadings!.isNotEmpty) { + if (res.meterReadings != null && res.meterReadings!.isNotEmpty) { data.bill!.first.meterReadings = res.meterReadings; } if (data.bill!.first.billDetails != null) { @@ -161,7 +164,7 @@ class HouseHoldProvider with ChangeNotifier { "consumerCode": data.connectionNo.toString(), "businessService": "WS", // "status": "ACTIVE" - }).then((value) async{ + }).then((value) async { value.demands = value.demands ?.where((element) => element.status != 'CANCELLED') .toList(); @@ -190,7 +193,8 @@ class HouseHoldProvider with ChangeNotifier { } else { isfirstdemand = true; } - if(waterConnection?.connectionType == 'Metered' && waterConnection?.fetchBill?.bill?.isNotEmpty == true){ + if (waterConnection?.connectionType == 'Metered' && + waterConnection?.fetchBill?.bill?.isNotEmpty == true) { value.demands?.first.meterReadings = await checkMeterDemand( waterConnection?.fetchBill, waterConnection); } diff --git a/frontend/mgramseva/lib/repository/authentication_repo.dart b/frontend/mgramseva/lib/repository/authentication_repo.dart index 68bd4f45a..aaa8aed9c 100644 --- a/frontend/mgramseva/lib/repository/authentication_repo.dart +++ b/frontend/mgramseva/lib/repository/authentication_repo.dart @@ -1,10 +1,14 @@ +import 'dart:convert'; + import 'package:mgramseva/model/user/user_details.dart'; import 'package:mgramseva/model/user_profile/user_profile.dart'; +import 'package:mgramseva/providers/common_provider.dart'; import 'package:mgramseva/services/request_info.dart'; import 'package:mgramseva/services/base_service.dart'; import 'package:mgramseva/services/urls.dart'; import 'package:mgramseva/utils/global_variables.dart'; import 'package:mgramseva/utils/models.dart'; +import 'package:provider/provider.dart'; class AuthenticationRepository extends BaseService { Future validateLogin( @@ -44,4 +48,39 @@ class AuthenticationRepository extends BaseService { } return userProfile; } + + Future logoutUser() async { + var commonProvider = Provider.of( + navigatorKey.currentContext!, + listen: false); + + final requestInfo = RequestInfo( + APIConstants.API_MODULE_NAME, + APIConstants.API_VERSION, + APIConstants.API_TS, + "POST", + APIConstants.API_DID, + APIConstants.API_KEY, + APIConstants.API_MESSAGE_ID, + commonProvider.userDetails!.accessToken, + ); + + var query = { + "access_token": commonProvider.userDetails!.accessToken, + "tenantId": commonProvider.userDetails?.selectedtenant?.code!, + "-": "${DateTime.now().millisecondsSinceEpoch}" + }; + + var res = await makeRequest( + url: UserUrl.LOGOUT_USER, + method: RequestType.POST, + body: { + "access_token": commonProvider.userDetails!.accessToken, + "RequestInfo": requestInfo + }, + queryParameters: query, + ); + + return res; + } } diff --git a/frontend/mgramseva/lib/screeens/connection_results/connection_details_card.dart b/frontend/mgramseva/lib/screeens/connection_results/connection_details_card.dart index 3aa445224..8b6b1fee3 100644 --- a/frontend/mgramseva/lib/screeens/connection_results/connection_details_card.dart +++ b/frontend/mgramseva/lib/screeens/connection_results/connection_details_card.dart @@ -1,3 +1,6 @@ +import 'dart:convert'; +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:mgramseva/model/connection/water_connections.dart'; import 'package:mgramseva/providers/common_provider.dart'; @@ -281,30 +284,30 @@ class SearchConnectionDetailCard extends StatelessWidget { ? i18.searchWaterConnection .HOUSE_DETAILS_VIEW : i18.searchWaterConnection - .HOUSE_DETAILS_EDIT, - () => Navigator.pushNamed( - context, - (arguments['Mode'] == 'collect' - ? Routes.HOUSEHOLD_DETAILS - : arguments['Mode'] == 'receipts' - ? Routes.HOUSEHOLD_DETAILS - : Routes.CONSUMER_UPDATE), - arguments: { - "waterconnections": isNameSearch == - true - ? waterconnections - .waterConnectionData![index] - : waterconnections - .waterConnection![index], - "mode": arguments['Mode'], - "status": isNameSearch == true - ? waterconnections - .waterConnectionData![index] - .status - : waterconnections - .waterConnection![index] - .status - })), + .HOUSE_DETAILS_EDIT, () { + log("${isNameSearch}"); + log("${jsonEncode(waterconnections.waterConnection![index])}"); + Navigator.pushNamed( + context, + (arguments['Mode'] == 'collect' + ? Routes.HOUSEHOLD_DETAILS + : arguments['Mode'] == 'receipts' + ? Routes.HOUSEHOLD_DETAILS + : Routes.CONSUMER_UPDATE), + arguments: { + "waterconnections": isNameSearch == true + ? waterconnections + .waterConnectionData![index] + : waterconnections + .waterConnection![index], + "mode": arguments['Mode'], + "status": isNameSearch == true + ? waterconnections + .waterConnectionData![index].status + : waterconnections + .waterConnection![index].status + }); + }), SizedBox( height: 8, ), diff --git a/frontend/mgramseva/lib/screeens/connection_results/connection_results.dart b/frontend/mgramseva/lib/screeens/connection_results/connection_results.dart index f37112189..9149823f0 100644 --- a/frontend/mgramseva/lib/screeens/connection_results/connection_results.dart +++ b/frontend/mgramseva/lib/screeens/connection_results/connection_results.dart @@ -1,3 +1,6 @@ +import 'dart:convert'; +import 'dart:developer'; + import 'package:flutter/material.dart'; import 'package:mgramseva/model/connection/water_connections.dart'; import 'package:mgramseva/providers/search_connection_provider.dart'; @@ -33,7 +36,11 @@ class _SearchConsumerResultState extends State { } buildconsumerView(WaterConnections waterConnections) { - return SearchConnectionDetailCard(waterConnections, widget.arguments, isNameSearch: widget.arguments['isNameSearch'],); + return SearchConnectionDetailCard( + waterConnections, + widget.arguments, + isNameSearch: widget.arguments['isNameSearch'], + ); } @override diff --git a/frontend/mgramseva/lib/screeens/household_detail/household_detail.dart b/frontend/mgramseva/lib/screeens/household_detail/household_detail.dart index df3c64c91..2ac460db1 100644 --- a/frontend/mgramseva/lib/screeens/household_detail/household_detail.dart +++ b/frontend/mgramseva/lib/screeens/household_detail/household_detail.dart @@ -43,7 +43,6 @@ class _HouseholdDetailState extends State { } afterViewBuild() { - Provider.of(context, listen: false) ..isVisible = false ..fetchDemand(widget.waterConnection, widget.waterConnection?.demands, @@ -51,10 +50,10 @@ class _HouseholdDetailState extends State { } buildDemandView(DemandList data) { - - var houseHoldProvider = Provider.of(context, listen: false); + log("${houseHoldProvider.waterConnection?.connectionType}"); + log("${houseHoldProvider.isfirstdemand}"); return Column( children: [ data.demands!.isEmpty @@ -95,6 +94,7 @@ class _HouseholdDetailState extends State { Widget build(BuildContext context) { var houseHoldProvider = Provider.of(context, listen: false); + return Scaffold( backgroundColor: Theme.of(context).colorScheme.background, appBar: CustomAppBar(), diff --git a/frontend/mgramseva/lib/services/urls.dart b/frontend/mgramseva/lib/services/urls.dart index 90551537e..ed2e833dc 100644 --- a/frontend/mgramseva/lib/services/urls.dart +++ b/frontend/mgramseva/lib/services/urls.dart @@ -108,4 +108,5 @@ class UserUrl { static const String USER_PROFILE = 'user/_search'; static const String EDIT_PROFILE = 'user/profile/_update'; static const String CHANGE_PASSWORD = 'user/password/_update'; + static const String LOGOUT_USER = 'user/_logout'; }