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

Commit

Permalink
ISTE-141 - FIX
Browse files Browse the repository at this point in the history
  • Loading branch information
Hari-egov committed May 28, 2024
1 parent 3c90662 commit 4e4ad1f
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,13 @@ class NewConsumerBillState extends State<NewConsumerBill> {
buildBillView(BillList billList) {
var houseHoldProvider =
Provider.of<HouseHoldProvider>(context, listen: false);

// if(houseHoldProvider.isLoading){
// return CircularProgressIndicator();
// }
// AggragateDemandDetails? updateDemandList = houseHoldProvider.aggDemandItems;
var commonProvider = Provider.of<CommonProvider>(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
Expand Down Expand Up @@ -238,33 +233,35 @@ class NewConsumerBillState extends State<NewConsumerBill> {
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
.getAdvanceAdjustedAmount(
widget
.demandList)) <=
0
? "₹ 0"
? "₹ ${double.parse(CommonProvider.getAdvanceAdjustedAmount(widget.demandList))}"
: '- ₹${double.parse(CommonProvider.getAdvanceAdjustedAmount(widget.demandList))}',
context),
// Net Due Amount
Expand Down Expand Up @@ -641,6 +638,14 @@ class NewConsumerBillState extends State<NewConsumerBill> {
}
} 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;
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions frontend/mgramseva/lib/env/app_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ dynamic get apiBaseUrl {
}

Map<String, dynamic> devConstants = {
// PROD
// _baseUrl: "https://mgramseva-dwss.punjab.gov.in/",
// UAT
_baseUrl: "https://mgramseva-uat.psegs.in/",
// _baseUrl: kIsWeb
// ? (window.location.origin) + "/"
Expand Down
48 changes: 24 additions & 24 deletions frontend/mgramseva/lib/model/connection/water_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
10 changes: 6 additions & 4 deletions frontend/mgramseva/lib/providers/authentication_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();
Expand Down Expand Up @@ -48,8 +51,7 @@ class AuthenticationProvider with ChangeNotifier {
"id": [loginResponse.userRequest!.id],
"mobileNumber": loginResponse.userRequest!.mobileNumber
}, loginResponse.accessToken!);
var commonProvider =
Provider.of<CommonProvider>(context, listen: false);
var commonProvider = Provider.of<CommonProvider>(context, listen: false);
loginResponse.isFirstTimeLogin = userInfo.user!.first.defaultPwdChgd;
commonProvider.loginCredentials = loginResponse;
if (userInfo.user!.first.defaultPwdChgd == false) {
Expand All @@ -61,7 +63,7 @@ class AuthenticationProvider with ChangeNotifier {
Navigator.of(context).pushNamedAndRemoveUntil(
Routes.HOME, (Route<dynamic> 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');
Expand Down
11 changes: 7 additions & 4 deletions frontend/mgramseva/lib/providers/common_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down
12 changes: 8 additions & 4 deletions frontend/mgramseva/lib/providers/household_details_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@ class HouseHoldProvider with ChangeNotifier {

Future<List<MeterReadings>> 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) {
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down
39 changes: 39 additions & 0 deletions frontend/mgramseva/lib/repository/authentication_repo.dart
Original file line number Diff line number Diff line change
@@ -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<UserDetails> validateLogin(
Expand Down Expand Up @@ -44,4 +48,39 @@ class AuthenticationRepository extends BaseService {
}
return userProfile;
}

Future<dynamic> logoutUser() async {
var commonProvider = Provider.of<CommonProvider>(
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;
}
}
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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,
),
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -33,7 +36,11 @@ class _SearchConsumerResultState extends State<SearchConsumerResult> {
}

buildconsumerView(WaterConnections waterConnections) {
return SearchConnectionDetailCard(waterConnections, widget.arguments, isNameSearch: widget.arguments['isNameSearch'],);
return SearchConnectionDetailCard(
waterConnections,
widget.arguments,
isNameSearch: widget.arguments['isNameSearch'],
);
}

@override
Expand Down
Loading

0 comments on commit 4e4ad1f

Please sign in to comment.