From fc818510fe354ca831524aa769a31f82502c6f0c Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:43:24 +0530 Subject: [PATCH 1/4] PFM-4136-version-upgrade --- .../expenses_details/expenses_details.dart | 9 ++- .../providers/expenses_details_provider.dart | 24 ++++++-- .../screeens/add_expense/expense_details.dart | 61 ++++++++++--------- 3 files changed, 59 insertions(+), 35 deletions(-) diff --git a/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart b/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart index 72cbca65f..e7649daf6 100644 --- a/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart +++ b/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart @@ -2,7 +2,11 @@ import 'package:flutter/material.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:mgramseva/model/expenses_details/vendor.dart'; import 'package:mgramseva/model/file/file_store.dart'; +import 'package:mgramseva/providers/expenses_details_provider.dart'; import 'package:mgramseva/utils/date_formats.dart'; +import 'package:provider/provider.dart'; + +import '../../utils/global_variables.dart'; part 'expenses_details.g.dart'; @@ -185,7 +189,10 @@ class ExpensesDetailsModel { paidDateCtrl.text = ''; allowEdit = true; } - if(expenseType=='ELECTRICITY_BILL'){ + var expenseProvider = Provider.of( + navigatorKey.currentContext!, + listen: false); + if(expenseType=='ELECTRICITY_BILL' && expenseProvider.isPSPCLEnabled){ allowEdit = false; } } diff --git a/frontend/mgramseva/lib/providers/expenses_details_provider.dart b/frontend/mgramseva/lib/providers/expenses_details_provider.dart index 646ca3211..061d18bf4 100644 --- a/frontend/mgramseva/lib/providers/expenses_details_provider.dart +++ b/frontend/mgramseva/lib/providers/expenses_details_provider.dart @@ -44,6 +44,7 @@ class ExpensesDetailsProvider with ChangeNotifier { var phoneNumberAutoValidation = false; var dateAutoValidation = false; GlobalKey? filePickerKey; + var isPSPCLEnabled = false; dispose() { @@ -56,23 +57,34 @@ class ExpensesDetailsProvider with ChangeNotifier { try { if(expensesDetails != null || id != null) await fetchVendors(); else fetchVendors(); + var commonProvider = + Provider.of(context, listen: false); + if (languageList?.mdmsRes?.expense?.expenseList != null) { + var res = languageList?.mdmsRes?.pspclIntegration?.accountNumberGpMapping?.where((element) => element.departmentEntityCode==commonProvider.userDetails?.selectedtenant?.city?.code).toList(); + if(res!.isNotEmpty){ + isPSPCLEnabled = true; + notifyListeners(); + }else{ + isPSPCLEnabled = false; + notifyListeners(); + } + } if (expensesDetails != null) { expenditureDetails = expensesDetails; - if(expenditureDetails.expenseType=='ELECTRICITY_BILL'){ + if(expenditureDetails.expenseType=='ELECTRICITY_BILL' && isPSPCLEnabled){ expenditureDetails.allowEdit = false; } getStoreFileDetails(); } else if (id != null) { - var commonProvider = - Provider.of(context, listen: false); var query = { 'tenantId': commonProvider.userDetails?.selectedtenant?.code, 'challanNo': id }; var expenditure = await ExpensesRepository().searchExpense(query); + if (expenditure != null && expenditure.isNotEmpty) { expenditureDetails = expenditure.first; - if(expenditureDetails.expenseType=='ELECTRICITY_BILL'){ + if(expenditureDetails.expenseType=='ELECTRICITY_BILL' && isPSPCLEnabled){ expenditureDetails.allowEdit = false; } getStoreFileDetails(); @@ -535,7 +547,11 @@ class ExpensesDetailsProvider with ChangeNotifier { var res = languageList?.mdmsRes?.pspclIntegration?.accountNumberGpMapping?.where((element) => element.departmentEntityCode==commonProvider.userDetails?.selectedtenant?.city?.code).toList(); var temp_list = languageList?.mdmsRes?.expense?.expenseList?.toList(); if(res!.isNotEmpty){ + isPSPCLEnabled = true; + notifyListeners(); isSearch?{}:temp_list!.removeWhere((element) => element.code=="ELECTRICITY_BILL"); + }else{ + isPSPCLEnabled = false; } return (temp_list ?? []) .map((value) { diff --git a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart index e64935fd5..358c641b3 100644 --- a/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart +++ b/frontend/mgramseva/lib/screeens/add_expense/expense_details.dart @@ -141,9 +141,9 @@ class _ExpenseDetailsState extends State { (expensesDetailsProvider .expenditureDetails.isBillCancelled ?? false)) || - !isUpdate) || (expensesDetailsProvider - .expenditureDetails.expenseType!='ELECTRICITY_BILL') - ? () => expensesDetailsProvider.validateExpensesDetails( + !isUpdate) + ? expensesDetailsProvider.isPSPCLEnabled && expensesDetailsProvider + .expenditureDetails.expenseType=='ELECTRICITY_BILL'?null:() => expensesDetailsProvider.validateExpensesDetails( context, isUpdate) : null, key: Keys.expense.EXPENSE_SUBMIT, @@ -472,34 +472,35 @@ class _ExpenseDetailsState extends State { contextKey: expenseProvider .expenseWalkthrougList[5].key, ), - if (isUpdate && expenseDetails.expenseType!='ELECTRICITY_BILL') - Container( - alignment: Alignment.centerLeft, - padding: EdgeInsets.symmetric( - vertical: 10, horizontal: 18), - child: Wrap( - direction: Axis.horizontal, - crossAxisAlignment: WrapCrossAlignment.center, - spacing: 8, - children: [ - SizedBox( - width: 20, - height: 20, - child: Checkbox( - value: expenseDetails.isBillCancelled, - onChanged: expensesDetailsProvider - .onChangeOfCheckBox), - ), - Text( - ApplicationLocalizations.of(context) - .translate(i18.expense - .MARK_BILL_HAS_CANCELLED), - style: TextStyle( - fontSize: 19, - fontWeight: FontWeight.normal)) - ], + if (isUpdate) + expensesDetailsProvider.isPSPCLEnabled && expenseDetails.expenseType=='ELECTRICITY_BILL'?Container(): + Container( + alignment: Alignment.centerLeft, + padding: EdgeInsets.symmetric( + vertical: 10, horizontal: 18), + child: Wrap( + direction: Axis.horizontal, + crossAxisAlignment: WrapCrossAlignment.center, + spacing: 8, + children: [ + SizedBox( + width: 20, + height: 20, + child: Checkbox( + value: expenseDetails.isBillCancelled, + onChanged: expensesDetailsProvider + .onChangeOfCheckBox), + ), + Text( + ApplicationLocalizations.of(context) + .translate(i18.expense + .MARK_BILL_HAS_CANCELLED), + style: TextStyle( + fontSize: 19, + fontWeight: FontWeight.normal)) + ], + ), ), - ), SizedBox( height: 20, ), From 8619dcad37794815f4aa762a11a09eb67101d8ba Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:43:45 +0530 Subject: [PATCH 2/4] PFM-4136-version-upgrade --- frontend/mgramseva/package.json | 2 +- frontend/mgramseva/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/mgramseva/package.json b/frontend/mgramseva/package.json index 3145cdff1..a71e0eca9 100644 --- a/frontend/mgramseva/package.json +++ b/frontend/mgramseva/package.json @@ -1,5 +1,5 @@ { "name": "mgramseva", - "version": "1.2.10", + "version": "1.2.11", "license": "egov" } diff --git a/frontend/mgramseva/pubspec.yaml b/frontend/mgramseva/pubspec.yaml index f147b68d5..72c837f43 100644 --- a/frontend/mgramseva/pubspec.yaml +++ b/frontend/mgramseva/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.2.10+30 +version: 1.2.11+30 environment: sdk: ">=2.12.0 <3.0.0" From 60b79f0616265c89e48e931138ccaf12ccc5a48e Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Fri, 20 Oct 2023 11:45:40 +0530 Subject: [PATCH 3/4] PFM-4136-version-upgrade --- .../lib/model/expenses_details/expenses_details.dart | 6 ------ .../mgramseva/lib/providers/expenses_details_provider.dart | 3 +++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart b/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart index e7649daf6..68c6ae4d1 100644 --- a/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart +++ b/frontend/mgramseva/lib/model/expenses_details/expenses_details.dart @@ -189,12 +189,6 @@ class ExpensesDetailsModel { paidDateCtrl.text = ''; allowEdit = true; } - var expenseProvider = Provider.of( - navigatorKey.currentContext!, - listen: false); - if(expenseType=='ELECTRICITY_BILL' && expenseProvider.isPSPCLEnabled){ - allowEdit = false; - } } factory ExpensesDetailsModel.fromJson(Map json) => diff --git a/frontend/mgramseva/lib/providers/expenses_details_provider.dart b/frontend/mgramseva/lib/providers/expenses_details_provider.dart index 061d18bf4..ce3e16c74 100644 --- a/frontend/mgramseva/lib/providers/expenses_details_provider.dart +++ b/frontend/mgramseva/lib/providers/expenses_details_provider.dart @@ -95,6 +95,9 @@ class ExpensesDetailsProvider with ChangeNotifier { } this.expenditureDetails.getText(); + if(this.expenditureDetails.expenseType=='ELECTRICITY_BILL' && isPSPCLEnabled){ + this.expenditureDetails.allowEdit = false; + } streamController.add(this.expenditureDetails); } on CustomException catch (e, s) { ErrorHandler.handleApiException(context, e, s); From 46df5fe2a167052755c97fac34a87faf5b773473 Mon Sep 17 00:00:00 2001 From: Rahul Dev Garg <34365102+rahuldevgarg@users.noreply.github.com> Date: Fri, 20 Oct 2023 12:06:07 +0530 Subject: [PATCH 4/4] PFM-4136-version-upgrade --- .../providers/expenses_details_provider.dart | 4 --- .../lib/screeens/expense/search_expense.dart | 36 ++++++++++--------- frontend/mgramseva/package.json | 2 +- frontend/mgramseva/pubspec.yaml | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/frontend/mgramseva/lib/providers/expenses_details_provider.dart b/frontend/mgramseva/lib/providers/expenses_details_provider.dart index ce3e16c74..4443c3536 100644 --- a/frontend/mgramseva/lib/providers/expenses_details_provider.dart +++ b/frontend/mgramseva/lib/providers/expenses_details_provider.dart @@ -550,11 +550,7 @@ class ExpensesDetailsProvider with ChangeNotifier { var res = languageList?.mdmsRes?.pspclIntegration?.accountNumberGpMapping?.where((element) => element.departmentEntityCode==commonProvider.userDetails?.selectedtenant?.city?.code).toList(); var temp_list = languageList?.mdmsRes?.expense?.expenseList?.toList(); if(res!.isNotEmpty){ - isPSPCLEnabled = true; - notifyListeners(); isSearch?{}:temp_list!.removeWhere((element) => element.code=="ELECTRICITY_BILL"); - }else{ - isPSPCLEnabled = false; } return (temp_list ?? []) .map((value) { diff --git a/frontend/mgramseva/lib/screeens/expense/search_expense.dart b/frontend/mgramseva/lib/screeens/expense/search_expense.dart index 7b0d1acd3..f7cc46c0f 100644 --- a/frontend/mgramseva/lib/screeens/expense/search_expense.dart +++ b/frontend/mgramseva/lib/screeens/expense/search_expense.dart @@ -36,10 +36,12 @@ class _SearchExpenseState extends State { @override void initState() { - Provider.of(context, listen: false)..getExpenses(); + WidgetsBinding.instance.addPostFrameCallback((_) => afterViewBuild()); super.initState(); } - + afterViewBuild() { + Provider.of(context, listen: false)..getExpenses(); + } @override Widget build(BuildContext context) { return KeyboardFocusWatcher(child:Scaffold( @@ -73,20 +75,22 @@ class _SearchExpenseState extends State { '\n${ApplicationLocalizations.of(context).translate(i18.common.OR)}', textAlign: TextAlign.center), Consumer( - builder: (_, expensesDetailsProvider, child) => - SelectFieldBuilder( - i18.expense.EXPENSE_TYPE, - expenseType, - '', - '', - onChangeOfExpense, - expensesDetailsProvider.getExpenseTypeList(isSearch: true), - false, - hint: - '${ApplicationLocalizations.of(context).translate(i18.common.ELECTRICITY_HINT)}', - controller: expenseTypeCtrl, - key: Keys.expense.SEARCH_EXPENSE_TYPE, - ), + builder: (_, expensesDetailsProvider, child) { + return SelectFieldBuilder( + i18.expense.EXPENSE_TYPE, + expenseType, + '', + '', + onChangeOfExpense, + expensesDetailsProvider.getExpenseTypeList(isSearch: true)??[], + false, + hint: + '${ApplicationLocalizations.of(context).translate(i18.common.ELECTRICITY_HINT)}', + controller: expenseTypeCtrl, + key: Keys.expense.SEARCH_EXPENSE_TYPE, + ); + } + , ), Column( mainAxisAlignment: MainAxisAlignment.start, diff --git a/frontend/mgramseva/package.json b/frontend/mgramseva/package.json index a71e0eca9..19b5160b1 100644 --- a/frontend/mgramseva/package.json +++ b/frontend/mgramseva/package.json @@ -1,5 +1,5 @@ { "name": "mgramseva", - "version": "1.2.11", + "version": "1.2.12", "license": "egov" } diff --git a/frontend/mgramseva/pubspec.yaml b/frontend/mgramseva/pubspec.yaml index 72c837f43..f3a612aca 100644 --- a/frontend/mgramseva/pubspec.yaml +++ b/frontend/mgramseva/pubspec.yaml @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.2.11+30 +version: 1.2.12+30 environment: sdk: ">=2.12.0 <3.0.0"