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

Commit

Permalink
Merge pull request #709 from egovernments/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
pradeepkumarcm-egov authored Feb 2, 2024
2 parents 098e1c0 + 98b6b8b commit 2a59429
Show file tree
Hide file tree
Showing 20 changed files with 595 additions and 11 deletions.
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

0 comments on commit 2a59429

Please sign in to comment.