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

Commit

Permalink
PFM-5473-frontend (#702)
Browse files Browse the repository at this point in the history
* PFM-5473 -frontend
  • Loading branch information
rahuldevgarg authored Feb 1, 2024
1 parent 52724dc commit 21b54d7
Showing 9 changed files with 348 additions and 2 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
@@ -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()
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
@@ -371,8 +371,7 @@ 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: [
26 changes: 26 additions & 0 deletions frontend/mgramseva/lib/providers/reports_provider.dart
Original file line number Diff line number Diff line change
@@ -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';
@@ -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;
@@ -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
@@ -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';
@@ -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/WaterConnectionCountWidget.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';
@@ -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(
Loading

0 comments on commit 21b54d7

Please sign in to comment.