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

Commit

Permalink
PFM-5262
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuldevgarg committed Jan 19, 2024
1 parent a7676c9 commit d6fb7a7
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 30 deletions.
124 changes: 94 additions & 30 deletions frontend/mgramseva/lib/providers/bill_generation_details_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import 'package:mgramseva/widgets/error_page.dart';
import 'package:provider/provider.dart';

import 'common_provider.dart';
import 'ifix_hierarchy_provider.dart';

class BillGenerationProvider with ChangeNotifier {
var streamController = StreamController.broadcast();
Expand Down Expand Up @@ -355,37 +356,100 @@ class BillGenerationProvider with ChangeNotifier {
}
} else if (formKey.currentState!.validate() &&
billGenerateDetails.serviceType == "Non_Metered") {
try {
Loaders.showLoadingDialog(context);
var commonProvider = Provider.of<CommonProvider>(
navigatorKey.currentContext!,
listen: false);
var res2 = {
"tenantId": commonProvider.userDetails!.selectedtenant!.code,
"billingPeriod": selectedBillPeriod
};
var billResponse2 = await BillGenerateRepository().bulkDemand(res2);
Navigator.pop(context);
String localizationText = getSubtitleText(context);
Navigator.of(context).pushReplacement(
new MaterialPageRoute(builder: (BuildContext context) {
return CommonSuccess(SuccessHandler(
ApplicationLocalizations.of(context)
.translate(i18.demandGenerate.GENERATE_DEMAND_SUCCESS),
localizationText,
i18.common.BACK_HOME,
Routes.BILL_GENERATE,
subHeader:
'${ApplicationLocalizations.of(context).translate(i18.demandGenerate.BILLING_CYCLE_LABEL)}',
subTextFun: () => getLocalizedText(context),
subtitleFun: () => getSubtitleText(context)));
}));
var rateProvider = Provider.of<IfixHierarchyProvider>(
navigatorKey.currentContext!,
listen: false);
var rate = rateProvider.wcBillingSlabs!.wCBillingSlabs!.where((element) => element.connectionType=='Non_Metered').toList();
showDialog(context: context, builder: (context)=>AlertDialog(
surfaceTintColor: Colors.white,
title: Text('${ApplicationLocalizations.of(context).translate(i18.common.CORE_CONFIRM)}'),
content: Container(
height: 370,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('${ApplicationLocalizations.of(context).translate(i18.demandGenerate.ARE_YOU_SURE_TO_GENERATE_DEMAND_FOR)} "${ApplicationLocalizations.of(context).translate(billGenerateDetails.serviceType!)}" ${ApplicationLocalizations.of(context).translate(i18.demandGenerate.WITH_MINIMUM_CHARGE_OF)} : '),
SizedBox(height: 10,),
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.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: [
...rate.map((e) => DataRow(cells: [
DataCell(Text(
"${ApplicationLocalizations.of(context).translate("${e.buildingType}")}")),
DataCell(Text("${e.minimumCharge}"))
])).toList()
],),
),
SizedBox(height: 10,),
Text('${ApplicationLocalizations.of(context).translate(i18.demandGenerate.NO_DEMAND_GEN_WITH_RATE_0)}'), //* Note : No Demand will be generated for the Service Type with rate set to 0.
],
),
),
actions:
(rateProvider.wcBillingSlabs!.wCBillingSlabs!.where((element) => element.connectionType=='Non_Metered').length- rateProvider.wcBillingSlabs!.wCBillingSlabs!.where((element) => element.connectionType=='Non_Metered' && element.minimumCharge==0).length == 0 )
?
[TextButton(onPressed: (){
Navigator.pop(context);
}, child: Text('${ApplicationLocalizations.of(context).translate(i18.consumerReciepts.CLOSE)}'))]
:
[TextButton(onPressed: () async{
if(rateProvider.wcBillingSlabs!.wCBillingSlabs!.where((element) => element.connectionType=='Non_Metered').length- rateProvider.wcBillingSlabs!.wCBillingSlabs!.where((element) => element.connectionType=='Non_Metered' && element.minimumCharge==0).length == 0 ){
Navigator.pop(context);
Notifiers.getToastMessage(context, '${ApplicationLocalizations.of(context).translate(i18.demandGenerate.NO_SERVICE_PRESENT_WITH_RATE_MORE_THAN_0)}', 'ERROR'); //No Service type present with rate more than 0.
return;
}
try {
Loaders.showLoadingDialog(context);
var commonProvider = Provider.of<CommonProvider>(
navigatorKey.currentContext!,
listen: false);
var res2 = {
"tenantId": commonProvider.userDetails!.selectedtenant!.code,
"billingPeriod": selectedBillPeriod
};
var billResponse2 = await BillGenerateRepository().bulkDemand(res2);
Navigator.pop(context);
String localizationText = getSubtitleText(context);
Navigator.of(context).pushReplacement(
new MaterialPageRoute(builder: (BuildContext context) {
return CommonSuccess(SuccessHandler(
ApplicationLocalizations.of(context)
.translate(i18.demandGenerate.GENERATE_DEMAND_SUCCESS),
localizationText,
i18.common.BACK_HOME,
Routes.BILL_GENERATE,
subHeader:
'${ApplicationLocalizations.of(context).translate(i18.demandGenerate.BILLING_CYCLE_LABEL)}',
subTextFun: () => getLocalizedText(context),
subtitleFun: () => getSubtitleText(context)));
}));
} catch (e) {
Navigator.of(context).pushReplacement(
new MaterialPageRoute(builder: (BuildContext context) {
return ErrorPage(e.toString());
}));
}
Navigator.of(context).pushReplacement(
new MaterialPageRoute(builder: (BuildContext context) {
return ErrorPage(e.toString());
}));
}
}, child: Text('${ApplicationLocalizations.of(context).translate(i18.common.YES)}')),
TextButton(onPressed: (){
Navigator.pop(context);
}, child: Text('${ApplicationLocalizations.of(context).translate(i18.common.NO)}')),]
,
));
} else {
autoValidation = true;
notifyListeners();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import 'package:mgramseva/widgets/text_field_builder.dart';
import 'package:mgramseva/widgets/footer.dart';
import 'package:provider/provider.dart';

import '../../providers/ifix_hierarchy_provider.dart';
import '../../utils/localization/application_localizations.dart';

class GenerateBill extends StatefulWidget {
Expand Down Expand Up @@ -54,6 +55,9 @@ class _GenerateBillState extends State<GenerateBill> {
..autoValidation = false
..clearBillYear()
..formKey = GlobalKey<FormState>();

Provider.of<IfixHierarchyProvider>(context,listen: false)
..getBillingSlabs();
}

var metVal = "";
Expand Down
4 changes: 4 additions & 0 deletions frontend/mgramseva/lib/utils/constants/i18_key_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,10 @@ class DemandGenerate {
String get METER_NUMBER_LABEL => 'GENERATE_DEMAND_METER_NUMBER_LABEL';
String get BILLING_YEAR_LABEL => 'GENERATE_DEMAND_BILLING_YEAR_LABEL';
String get BILLING_CYCLE_LABEL => 'GENERATE_DEMAND_BILLING_CYCLE_LABEL';
String get NO_DEMAND_GEN_WITH_RATE_0 => 'NO_DEMAND_GEN_WITH_RATE_0';
String get NO_SERVICE_PRESENT_WITH_RATE_MORE_THAN_0 => 'NO_SERVICE_PRESENT_WITH_RATE_MORE_THAN_0';
String get ARE_YOU_SURE_TO_GENERATE_DEMAND_FOR => 'ARE_YOU_SURE_TO_GENERATE_DEMAND_FOR';
String get WITH_MINIMUM_CHARGE_OF => 'WITH_MINIMUM_CHARGE_OF';
String get PREV_METER_READING_LABEL =>
'GENERATE_DEMAND_PREV_METER_READING_LABEL';
String get NEW_METER_READING_LABEL =>
Expand Down

0 comments on commit d6fb7a7

Please sign in to comment.