Skip to content

Commit

Permalink
removed id from Billing SLab Model
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuldevgarg committed Apr 28, 2023
1 parent b404280 commit 376e892
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 22 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
43 changes: 35 additions & 8 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,22 +46,43 @@ 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)
Expand Down Expand Up @@ -149,7 +176,7 @@ 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")),
Expand Down

0 comments on commit 376e892

Please sign in to comment.