diff --git a/frontend/mgramseva/assets/icons/config.json b/frontend/mgramseva/assets/icons/config.json index c8d1d9a69..87f7d6076 100644 --- a/frontend/mgramseva/assets/icons/config.json +++ b/frontend/mgramseva/assets/icons/config.json @@ -131,6 +131,20 @@ "search": [ "updateexpenses" ] + }, + { + "uid": "7575e60d98fe96288614b8e6bbb34c8e", + "css": "gpwscdetails", + "code": 59412, + "src": "custom_icons", + "selected": true, + "svg": { + "path": "M888.9 0H111.1C50 0 0 50 0 111.1V888.9C0 950 50 1000 111.1 1000H888.9C950 1000 1000 950 1000 888.9V111.1C1000 50 950 0 888.9 0ZM611.1 777.8H222.2V666.7H611.1V777.8ZM777.8 555.6H222.2V444.4H777.8V555.6ZM777.8 333.3H222.2V222.2H777.8V333.3Z", + "width": 1000 + }, + "search": [ + "gpwscdetails" + ] } ] } \ No newline at end of file diff --git a/frontend/mgramseva/assets/icons/fonts/HomeIcons.ttf b/frontend/mgramseva/assets/icons/fonts/HomeIcons.ttf index 8e366ae82..a645dc6ea 100644 Binary files a/frontend/mgramseva/assets/icons/fonts/HomeIcons.ttf and b/frontend/mgramseva/assets/icons/fonts/HomeIcons.ttf differ diff --git a/frontend/mgramseva/assets/svg/gpwscDetails.svg b/frontend/mgramseva/assets/svg/gpwscDetails.svg new file mode 100644 index 000000000..17b6e1dbe --- /dev/null +++ b/frontend/mgramseva/assets/svg/gpwscDetails.svg @@ -0,0 +1,3 @@ + + + diff --git a/frontend/mgramseva/lib/icons/home_icons_icons.dart b/frontend/mgramseva/lib/icons/home_icons_icons.dart index 67ca27e18..b4c34af90 100644 --- a/frontend/mgramseva/lib/icons/home_icons_icons.dart +++ b/frontend/mgramseva/lib/icons/home_icons_icons.dart @@ -30,4 +30,5 @@ class HomeIcons { static const IconData printreciept = IconData(0xe806, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData updateconsumer = IconData(0xe807, fontFamily: _kFontFam, fontPackage: _kFontPkg); static const IconData updateexpenses = IconData(0xe808, fontFamily: _kFontFam, fontPackage: _kFontPkg); + static const IconData gpwscdetails = IconData(0xe814, fontFamily: _kFontFam, fontPackage: _kFontPkg); } diff --git a/frontend/mgramseva/lib/main.dart b/frontend/mgramseva/lib/main.dart index b67d4f2b6..25f1860f6 100644 --- a/frontend/mgramseva/lib/main.dart +++ b/frontend/mgramseva/lib/main.dart @@ -24,6 +24,7 @@ import 'package:mgramseva/providers/forgot_password_provider.dart'; import 'package:mgramseva/providers/home_provider.dart'; import 'package:mgramseva/providers/household_details_provider.dart'; import 'package:mgramseva/providers/household_register_provider.dart'; +import 'package:mgramseva/providers/ifix_hierarchy_provider.dart'; import 'package:mgramseva/providers/language.dart'; import 'package:mgramseva/providers/notification_screen_provider.dart'; import 'package:mgramseva/providers/notifications_provider.dart'; @@ -188,6 +189,7 @@ class _MyAppState extends State { ChangeNotifierProvider(create: (_) => RevenueDashboard()), ChangeNotifierProvider(create: (_) => HouseholdRegisterProvider()), ChangeNotifierProvider(create: (_) => NotificationScreenProvider()), + ChangeNotifierProvider(create: (_) => IfixHierarchyProvider()), ], child: Consumer( builder: (_, userProvider, child) => GestureDetector( diff --git a/frontend/mgramseva/lib/model/localization/language.dart b/frontend/mgramseva/lib/model/localization/language.dart index 55ab344f2..1c60bc706 100644 --- a/frontend/mgramseva/lib/model/localization/language.dart +++ b/frontend/mgramseva/lib/model/localization/language.dart @@ -6,6 +6,8 @@ import 'package:mgramseva/model/mdms/property_type.dart'; import 'package:mgramseva/model/mdms/sub_category_type.dart'; import 'package:mgramseva/model/mdms/tax_period.dart'; +import '../../repository/water_services_calculation.dart'; + class LanguageList { dynamic? responseInfo; MdmsRes? mdmsRes; @@ -37,6 +39,7 @@ class MdmsRes { Category? category; SubCategory? subCategory; TaxPeriodListModel? taxPeriodList; + WCBillingSlabs? wcBillingSlabList; MdmsRes({this.commonMasters}); @@ -65,6 +68,9 @@ class MdmsRes { taxPeriodList = json['BillingService'] != null ? new TaxPeriodListModel.fromJson(json['BillingService']) : null; + wcBillingSlabList = json['ws-services-calculation'] != null + ? new WCBillingSlabs.fromJson(json['ws-services-calculation']) + : null; } Map toJson() { diff --git a/frontend/mgramseva/lib/model/mdms/department.dart b/frontend/mgramseva/lib/model/mdms/department.dart new file mode 100644 index 000000000..68895c9b2 --- /dev/null +++ b/frontend/mgramseva/lib/model/mdms/department.dart @@ -0,0 +1,46 @@ +import 'dart:math'; + +class Department { + final String id; + final String tenantId; + final String departmentId; + final String code; + final String name; + final int hierarchyLevel; + late final List children; + + Department({ + required this.id, + required this.tenantId, + required this.departmentId, + required this.code, + required this.name, + required this.hierarchyLevel, + List? children, + }) : children = children ?? []; + + factory Department.fromJson(Map json) { + final childrenJson = json['children'] as List; + return Department( + id: json['id']??'', + tenantId: json['tenantId']??'', + departmentId: json['departmentId']??'', + code: json['code']??'', + name: json['name']??'', + hierarchyLevel: json['hierarchyLevel'] ?? Random().nextInt(500)+50, + children: childrenJson.map((childJson) => Department.fromJson(childJson)).toList(), + ); + } + + Map toJson() { + return { + 'id': id, + 'tenantId': tenantId, + 'departmentId': departmentId, + 'code': code, + 'name': name, + 'hierarchyLevel': hierarchyLevel, + 'children': List>.from(children.map((child) => child.toJson())), + }; + } +} \ No newline at end of file diff --git a/frontend/mgramseva/lib/model/mdms/wc_billing_slab.dart b/frontend/mgramseva/lib/model/mdms/wc_billing_slab.dart new file mode 100644 index 000000000..62e0206c4 --- /dev/null +++ b/frontend/mgramseva/lib/model/mdms/wc_billing_slab.dart @@ -0,0 +1,50 @@ +import 'package:json_annotation/json_annotation.dart'; + +part 'wc_billing_slab.g.dart'; + +@JsonSerializable() +class WCBillingSlab { + + @JsonKey(name: "buildingType") + String? buildingType; + + @JsonKey(name: "connectionType") + String? connectionType; + + @JsonKey(name: "calculationAttribute") + String? calculationAttribute; + + @JsonKey(name: "minimumCharge") + double? minimumCharge; + + @JsonKey(name: "slabs") + List? slabs; + + WCBillingSlab(); + + factory WCBillingSlab.fromJson(Map json) => + _$WCBillingSlabFromJson(json); + + Map toJson() => _$WCBillingSlabToJson(this); +} + +@JsonSerializable() +class Slabs { + @JsonKey(name: "from") + int? from; + + @JsonKey(name: "to") + int? to; + + @JsonKey(name: "charge") + double? charge; + + @JsonKey(name: "meterCharge") + double? meterCharge; + + Slabs(); + + factory Slabs.fromJson(Map json) => _$SlabsFromJson(json); + + Map toJson() => _$SlabsToJson(this); +} diff --git a/frontend/mgramseva/lib/model/mdms/wc_billing_slab.g.dart b/frontend/mgramseva/lib/model/mdms/wc_billing_slab.g.dart new file mode 100644 index 000000000..31a870785 --- /dev/null +++ b/frontend/mgramseva/lib/model/mdms/wc_billing_slab.g.dart @@ -0,0 +1,39 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'wc_billing_slab.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +WCBillingSlab _$WCBillingSlabFromJson(Map json) => + WCBillingSlab() + ..buildingType = json['buildingType'] as String? + ..connectionType = json['connectionType'] as String? + ..calculationAttribute = json['calculationAttribute'] as String? + ..minimumCharge = json['minimumCharge'] as double? + ..slabs = (json['slabs'] as List?) + ?.map((e) => Slabs.fromJson(e as Map)) + .toList(); + +Map _$WCBillingSlabToJson(WCBillingSlab instance) => + { + 'buildingType': instance.buildingType, + 'connectionType': instance.connectionType, + 'calculationAttribute': instance.calculationAttribute, + 'minimumCharge': instance.minimumCharge, + 'slabs': instance.slabs, + }; + +Slabs _$SlabsFromJson(Map json) => Slabs() + ..from = json['from'] as int? + ..to = json['to'] as int? + ..charge = json['charge'] as double? + ..meterCharge = json['meterCharge'] as double?; + +Map _$SlabsToJson(Slabs instance) => { + 'from': instance.from, + 'to': instance.to, + 'charge': instance.charge, + 'meterCharge': instance.meterCharge, + }; diff --git a/frontend/mgramseva/lib/providers/ifix_hierarchy_provider.dart b/frontend/mgramseva/lib/providers/ifix_hierarchy_provider.dart new file mode 100644 index 000000000..444d6b19e --- /dev/null +++ b/frontend/mgramseva/lib/providers/ifix_hierarchy_provider.dart @@ -0,0 +1,78 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:mgramseva/model/mdms/department.dart'; +import 'package:mgramseva/repository/core_repo.dart'; +import 'package:mgramseva/repository/water_services_calculation.dart'; +import 'package:mgramseva/utils/error_logging.dart'; +import 'package:mgramseva/utils/global_variables.dart'; +import 'package:provider/provider.dart'; + +import '../repository/ifix_hierarchy_repo.dart'; +import 'common_provider.dart'; + +class IfixHierarchyProvider with ChangeNotifier { + Department? departments; + Map> hierarchy={}; + WCBillingSlabs? wcBillingSlabs; + var streamController = StreamController.broadcast(); + var streamControllerRate = StreamController.broadcast(); + + dispose() { + streamController.close(); + super.dispose(); + } + + Future getDepartments() async { + try { + var commonProvider = Provider.of( + navigatorKey.currentContext!, + listen: false); + var userResponse = await IfixHierarchyRepo().fetchDepartments( + commonProvider.userDetails!.selectedtenant!.city!.code!, true); + departments = userResponse; + hierarchy.clear(); + if(departments!=null){ + parseDepartments(departments!); + } + streamController.add(userResponse); + callNotifier(); + } catch (e, s) { + hierarchy.clear(); + ErrorHandler().allExceptionsHandler(navigatorKey.currentContext!, e, s); + streamController.addError('error'); + } + } + + Future getBillingSlabs() async { + try { + var commonProvider = Provider.of( + navigatorKey.currentContext!, + listen: false); + var mdmsRates = await CoreRepository().getRateFromMdms( + commonProvider.userDetails!.selectedtenant!.code!); + wcBillingSlabs = mdmsRates; + streamControllerRate.add(wcBillingSlabs); + callNotifier(); + } catch (e, s) { + ErrorHandler().allExceptionsHandler(navigatorKey.currentContext!, e, s); + streamController.addError('error'); + } + } + void callNotifier() { + notifyListeners(); + } + void parseDepartments(Department department) { + final Map departmentData = { + 'departmentId': department.departmentId, + 'code': department.code, + 'name': department.name, + 'hierarchyLevel': department.hierarchyLevel.toString(), + }; + hierarchy.addAll({department.hierarchyLevel.toString(): departmentData}); + callNotifier(); + for (final child in department.children) { + parseDepartments(child); + } + } +} diff --git a/frontend/mgramseva/lib/repository/core_repo.dart b/frontend/mgramseva/lib/repository/core_repo.dart index cb3c74813..2a534f1d8 100644 --- a/frontend/mgramseva/lib/repository/core_repo.dart +++ b/frontend/mgramseva/lib/repository/core_repo.dart @@ -15,6 +15,7 @@ import 'package:mgramseva/model/mdms/payment_type.dart'; import 'package:mgramseva/providers/common_provider.dart'; import 'package:mgramseva/providers/language.dart'; import 'package:mgramseva/providers/notifications_provider.dart'; +import 'package:mgramseva/repository/water_services_calculation.dart'; import 'package:mgramseva/services/RequestInfo.dart'; import 'package:mgramseva/services/base_service.dart'; import 'package:mgramseva/services/urls.dart'; @@ -74,7 +75,41 @@ class CoreRepository extends BaseService { } return languageList; } - + Future getRateFromMdms(String tenantId) async { + var body = { + "MdmsCriteria": { + "tenantId": tenantId, + "moduleDetails": [ + { + "moduleName": "ws-services-calculation", + "masterDetails": [ + { + "name": "WCBillingSlab" + } + ] + } + ] + } + }; + late LanguageList languageList; + var res = await makeRequest( + url: Url.MDMS, + body: body, + method: RequestType.POST, + requestInfo: RequestInfo( + APIConstants.API_MODULE_NAME, + APIConstants.API_VERSION, + APIConstants.API_TS, + "_search", + APIConstants.API_DID, + APIConstants.API_KEY, + APIConstants.API_MESSAGE_ID, + "")); + if (res != null) { + languageList = LanguageList.fromJson(res); + } + return languageList.mdmsRes?.wcBillingSlabList; + } Future getPaymentTypeMDMS(Map body) async { late PaymentType paymentType; var res = await makeRequest( diff --git a/frontend/mgramseva/lib/repository/ifix_hierarchy_repo.dart b/frontend/mgramseva/lib/repository/ifix_hierarchy_repo.dart new file mode 100644 index 000000000..e51cb0cc5 --- /dev/null +++ b/frontend/mgramseva/lib/repository/ifix_hierarchy_repo.dart @@ -0,0 +1,48 @@ +import 'package:provider/provider.dart'; +import 'package:mgramseva/services/urls.dart'; +import '../model/mdms/department.dart'; +import '../providers/common_provider.dart'; +import '../services/RequestInfo.dart'; +import '../services/base_service.dart'; +import '../utils/global_variables.dart'; +import '../utils/models.dart'; + +class IfixHierarchyRepo extends BaseService { + Future fetchDepartments(String code, bool getAncestry, + [String? token]) async { + var commonProvider = Provider.of( + navigatorKey.currentContext!, + listen: false); + late Department? departments; + final requestInfo = RequestInfo('mGramSeva', .01, "", "search", "", "", "", + token ?? commonProvider.userDetails!.accessToken); + var body = { + "criteria": { + "code": code, + "tenantId": + commonProvider.userDetails!.selectedtenant?.code?.substring(0, 2), + "getAncestry": getAncestry + }, + 'requestHeader': { + "ts": 1627193067, + "version": "2.0.0", + "msgId": "Unknown", + "signature": "NON" + } + }; + var res = await makeRequest( + url: Url.IFIX_DEPARTMENT_ENTITY, + body: body, + requestInfo: requestInfo, + method: RequestType.POST); + if (res != null && + res['departmentEntity'] != null) { + try{ + departments = Department.fromJson(res['departmentEntity'][0]); + }catch(e){ + departments=null; + } + } + return departments; + } +} diff --git a/frontend/mgramseva/lib/repository/water_services_calculation.dart b/frontend/mgramseva/lib/repository/water_services_calculation.dart new file mode 100644 index 000000000..d4aa0d99a --- /dev/null +++ b/frontend/mgramseva/lib/repository/water_services_calculation.dart @@ -0,0 +1,18 @@ +import 'package:json_annotation/json_annotation.dart'; + +import '../model/mdms/wc_billing_slab.dart'; + +part 'water_services_calculation.g.dart'; + +@JsonSerializable() +class WCBillingSlabs { + @JsonKey(name: "WCBillingSlab") + List? wCBillingSlabs; + + WCBillingSlabs(); + + factory WCBillingSlabs.fromJson(Map json) => + _$WCBillingSlabsFromJson(json); + + Map toJson() => _$WCBillingSlabsToJson(this); +} diff --git a/frontend/mgramseva/lib/repository/water_services_calculation.g.dart b/frontend/mgramseva/lib/repository/water_services_calculation.g.dart new file mode 100644 index 000000000..99bf5bd50 --- /dev/null +++ b/frontend/mgramseva/lib/repository/water_services_calculation.g.dart @@ -0,0 +1,18 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'water_services_calculation.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +WCBillingSlabs _$WCBillingSlabsFromJson(Map json) => + WCBillingSlabs() + ..wCBillingSlabs = (json['WCBillingSlab'] as List?) + ?.map((e) => WCBillingSlab.fromJson(e as Map)) + .toList(); + +Map _$WCBillingSlabsToJson(WCBillingSlabs instance) => + { + 'WCBillingSlab': instance.wCBillingSlabs, + }; diff --git a/frontend/mgramseva/lib/router.dart b/frontend/mgramseva/lib/router.dart index 39bcafda8..c9b9509b7 100644 --- a/frontend/mgramseva/lib/router.dart +++ b/frontend/mgramseva/lib/router.dart @@ -8,6 +8,7 @@ import 'package:mgramseva/model/expensesDetails/expenses_details.dart'; import 'package:mgramseva/providers/common_provider.dart'; import 'package:mgramseva/routers/Routers.dart'; import 'package:mgramseva/screeens/ConsumerDetails/ConsumerDetails.dart'; +import 'package:mgramseva/screeens/GpwscDetails/GpwscDetails.dart'; import 'package:mgramseva/screeens/Home/Home.dart'; import 'package:mgramseva/screeens/HouseholdRegister/HouseholdRegister.dart'; import 'package:mgramseva/screeens/Login/Login.dart'; @@ -297,6 +298,12 @@ class router { return MaterialPageRoute( builder: (_) => Dashboard(initialTabIndex: tabIndex), settings: RouteSettings(name: tabIndex != null ? '${Routes.DASHBOARD}?tab=$tabIndex' : '${Routes.DASHBOARD}')); + + case Routes.GPWSC_DETAILS_AND_RATE_INFO: + return MaterialPageRoute( + builder: (_) => GpwscDetails(), + settings: RouteSettings(name: Routes.GPWSC_DETAILS_AND_RATE_INFO)); + case Routes.SEARCH_CONSUMER_RESULT: if (settings.arguments == null) { return MaterialPageRoute( diff --git a/frontend/mgramseva/lib/routers/Routers.dart b/frontend/mgramseva/lib/routers/Routers.dart index 15313b3a6..0dfaf7de0 100644 --- a/frontend/mgramseva/lib/routers/Routers.dart +++ b/frontend/mgramseva/lib/routers/Routers.dart @@ -53,6 +53,7 @@ class Routes { '$HOUSEHOLD_DETAILS_COLLECT_PAYMENT/success'; static const String DASHBOARD = '/home/dashboard'; + static const String GPWSC_DETAILS_AND_RATE_INFO = '/home/villagedetails'; static const String BILL_GENERATE = '/home/householddetails/billgenerate'; diff --git a/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscBoundaryDetailCard.dart b/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscBoundaryDetailCard.dart new file mode 100644 index 000000000..9f7aae192 --- /dev/null +++ b/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscBoundaryDetailCard.dart @@ -0,0 +1,104 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mgramseva/providers/common_provider.dart'; +import 'package:mgramseva/providers/ifix_hierarchy_provider.dart'; +import 'package:mgramseva/utils/Constants/I18KeyConstants.dart'; +import 'package:provider/provider.dart'; + +import '../../utils/Locilization/application_localizations.dart'; +import '../../widgets/LabelText.dart'; +import 'GpwscCard.dart'; + +class GpwscBoundaryDetailCard extends StatelessWidget { + const GpwscBoundaryDetailCard({ + Key? key + }) : super(key: key); + _getLabeltext(label, value, context) { + return (Row( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Container( + padding: EdgeInsets.only(top: 16, bottom: 16), + width: MediaQuery.of(context).size.width / 3, + child: Text( + ApplicationLocalizations.of(context).translate(label), + style: TextStyle(fontSize: 16, fontWeight: FontWeight.w700), + )), + new Flexible( + child: Container( + padding: EdgeInsets.only(top: 16, bottom: 16, left: 8), + child: Text( + ApplicationLocalizations.of(context).translate(value), + maxLines: 3, + softWrap: true, + style: TextStyle( + fontSize: 16, fontWeight: FontWeight.w400)))) + ])); + } + @override + Widget build(BuildContext context) { + return LayoutBuilder(builder: (context, constraints) { + return Consumer( + key: key, + builder: (_, departmentProvider, child) { + return Consumer( + builder: (_, commonProvider, child) { + return GpwscCard( + children: [ + LabelText(i18.dashboard.GPWSC_DETAILS), + Padding( + padding: constraints.maxWidth > 760 + ? const EdgeInsets.all(20.0) + : const EdgeInsets.all(8.0), + child: Column( + children: [ + _getLabeltext( + "${ApplicationLocalizations.of(context).translate(i18.common.VILLAGE_CODE)}", + commonProvider.userDetails!.selectedtenant?.city?.code, + context), + _getLabeltext( + "${ApplicationLocalizations.of(context).translate(i18.common.VILLAGE_NAME)}", + commonProvider.userDetails!.selectedtenant?.code, + context), + _getLabeltext( + "${ApplicationLocalizations.of(context).translate(i18.common.SECTION_CODE)}", + departmentProvider.hierarchy.containsKey("5") + ? '${departmentProvider.hierarchy["5"]!["code"]}-${departmentProvider.hierarchy["5"]!["name"]}' + : '', + context), + _getLabeltext( + "${ApplicationLocalizations.of(context).translate(i18.common.SUB_DIVISION_CODE)}", + departmentProvider.hierarchy.containsKey("4") + ? '${departmentProvider.hierarchy["4"]!['code']}-${departmentProvider.hierarchy["5"]!["name"]}' + : '', + context), + _getLabeltext( + "${ApplicationLocalizations.of(context).translate(i18.common.DIVISION_CODE)}", + departmentProvider.hierarchy.containsKey("3") + ? '${departmentProvider.hierarchy["3"]!['code']}-${departmentProvider.hierarchy["3"]!["name"]}' + : '', + context), + _getLabeltext( + "${ApplicationLocalizations.of(context).translate(i18.common.PROJECT_SCHEME_CODE)}", + commonProvider.userDetails!.selectedtenant?.city?.code, + context), + _getLabeltext( + "${ApplicationLocalizations.of(context).translate(i18.common.REGION_NAME)}", + '${commonProvider.userDetails!.selectedtenant?.city?.regionName}', + context), + _getLabeltext( + "${ApplicationLocalizations.of(context).translate(i18.common.DISTRICT_CODE)}", + '${commonProvider.userDetails!.selectedtenant?.city?.districtCode}-${commonProvider.userDetails!.selectedtenant?.city?.districtName}', + context) + ], + ), + ) + ], + ); + }, + ); + }); + }); + } +} \ No newline at end of file diff --git a/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscCard.dart b/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscCard.dart new file mode 100644 index 000000000..6eba2d367 --- /dev/null +++ b/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscCard.dart @@ -0,0 +1,24 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +class GpwscCard extends StatelessWidget { + final List children; + const GpwscCard({ + Key? key,required this.children + }) : super(key: key); + @override + Widget build(BuildContext context) { + return LayoutBuilder(builder: (context, constraints) { + return Card( + margin: EdgeInsets.only(bottom: 2), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.0), + ), + child: Column( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + children: children), + ); + }); + } +} \ No newline at end of file diff --git a/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscDetails.dart b/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscDetails.dart new file mode 100644 index 000000000..303a60b6b --- /dev/null +++ b/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscDetails.dart @@ -0,0 +1,118 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_focus_watcher/flutter_focus_watcher.dart'; +import 'package:mgramseva/screeens/GpwscDetails/GpwscRateCard.dart'; +import 'package:provider/provider.dart'; +import 'package:screenshot/screenshot.dart'; + +import '../../providers/dashboard_provider.dart'; +import '../../providers/ifix_hierarchy_provider.dart'; +import '../../utils/global_variables.dart'; +import '../../widgets/DrawerWrapper.dart'; +import '../../widgets/HomeBack.dart'; +import '../../widgets/SideBar.dart'; +import '../../widgets/customAppbar.dart'; +import '../../widgets/custom_overlay/show_overlay.dart'; +import '../../widgets/footer.dart'; +import 'GpwscBoundaryDetailCard.dart'; + +class GpwscDetails extends StatefulWidget { + const GpwscDetails({Key? key}) : super(key: key); + + @override + State createState() { + return _GpwscDetails(); + } +} + +class _GpwscDetails extends State + with SingleTickerProviderStateMixin { + GlobalKey key = GlobalKey(); + ScreenshotController screenshotController = ScreenshotController(); + ScrollController scrollController = ScrollController(); + var takeScreenShot = false; + + @override + void dispose() { + super.dispose(); + } + + @override + void initState() { + super.initState(); + var departmentProvider = Provider.of(navigatorKey.currentContext!, listen: false); + departmentProvider.getDepartments(); + departmentProvider.getBillingSlabs(); + WidgetsBinding.instance.addPostFrameCallback((_) => afterViewBuild()); + } + + afterViewBuild() { + var dashBoardProvider = + Provider.of(context, listen: false); + dashBoardProvider.fetchUserFeedbackDetails(context); + } + + @override + Widget build(BuildContext context) { + return WillPopScope( + onWillPop: () async { + if (CustomOVerlay.removeOverLay()) return false; + return true; + }, + child: GestureDetector( + onTap: () => CustomOVerlay.removeOverLay(), + child: FocusWatcher( + child: Scaffold( + appBar: CustomAppBar(), + drawer: DrawerWrapper( + Drawer(child: SideBar()), + ), + backgroundColor: Color.fromRGBO(238, 238, 238, 1), + body: LayoutBuilder( + builder: (context, constraints) => Container( + alignment: Alignment.center, + margin: constraints.maxWidth < 760 + ? null + : EdgeInsets.symmetric( + horizontal: MediaQuery.of(context).size.width / 25), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + HomeBack(callback: onClickOfBackButton), + ], + ), + Container( + key: key, + color: Color.fromRGBO(238, 238, 238, 1), + padding: EdgeInsets.only(left: 8, right: 8), + height: constraints.maxHeight-50, + child: SingleChildScrollView( + controller: scrollController, + child: Column( + children: [ + GpwscBoundaryDetailCard(), + SizedBox(height: 10,), + GpwscRateCard(rateType: "Non_Metered"), + SizedBox(height: 10,), + GpwscRateCard(rateType: "Metered"), + Footer() + ], + ), + ), + ), + ], + ), + ), + ), + )), + )); + } + + void onClickOfBackButton() { + CustomOVerlay.removeOverLay(); + Navigator.pop(context); + } +} diff --git a/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscRateCard.dart b/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscRateCard.dart new file mode 100644 index 000000000..bbe5bf987 --- /dev/null +++ b/frontend/mgramseva/lib/screeens/GpwscDetails/GpwscRateCard.dart @@ -0,0 +1,195 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:mgramseva/utils/Constants/I18KeyConstants.dart'; +import 'package:provider/provider.dart'; +import '../../providers/ifix_hierarchy_provider.dart'; +import '../../repository/water_services_calculation.dart'; +import '../../utils/Locilization/application_localizations.dart'; +import '../../utils/common_widgets.dart'; +import '../../utils/loaders.dart'; +import '../../utils/notifyers.dart'; +import '../../widgets/LabelText.dart'; +import 'GpwscCard.dart'; + +class GpwscRateCard extends StatelessWidget { + final String rateType; + + const GpwscRateCard({Key? key, required this.rateType}) : super(key: key); + + Color getColor(Set states) { + return Colors.grey.shade200; + } + List getTableTitle(context,constraints,String rateType){ + return [ + LabelText( + "${ApplicationLocalizations.of(context).translate(i18.dashboard.GPWSC_RATE_INFO)}"), + Padding( + padding: (constraints.maxWidth > 760 ? const EdgeInsets.all(15.0) : const EdgeInsets.all(8.0)), + child: Text( + "(${ApplicationLocalizations.of(context).translate(rateType)})", + style: Theme.of(context).textTheme.titleLarge, + textAlign: TextAlign.left, + ), + ), + ]; + } + @override + Widget build(BuildContext context) { + WCBillingSlabs? wcBillingSlabs; + return LayoutBuilder(builder: (context, constraints) { + var ifixProvider = Provider.of(context, listen: false); + return GpwscCard( + children: [ + constraints.maxWidth < 760?Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: getTableTitle(context,constraints,rateType), + ):Row( + children: getTableTitle(context,constraints,rateType), + ), + StreamBuilder( + stream: ifixProvider.streamControllerRate.stream, + builder: (context, AsyncSnapshot snapshot) { + if (snapshot.hasData) { + if (snapshot.data is String) { + return CommonWidgets.buildEmptyMessage(snapshot.data, context); + } + wcBillingSlabs = snapshot.data; + return Consumer( + key: key, + builder: (_, departmentProvider, child) { + return _getRateCard( + rateType, wcBillingSlabs!, context, constraints); + }); + } else if (snapshot.hasError) { + return Notifiers.networkErrorPage(context, () => {}); + } else { + switch (snapshot.connectionState) { + case ConnectionState.waiting: + return Loaders.CircularLoader(); + case ConnectionState.active: + return Loaders.CircularLoader(); + default: + return Container(); + } + } + }) + ], + ); + }); + } + + Widget _getRateCard(String type, WCBillingSlabs wcBillingSlabs, + context, BoxConstraints constraints) { + List getMeteredRows(){ + List rows = []; + wcBillingSlabs.wCBillingSlabs?.where((element) => element.connectionType?.compareTo("Metered")==0).forEach((e) =>{ + e.slabs?.forEach((slabs) => + rows.add(DataRow(cells: [ + DataCell(Text("${ApplicationLocalizations.of(context) + .translate(i18.common.WATER_CHARGES)}-10101")), + DataCell(Text("${ApplicationLocalizations.of(context) + .translate("${e.calculationAttribute}")}")), + DataCell(Text("${slabs.from}-${slabs.to}")), + DataCell(Text("${ApplicationLocalizations.of(context) + .translate("${e.buildingType}")}")), + DataCell(Text("${slabs.charge}")) + ]))) + }); + return rows; + } + if (type.compareTo("Metered") == 0) { + return Padding( + padding: constraints.maxWidth > 760 + ? const EdgeInsets.all(20.0) + : const EdgeInsets.all(8.0), + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + border: TableBorder.all( + width: 0.5, borderRadius: BorderRadius.all(Radius.circular(5))), + columns: [ + DataColumn( + label: Text( + "${ApplicationLocalizations.of(context).translate(i18.common.CHARGE_HEAD)}", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold), + )), + DataColumn( + label: Text( + "${ApplicationLocalizations.of(context).translate(i18.common.CALC_TYPE)}", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold), + )), + DataColumn( + label: Text( + "${ApplicationLocalizations.of(context).translate(i18.common.BILLING_SLAB)}", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold), + )), + DataColumn( + label: Text( + "${ApplicationLocalizations.of(context).translate(i18.searchWaterConnection.CONNECTION_TYPE)}", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold), + )), + DataColumn( + label: Text( + "${ApplicationLocalizations.of(context).translate(i18.common.RATE_PERCENTAGE)}", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold), + )), + ], + rows: getMeteredRows()), + ), + ); + } + return Padding( + padding: constraints.maxWidth > 760 + ? const EdgeInsets.all(20.0) + : const EdgeInsets.all(8.0), + child: SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + border: TableBorder.all( + width: 0.5, borderRadius: BorderRadius.all(Radius.circular(5))), + columns: [ + DataColumn( + label: Text( + "${ApplicationLocalizations.of(context).translate(i18.common.CHARGE_HEAD)}", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold), + )), + DataColumn( + label: Text( + "${ApplicationLocalizations.of(context).translate(i18.common.CALC_TYPE)}", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold), + )), + DataColumn( + label: Text( + "${ApplicationLocalizations.of(context).translate(i18.searchWaterConnection.CONNECTION_TYPE)}", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold), + )), + DataColumn( + label: Text( + "${ApplicationLocalizations.of(context).translate(i18.common.RATE_PERCENTAGE)}", + style: + TextStyle(color: Colors.black, fontWeight: FontWeight.bold), + )), + ], + rows: wcBillingSlabs.wCBillingSlabs!.where((element) => element.connectionType?.compareTo("Metered")!=0) + .map((slab) => DataRow(cells: [ + DataCell(Text("${ApplicationLocalizations.of(context) + .translate(i18.common.WATER_CHARGES)}-10101")), + DataCell(Text("${ApplicationLocalizations.of(context) + .translate("${slab.calculationAttribute}")}")), + DataCell(Text("${ApplicationLocalizations.of(context) + .translate("${slab.buildingType}")}")), + DataCell(Text("${slab.minimumCharge}")) + ])) + .toList()), + ), + ); + } +} diff --git a/frontend/mgramseva/lib/services/urls.dart b/frontend/mgramseva/lib/services/urls.dart index 158c6ce02..01e1854fc 100644 --- a/frontend/mgramseva/lib/services/urls.dart +++ b/frontend/mgramseva/lib/services/urls.dart @@ -72,6 +72,9 @@ class Url { static const String DASHBOARD_COLLECTION_TABLE_DATA = 'ws-services/wc/_revenueCollectionData'; static const String DASHBOARD_EXPENSE_TABLE_DATA = 'echallan-services/eChallan/v1/_chalanCollectionData'; + /// GPWSC Details + static const String IFIX_DEPARTMENT_ENTITY = 'ifix-department-entity/departmentEntity/v1/_search'; + } class UserUrl { diff --git a/frontend/mgramseva/lib/utils/Constants/I18KeyConstants.dart b/frontend/mgramseva/lib/utils/Constants/I18KeyConstants.dart index f96f07e3f..510fecc62 100644 --- a/frontend/mgramseva/lib/utils/Constants/I18KeyConstants.dart +++ b/frontend/mgramseva/lib/utils/Constants/I18KeyConstants.dart @@ -205,6 +205,22 @@ class Common { String get CORE_CONFIRM => 'CORE_CONFIRM'; String get CORE_ADVANCE_RUPEE => 'CORE_ADVANCE_RUPEE'; String get ADVANCE_AVAILABLE => 'ADVANCE_AVAILABLE'; + + String get VILLAGE_CODE => 'VILLAGE_CODE'; + String get VILLAGE_NAME => 'VILLAGE_NAME'; + String get SECTION_CODE => 'SECTION_CODE'; + String get SUB_DIVISION_CODE => 'SUB_DIVISION_CODE'; + String get DIVISION_CODE => 'DIVISION_CODE'; + String get DISTRICT_CODE => 'DISTRICT_CODE'; + String get PROJECT_SCHEME_CODE => 'PROJECT_SCHEME_CODE'; + + String get CHARGE_HEAD => 'CHARGE_HEAD'; + String get CALC_TYPE => 'CALC_TYPE'; + String get BILLING_SLAB => 'BILLING_SLAB'; + String get SERVICE_TYPE => 'SERVICE_TYPE'; + String get RATE_PERCENTAGE => 'RATE_PERCENTAGE'; + + String get REGION_NAME => 'REGION_NAME'; } class Password { @@ -467,6 +483,7 @@ class BillDetails { 'CORE_NET_DUE_AMOUNT_WITH_PENALTY'; String get WS_10201 => 'WS_10201'; String get WS_10102 => 'WS_10102'; + String get WATER_CHARGES_10101 => 'WATER_CHARGES_10101'; String get CORE_PENALTY_APPLICABLE => 'CORE_PENALTY_APPLICABLE'; } @@ -623,6 +640,11 @@ class _DashBoard { String get EXPENDITURE_DESC => 'EXPENDITURE_DESC'; String get COLLECTION_DESC => 'COLLECTION_DESC'; String get NUMBER_OF_RECORDS => 'NUMBER_OF_RECORDS'; + + String get CORE_GPWSC_DETAILS_AND_RATE_INFO => + 'CORE_GPWSC_DETAILS_AND_RATE_INFO'; + String get GPWSC_DETAILS => 'GPWSC_DETAILS'; + String get GPWSC_RATE_INFO => 'GPWSC_RATE_INFO'; } class _ExpenseWalkThroughMsg { diff --git a/frontend/mgramseva/lib/utils/constants.dart b/frontend/mgramseva/lib/utils/constants.dart index f7f6994f5..441075d02 100644 --- a/frontend/mgramseva/lib/utils/constants.dart +++ b/frontend/mgramseva/lib/utils/constants.dart @@ -93,6 +93,11 @@ class Constants { (i18.homeWalkThroughMSg.GPWSC_DASHBOARD_MSG), HomeIcons.dashboard, Routes.DASHBOARD, {}), + HomeItem( + "CORE_GPWSC_DETAILS_AND_RATE_INFO", + (i18.dashboard.CORE_GPWSC_DETAILS_AND_RATE_INFO), + HomeIcons.gpwscdetails, + Routes.GPWSC_DETAILS_AND_RATE_INFO, {}), ]; static List SERVICECATEGORY = [