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

Develop #709

Merged
merged 35 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0bd460f
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 22, 2024
cf445f3
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 22, 2024
bc924cc
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
abeee24
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
5f6e5a5
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
7703534
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
b894fdf
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
db8d7f1
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
958ee0e
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
8a94c85
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
e7a2c57
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
b28933e
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
300cff7
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
2e8d9df
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
c00aa32
PFM-5473: Added changes to get the count of tenantby last demand genn…
Jan 23, 2024
691055e
PFM-5473 Query fix
rahuldevgarg Jan 31, 2024
e63b0a0
PFM-5473 Query fix
rahuldevgarg Jan 31, 2024
41e6060
PFM-5473 Query fix
rahuldevgarg Jan 31, 2024
07f241a
PFM-5473 query change
rahuldevgarg Jan 31, 2024
aa40b81
PFM-5473 contract change
rahuldevgarg Jan 31, 2024
351a687
PFM-5473 query fix
rahuldevgarg Jan 31, 2024
6aa02f5
WATER_CONNNECTION_BY_DEMANNDDATE
rahuldevgarg Jan 31, 2024
0066884
query fix
rahuldevgarg Jan 31, 2024
169a044
query fix
rahuldevgarg Jan 31, 2024
861c2e9
query fix
rahuldevgarg Jan 31, 2024
918d7a0
Merge pull request #701 from egovernments/PFM-5473
pradeepkumarcm-egov Jan 31, 2024
7dc9449
Update WsQueryBuilder.java
debasishchakraborty-egovt Feb 1, 2024
52724dc
Merge pull request #708 from egovernments/debasishchakraborty-egovt-p…
pradeepkumarcm-egov Feb 1, 2024
21b54d7
PFM-5473-frontend (#702)
rahuldevgarg Feb 1, 2024
2260d60
PFM-5473 -frontend
rahuldevgarg Feb 1, 2024
0e72485
fixed date month localization
rahuldevgarg Feb 1, 2024
90a9f88
implemented the collapsable table
rahuldevgarg Feb 1, 2024
d57dfac
implemented the collapsable table
rahuldevgarg Feb 1, 2024
3b5809b
implemented the collapsable table
rahuldevgarg Feb 1, 2024
98b6b8b
implemented the collapsable table
rahuldevgarg Feb 1, 2024
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
60 changes: 60 additions & 0 deletions frontend/mgramseva/lib/model/connection/water_connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,66 @@ class WaterConnection {
factory WaterConnection.fromJson(Map<String, dynamic> json) =>
_$WaterConnectionFromJson(json);
Map<String, dynamic> toJson() => _$WaterConnectionToJson(this);
@override
bool operator ==(Object other) {
if (identical(this, other)) return true;

return other is WaterConnection &&
other.id == id &&
other.connectionNo == connectionNo &&
other.propertyId == propertyId &&
other.applicationNo == applicationNo &&
other.tenantId == tenantId &&
other.action == action &&
other.status == status &&
other.meterInstallationDate == meterInstallationDate &&
other.documents == documents &&
other.proposedTaps == proposedTaps &&
other.noOfTaps == noOfTaps &&
other.arrears == arrears &&
other.connectionType == connectionType &&
other.oldConnectionNo == oldConnectionNo &&
other.meterId == meterId &&
other.propertyType == propertyType &&
other.previousReadingDate == previousReadingDate &&
other.previousReading == previousReading &&
other.proposedPipeSize == proposedPipeSize &&
other.connectionHolders == connectionHolders &&
other.additionalDetails == additionalDetails &&
other.processInstance == processInstance &&
other.paymentType == paymentType &&
other.penalty == penalty &&
other.advance == advance;
}

@override
int get hashCode {
return id.hashCode ^
connectionNo.hashCode ^
propertyId.hashCode ^
applicationNo.hashCode ^
tenantId.hashCode ^
action.hashCode ^
status.hashCode ^
meterInstallationDate.hashCode ^
documents.hashCode ^
proposedTaps.hashCode ^
noOfTaps.hashCode ^
arrears.hashCode ^
connectionType.hashCode ^
oldConnectionNo.hashCode ^
meterId.hashCode ^
propertyType.hashCode ^
previousReadingDate.hashCode ^
previousReading.hashCode ^
proposedPipeSize.hashCode ^
connectionHolders.hashCode ^
additionalDetails.hashCode ^
processInstance.hashCode ^
paymentType.hashCode ^
penalty.hashCode ^
advance.hashCode;
}
}

@JsonSerializable()
Expand Down
59 changes: 59 additions & 0 deletions frontend/mgramseva/lib/model/reports/WaterConnectionCount.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
class WaterConnectionCount {
int? count;
int? taxperiodto;

WaterConnectionCount({this.count, this.taxperiodto});

WaterConnectionCount.fromJson(Map<String, dynamic> json) {
count = json['count']??0;
taxperiodto = json['taxperiodto']??0;
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['count'] = this.count;
data['taxperiodto'] = this.taxperiodto;
return data;
}
}
class WaterConnectionCountResponse {
List<WaterConnectionCount>? waterConnectionsDemandGenerated;
List<WaterConnectionCount>? waterConnectionsDemandNotGenerated;

WaterConnectionCountResponse(
{this.waterConnectionsDemandGenerated,
this.waterConnectionsDemandNotGenerated});

WaterConnectionCountResponse.fromJson(Map<String, dynamic> json) {
if (json['WaterConnectionsDemandGenerated'] != null) {
waterConnectionsDemandGenerated = <WaterConnectionCount>[];
json['WaterConnectionsDemandGenerated'].forEach((v) {
waterConnectionsDemandGenerated!
.add(new WaterConnectionCount.fromJson(v));
});
}
if (json['WaterConnectionsDemandNotGenerated'] != null) {
waterConnectionsDemandNotGenerated =
<WaterConnectionCount>[];
json['WaterConnectionsDemandNotGenerated'].forEach((v) {
waterConnectionsDemandNotGenerated!
.add(new WaterConnectionCount.fromJson(v));
});
}
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
if (this.waterConnectionsDemandGenerated != null) {
data['WaterConnectionsDemandGenerated'] =
this.waterConnectionsDemandGenerated!.map((v) => v.toJson()).toList();
}
if (this.waterConnectionsDemandNotGenerated != null) {
data['WaterConnectionsDemandNotGenerated'] = this
.waterConnectionsDemandNotGenerated!
.map((v) => v.toJson())
.toList();
}
return data;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -371,11 +371,11 @@ class BillGenerationProvider with ChangeNotifier {
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,
FittedBox(
child: DataTable(
border: TableBorder.all(
width: 0.5, borderRadius: BorderRadius.all(Radius.circular(5))), columns: [
width: 0.5, borderRadius: BorderRadius.all(Radius.circular(5)),
color: Colors.grey,), columns: [
DataColumn(
label: Text(
"${ApplicationLocalizations.of(context).translate(i18.searchWaterConnection.CONNECTION_TYPE)}",
Expand Down
26 changes: 26 additions & 0 deletions frontend/mgramseva/lib/providers/reports_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:syncfusion_flutter_xlsio/xlsio.dart';
import '../model/common/BillsTableData.dart';
import '../model/localization/language.dart';
import '../model/mdms/tax_period.dart';
import '../model/reports/WaterConnectionCount.dart';
import '../model/reports/bill_report_data.dart';
import '../model/reports/collection_report_data.dart';
import '../model/reports/expense_bill_report_data.dart';
Expand Down Expand Up @@ -40,6 +41,7 @@ class ReportsProvider with ChangeNotifier {
List<InactiveConsumerReportData>? inactiveconsumers;
List<ExpenseBillReportData>? expenseBillReportData;
List<VendorReportData>? vendorReportData;
WaterConnectionCountResponse? waterConnectionCount;
BillsTableData genericTableData = BillsTableData([], []);
int limit = 10;
int offset = 1;
Expand Down Expand Up @@ -805,4 +807,28 @@ class ReportsProvider with ChangeNotifier {
//Save and launch the file.
await saveAndLaunchFile(bytes, '$title.xlsx');
}
Future<void> getWaterConnectionsCount() async {
try {
var commonProvider = Provider.of<CommonProvider>(
navigatorKey.currentContext!,
listen: false);
Map<String, dynamic> params = {
'tenantId': commonProvider.userDetails!.selectedtenant!.code,
};
var response = await ReportsRepo().fetchWaterConnectionsCount(params);
if (response != null) {
waterConnectionCount = response;
streamController.add(response);
callNotifier();
} else {
streamController.add('error');
throw Exception('API Error');
}
callNotifier();
} catch (e, s) {
ErrorHandler().allExceptionsHandler(navigatorKey.currentContext!, e, s);
streamController.addError('error');
callNotifier();
}
}
}
33 changes: 33 additions & 0 deletions frontend/mgramseva/lib/repository/reports_repo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:mgramseva/services/base_service.dart';
import 'package:provider/provider.dart';

import '../model/reports/InactiveConsumerReportData.dart';
import '../model/reports/WaterConnectionCount.dart';
import '../model/reports/bill_report_data.dart';
import '../model/reports/collection_report_data.dart';
import '../providers/common_provider.dart';
Expand Down Expand Up @@ -194,4 +195,36 @@ class ReportsRepo extends BaseService{
}
return vendorReports;
}
Future<WaterConnectionCountResponse?> fetchWaterConnectionsCount(Map<String,dynamic> params,
[String? token]) async {
var commonProvider = Provider.of<CommonProvider>(
navigatorKey.currentContext!,
listen: false);
WaterConnectionCountResponse? waterConnectionResponse = WaterConnectionCountResponse();
final requestInfo = RequestInfo(
APIConstants.API_MODULE_NAME,
APIConstants.API_VERSION,
APIConstants.API_TS,
'_get',
APIConstants.API_DID,
APIConstants.API_KEY,
APIConstants.API_MESSAGE_ID,
commonProvider.userDetails?.accessToken,
commonProvider.userDetails?.userRequest?.toJson());
var res = await makeRequest(
url: Url.WATER_CONNECTION_COUNT,
queryParameters: params,
requestInfo: requestInfo,
body: {},
method: RequestType.POST);
if (res != null ){
try {
waterConnectionResponse = WaterConnectionCountResponse.fromJson(res);
} catch (e) {
print(e);
waterConnectionResponse = null;
}
}
return waterConnectionResponse;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import 'package:flutter/material.dart';
import 'package:mgramseva/providers/reports_provider.dart';
import 'package:mgramseva/screeens/generate_bill/widgets/water_connection_count_widget.dart';
import 'package:mgramseva/widgets/keyboard_focus_watcher.dart';
import 'package:mgramseva/model/bill/bill_generation_details/bill_generation_details.dart';
import 'package:mgramseva/model/connection/water_connection.dart';
Expand Down Expand Up @@ -78,6 +80,7 @@ class _GenerateBillState extends State<GenerateBill> {
Provider.of<BillGenerationProvider>(context, listen: false).clearBillYear();
Navigator.pop(context);
},),
WaterConnectionCountWidget(),
Container(
width: MediaQuery.of(context).size.width,
child: Card(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import 'package:flutter/material.dart';
import 'package:mgramseva/model/reports/WaterConnectionCount.dart';
import 'package:mgramseva/utils/constants/i18_key_constants.dart';
import '../../../utils/date_formats.dart';
import '../../../utils/localization/application_localizations.dart';

class CountTableWidget extends StatefulWidget {
final List<WaterConnectionCount>? waterConnectionCount;

const CountTableWidget({Key? key, this.waterConnectionCount})
: super(key: key);

@override
_CountTableWidgetState createState() => _CountTableWidgetState();
}

class _CountTableWidgetState extends State<CountTableWidget> {
bool _isCollapsed = true;

@override
Widget build(BuildContext context) {
final List<WaterConnectionCount>? connectionCount =
widget.waterConnectionCount;

return Container(
child: Column(
children: [
LayoutBuilder(
builder: (context, constraints) {
if (constraints.maxWidth <= 760) {
return Container(
width: MediaQuery.of(context).size.width,
child: FittedBox(
child: _buildDataTable(connectionCount!),
),
);
} else {
return Container(
width: MediaQuery.of(context).size.width,
child: _buildDataTable(connectionCount!));
}
},
),
if (connectionCount!.length > 5)
Align(
alignment: Alignment.bottomRight,
child: TextButton(
onPressed: () {
setState(() {
_isCollapsed = !_isCollapsed;
});
},
child: Text(_isCollapsed
? "${ApplicationLocalizations.of(context).translate(i18.common.VIEW_ALL)}"
: "${ApplicationLocalizations.of(context).translate(i18.common.COLLAPSE)}"),
),
),
],
),
);
}

Widget _buildDataTable(List<WaterConnectionCount> connectionCount) {
return DataTable(
border: TableBorder.all(
width: 0.5,
borderRadius: BorderRadius.all(Radius.circular(5)),
color: Colors.grey, // Set border color to grey
),// Set heading row background color to grey
headingTextStyle: TextStyle(color: Colors.black, fontWeight: FontWeight.bold), // Set heading text color to black and bold
columns: [
DataColumn(
label: FittedBox(
child: Text(
"${ApplicationLocalizations.of(context).translate(i18.common.LAST_BILL_CYCLE_MONTH)}",
),
),
),
DataColumn(
label: FittedBox(
child: Text(
"${ApplicationLocalizations.of(context).translate(i18.common.CONSUMER_COUNT)}",
),
),
)
],
rows: _isCollapsed
? connectionCount.take(5).map((e) => _buildDataRow(e)).toList()
: connectionCount.map((e) => _buildDataRow(e)).toList(),
);
}

DataRow _buildDataRow(WaterConnectionCount count) {
final bool isEvenRow = widget.waterConnectionCount!.indexOf(count) % 2 == 0;
final Color? rowColor = isEvenRow ? Colors.grey[100] : Colors.white; // Set alternate row background color to grey

return DataRow(
color: MaterialStateColor.resolveWith((states) => rowColor!), // Apply alternate row background color
cells: [
DataCell(
Text(
DateFormats.getMonthAndYearFromDateTime(
DateTime.fromMillisecondsSinceEpoch(count.taxperiodto!),
),
),
),
DataCell(
Text(count.count.toString()),
),
],
);
}
}
Loading
Loading