Skip to content

Commit

Permalink
Merge pull request #395 from rahuldevgarg-egov/gpwsc-rate-info-screen
Browse files Browse the repository at this point in the history
PFM-1730: removed id from Billing SLab Model
  • Loading branch information
Ramkrishna-egov authored Apr 28, 2023
2 parents f66fdc7 + ccc1f87 commit c2adb26
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 26 deletions.
12 changes: 5 additions & 7 deletions frontend/mgramseva/lib/model/mdms/wc_billing_slab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ part 'wc_billing_slab.g.dart';

@JsonSerializable()
class WCBillingSlab {
@JsonKey(name: "id")
String? id;

@JsonKey(name: "buildingType")
String? buildingType;
Expand All @@ -17,7 +15,7 @@ class WCBillingSlab {
String? calculationAttribute;

@JsonKey(name: "minimumCharge")
String? minimumCharge;
double? minimumCharge;

@JsonKey(name: "slabs")
List<Slabs>? slabs;
Expand All @@ -33,16 +31,16 @@ class WCBillingSlab {
@JsonSerializable()
class Slabs {
@JsonKey(name: "from")
String? from;
int? from;

@JsonKey(name: "to")
String? to;
int? to;

@JsonKey(name: "charge")
String? charge;
double? charge;

@JsonKey(name: "meterCharge")
String? meterCharge;
double? meterCharge;

Slabs();

Expand Down
12 changes: 5 additions & 7 deletions frontend/mgramseva/lib/model/mdms/wc_billing_slab.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/mgramseva/lib/providers/ifix_hierarchy_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class IfixHierarchyProvider with ChangeNotifier {
Map<String,Map<String,String>> hierarchy={};
WCBillingSlabs? wcBillingSlabs;
var streamController = StreamController.broadcast();
var streamControllerRate = StreamController.broadcast();

dispose() {
streamController.close();
Expand Down Expand Up @@ -51,6 +52,7 @@ class IfixHierarchyProvider with ChangeNotifier {
var mdmsRates = await CoreRepository().getRateFromMdms(
commonProvider.userDetails!.selectedtenant!.code!);
wcBillingSlabs = mdmsRates;
streamControllerRate.add(wcBillingSlabs);
callNotifier();
} catch (e, s) {
ErrorHandler().allExceptionsHandler(navigatorKey.currentContext!, e, s);
Expand Down
55 changes: 43 additions & 12 deletions frontend/mgramseva/lib/screeens/GpwscDetails/GpwscRateCard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ 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';

Expand Down Expand Up @@ -31,7 +35,9 @@ class GpwscRateCard extends StatelessWidget {
}
@override
Widget build(BuildContext context) {
WCBillingSlabs? wcBillingSlabs;
return LayoutBuilder(builder: (context, constraints) {
var ifixProvider = Provider.of<IfixHierarchyProvider>(context, listen: false);
return GpwscCard(
children: [
constraints.maxWidth < 760?Column(
Expand All @@ -40,29 +46,52 @@ class GpwscRateCard extends StatelessWidget {
):Row(
children: getTableTitle(context,constraints,rateType),
),
Consumer<IfixHierarchyProvider>(
key: key,
builder: (_, departmentProvider, child) {
return _getRateCard(
rateType, departmentProvider, context, constraints);
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<IfixHierarchyProvider>(
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, IfixHierarchyProvider ifixHierarchyProvider,
Widget _getRateCard(String type, WCBillingSlabs wcBillingSlabs,
context, BoxConstraints constraints) {
List<DataRow> getMeteredRows(){
List<DataRow> rows = [];
ifixHierarchyProvider.wcBillingSlabs!.wCBillingSlabs?.where((element) => element.connectionType?.compareTo("Metered")==0).forEach((e) =>{
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("${e.calculationAttribute}")),
DataCell(Text("${ApplicationLocalizations.of(context)
.translate("${e.calculationAttribute}")}")),
DataCell(Text("${slabs.from}-${slabs.to}")),
DataCell(Text("${e.buildingType}")),
DataCell(Text("${ApplicationLocalizations.of(context)
.translate("${e.buildingType}")}")),
DataCell(Text("${slabs.charge}"))
])))
});
Expand Down Expand Up @@ -149,12 +178,14 @@ class GpwscRateCard extends StatelessWidget {
TextStyle(color: Colors.black, fontWeight: FontWeight.bold),
)),
],
rows: ifixHierarchyProvider.wcBillingSlabs!.wCBillingSlabs!.where((element) => element.connectionType?.compareTo("Metered")!=0)
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("${slab.calculationAttribute}")),
DataCell(Text("${slab.buildingType}")),
DataCell(Text("${ApplicationLocalizations.of(context)
.translate("${slab.calculationAttribute}")}")),
DataCell(Text("${ApplicationLocalizations.of(context)
.translate("${slab.buildingType}")}")),
DataCell(Text("${slab.minimumCharge}"))
]))
.toList()),
Expand Down

0 comments on commit c2adb26

Please sign in to comment.