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

Develop #624

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -185,9 +189,6 @@ class ExpensesDetailsModel {
paidDateCtrl.text = '';
allowEdit = true;
}
if(expenseType=='ELECTRICITY_BILL'){
allowEdit = false;
}
}

factory ExpensesDetailsModel.fromJson(Map<String, dynamic> json) =>
Expand Down
23 changes: 19 additions & 4 deletions frontend/mgramseva/lib/providers/expenses_details_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class ExpensesDetailsProvider with ChangeNotifier {
var phoneNumberAutoValidation = false;
var dateAutoValidation = false;
GlobalKey<FilePickerDemoState>? filePickerKey;
var isPSPCLEnabled = false;


dispose() {
Expand All @@ -56,23 +57,34 @@ class ExpensesDetailsProvider with ChangeNotifier {
try {
if(expensesDetails != null || id != null) await fetchVendors();
else fetchVendors();
var commonProvider =
Provider.of<CommonProvider>(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<CommonProvider>(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();
Expand All @@ -83,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);
Expand Down
61 changes: 31 additions & 30 deletions frontend/mgramseva/lib/screeens/add_expense/expense_details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ class _ExpenseDetailsState extends State<ExpenseDetails> {
(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,
Expand Down Expand Up @@ -472,34 +472,35 @@ class _ExpenseDetailsState extends State<ExpenseDetails> {
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,
),
Expand Down
36 changes: 20 additions & 16 deletions frontend/mgramseva/lib/screeens/expense/search_expense.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ class _SearchExpenseState extends State<SearchExpense> {

@override
void initState() {
Provider.of<ExpensesDetailsProvider>(context, listen: false)..getExpenses();
WidgetsBinding.instance.addPostFrameCallback((_) => afterViewBuild());
super.initState();
}

afterViewBuild() {
Provider.of<ExpensesDetailsProvider>(context, listen: false)..getExpenses();
}
@override
Widget build(BuildContext context) {
return KeyboardFocusWatcher(child:Scaffold(
Expand Down Expand Up @@ -73,20 +75,22 @@ class _SearchExpenseState extends State<SearchExpense> {
'\n${ApplicationLocalizations.of(context).translate(i18.common.OR)}',
textAlign: TextAlign.center),
Consumer<ExpensesDetailsProvider>(
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,
Expand Down
2 changes: 1 addition & 1 deletion frontend/mgramseva/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "mgramseva",
"version": "1.2.10",
"version": "1.2.12",
"license": "egov"
}
2 changes: 1 addition & 1 deletion frontend/mgramseva/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.12+30

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Loading