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

Commit

Permalink
Format
Browse files Browse the repository at this point in the history
  • Loading branch information
Hari-egov committed May 27, 2024
1 parent fd76ced commit d041413
Show file tree
Hide file tree
Showing 5 changed files with 253 additions and 209 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ class NewConsumerBillState extends State<NewConsumerBill> {
: '- ₹${double.parse(CommonProvider.getAdvanceAdjustedAmount(widget.demandList))}',
context),
// Net Due Amount

if (CommonProvider
.getPenaltyOrAdvanceStatus(
widget.waterConnection
Expand Down
21 changes: 10 additions & 11 deletions frontend/mgramseva/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,13 @@ void main() {

WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: 'assets/.env');
if(kIsWeb){
await Firebase.initializeApp(options: FirebaseConfigurations.firebaseOptions);
}else{
if (kIsWeb) {
await Firebase.initializeApp(
options: FirebaseConfigurations.firebaseOptions);
} else {
await Firebase.initializeApp();
}
if (Firebase.apps.length == 0) {

}
if (Firebase.apps.length == 0) {}

if (!kIsWeb) {
await FlutterDownloader.initialize(
Expand Down Expand Up @@ -136,9 +135,9 @@ class _MyAppState extends State<MyApp> {
IsolateNameServer.removePortNameMapping('downloader_send_port');
super.dispose();
}

@pragma('vm:entry-point')
static void downloadCallback(
String id, int status, int progress) {
static void downloadCallback(String id, int status, int progress) {
final SendPort send =
IsolateNameServer.lookupPortByName('downloader_send_port')!;

Expand All @@ -156,7 +155,8 @@ class _MyAppState extends State<MyApp> {
// print("Download progress: "+progress.toString());
if (status == DownloadTaskStatus.complete) {
if (CommonProvider.downloadUrl.containsKey(id)) {
if (CommonProvider.downloadUrl[id] != null) OpenFilex.open(CommonProvider.downloadUrl[id] ?? '');
if (CommonProvider.downloadUrl[id] != null)
OpenFilex.open(CommonProvider.downloadUrl[id] ?? '');
CommonProvider.downloadUrl.remove(id);
} else if (status == DownloadTaskStatus.failed ||
status == DownloadTaskStatus.canceled ||
Expand Down Expand Up @@ -286,8 +286,7 @@ class _LandingPageState extends State<LandingPage> {
commonProvider.getLoginCredentials();
await commonProvider.getAppVersionDetails();
if (!kIsWeb)
CommonMethods()
.checkVersion(context, commonProvider.appVersion!);
CommonMethods().checkVersion(context, commonProvider.appVersion!);
}

@override
Expand Down
103 changes: 60 additions & 43 deletions frontend/mgramseva/lib/providers/consumer_details_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,12 @@ class ConsumerProvider with ChangeNotifier {
isEdit = true;
waterconnection = data;
waterconnection.getText();
selectedcycle = {'code':DateTime.fromMillisecondsSinceEpoch(waterconnection.previousReadingDate!),
'name':"${ApplicationLocalizations.of(navigatorKey.currentContext!)
.translate(DateFormats.timeStampToDate(
waterconnection.previousReadingDate,
format: 'MMMM')) +
" - " +
DateFormats.timeStampToDate(
waterconnection.previousReadingDate,
format: 'yyyy')}"};
selectedcycle = {
'code': DateTime.fromMillisecondsSinceEpoch(
waterconnection.previousReadingDate!),
'name':
"${ApplicationLocalizations.of(navigatorKey.currentContext!).translate(DateFormats.timeStampToDate(waterconnection.previousReadingDate, format: 'MMMM')) + " - " + DateFormats.timeStampToDate(waterconnection.previousReadingDate, format: 'yyyy')}"
};
if (waterconnection.previousReadingDate != null &&
(languageList?.mdmsRes?.billingService?.taxPeriodList?.isNotEmpty ??
false)) {
Expand Down Expand Up @@ -479,12 +476,14 @@ class ConsumerProvider with ChangeNotifier {
"tenantId": commonProvider.userDetails!.selectedtenant!.code
});
boundaryList = [];
result['TenantBoundary']!=null && result['TenantBoundary'].length>0?boundaryList.addAll(
TenantBoundary.fromJson(result['TenantBoundary'][0]).boundary!):{};
result['TenantBoundary'] != null && result['TenantBoundary'].length > 0
? boundaryList.addAll(
TenantBoundary.fromJson(result['TenantBoundary'][0]).boundary!)
: {};
if (boundaryList.length == 1) {
property.address.localityCtrl = boundaryList.first;
onChangeOfLocality(property.address.localityCtrl);
}else{
} else {
boundaryList.add(Boundary.fromJson({
"code": "WARD1",
"name": commonProvider.userDetails!.selectedtenant!.name,
Expand Down Expand Up @@ -557,8 +556,8 @@ class ConsumerProvider with ChangeNotifier {
return (languageList?.mdmsRes?.category?.categoryList ?? <CategoryType>[])
.map((value) {
return value.code!;
}).toList();
}
}).toList();
}
return <String>[];
}

Expand Down Expand Up @@ -602,7 +601,8 @@ class ConsumerProvider with ChangeNotifier {
DateTime result = DateTime.parse(val['code'].toString());
waterconnection.previousReadingDateCtrl.clear();
waterconnection.BillingCycleCtrl.text = result.toLocal().toString();
waterconnection.meterInstallationDateCtrl.text = result.toLocal().toString();
waterconnection.meterInstallationDateCtrl.text =
result.toLocal().toString();
notifyListeners();
}

Expand All @@ -619,8 +619,8 @@ class ConsumerProvider with ChangeNotifier {
}

//Displaying Billing Cycle Vaule (EX- JAN-2021,,)
List<Map<String,dynamic>> getBillingCycle() {
var dates = <Map<String,dynamic>>[];
List<Map<String, dynamic>> getBillingCycle() {
var dates = <Map<String, dynamic>>[];
if (billYear != null) {
DatePeriod ytd;
var fromDate = DateFormats.getFormattedDateToDateTime(
Expand All @@ -629,60 +629,64 @@ class ConsumerProvider with ChangeNotifier {
var toDate = DateFormats.getFormattedDateToDateTime(
DateFormats.timeStampToDate(billYear?.toDate)) as DateTime;

ytd = DatePeriod(fromDate,toDate,DateType.YTD);
ytd = DatePeriod(fromDate, toDate, DateType.YTD);

/// Get months based on selected billing year
var months = CommonMethods.getPastMonthUntilFinancialYTD(ytd);

/// if selected year is future year means all the months will be removed
if(fromDate.year > ytd.endDate.year) months.clear();
if (fromDate.year > ytd.endDate.year) months.clear();

for (var i = 0; i < months.length; i++) {
var prevMonth = months[i].startDate;
var r = {"code": prevMonth, "name": '${ApplicationLocalizations.of(navigatorKey.currentContext!)
.translate((Constants.MONTHS[prevMonth.month - 1])) +
" - " +
prevMonth.year.toString()}'};
var r = {
"code": prevMonth,
"name":
'${ApplicationLocalizations.of(navigatorKey.currentContext!).translate((Constants.MONTHS[prevMonth.month - 1])) + " - " + prevMonth.year.toString()}'
};
dates.add(r);
}
}
if (dates.length > 0 && waterconnection.connectionType == 'Non_Metered') {
return dates;
}
return <Map<String,dynamic>>[];
return <Map<String, dynamic>>[];
}

//Displaying Billing Cycle Vaule (EX- JAN-2021,,)
List<Map<String,dynamic>> getBillingCycleMonthCountCurrent(TaxPeriod? billYear) {
var dates = <Map<String,dynamic>>[];
if (billYear!=null) {
List<Map<String, dynamic>> getBillingCycleMonthCountCurrent(
TaxPeriod? billYear) {
var dates = <Map<String, dynamic>>[];
if (billYear != null) {
DatePeriod ytd;
var fromDate = DateFormats.getFormattedDateToDateTime(
DateFormats.timeStampToDate(billYear?.fromDate)) as DateTime;

var toDate = DateFormats.getFormattedDateToDateTime(
DateFormats.timeStampToDate(billYear?.toDate)) as DateTime;

ytd = DatePeriod(fromDate,toDate,DateType.YTD);
ytd = DatePeriod(fromDate, toDate, DateType.YTD);

/// Get months based on selected billing year
var months = CommonMethods.getPastMonthUntilFinancialYTD(ytd);

/// if selected year is future year means all the months will be removed
if(fromDate.year > ytd.endDate.year) months.clear();
if (fromDate.year > ytd.endDate.year) months.clear();

for (var i = 0; i < months.length; i++) {
var prevMonth = months[i].startDate;
var r = {"code": prevMonth, "name": '${ApplicationLocalizations.of(navigatorKey.currentContext!)
.translate((Constants.MONTHS[prevMonth.month - 1])) +
" - " +
prevMonth.year.toString()}'};
var r = {
"code": prevMonth,
"name":
'${ApplicationLocalizations.of(navigatorKey.currentContext!).translate((Constants.MONTHS[prevMonth.month - 1])) + " - " + prevMonth.year.toString()}'
};
dates.add(r);
}
}
if (dates.length > 0 && waterconnection.connectionType == 'Non_Metered') {
return dates;
}
return <Map<String,dynamic>>[];
return <Map<String, dynamic>>[];
}

incrementIndex(index, consumerGenderKey) async {
Expand Down Expand Up @@ -716,28 +720,41 @@ class ConsumerProvider with ChangeNotifier {

List<TaxPeriod> getFinancialYearList() {
if (languageList?.mdmsRes?.billingService?.taxPeriodList != null) {
CommonMethods.getFilteredFinancialYearList(languageList?.mdmsRes?.billingService?.taxPeriodList ?? <TaxPeriod>[]);
languageList?.mdmsRes?.billingService?.taxPeriodList!.sort((a,b)=>a.fromDate!.compareTo(b.fromDate!));
CommonMethods.getFilteredFinancialYearList(
languageList?.mdmsRes?.billingService?.taxPeriodList ??
<TaxPeriod>[]);
languageList?.mdmsRes?.billingService?.taxPeriodList!
.sort((a, b) => a.fromDate!.compareTo(b.fromDate!));
return (languageList?.mdmsRes?.billingService?.taxPeriodList ??
<TaxPeriod>[])
<TaxPeriod>[])
.map((value) {
return value;
}).toList().reversed.toList();
return value;
})
.toList()
.reversed
.toList();
}
return <TaxPeriod>[];
}

List<TaxPeriod> getLastFinancialYearList(int count) {
return getFinancialYearList().length>count?getFinancialYearList().sublist(0,count):getFinancialYearList();
return getFinancialYearList().length > count
? getFinancialYearList().sublist(0, count)
: getFinancialYearList();
}
List<Map<String,dynamic>> newBillingCycleFunction({int pastMonthCount = 2}){

List<Map<String, dynamic>> newBillingCycleFunction({int pastMonthCount = 2}) {
List<TaxPeriod> financialYears = getFinancialYearList();
var dates = <Map<String,dynamic>>[];
var dates = <Map<String, dynamic>>[];
financialYears.forEach((year) {
dates.addAll(getBillingCycleMonthCountCurrent(year));
});
dates.sort((a, b) => b['code'].compareTo(a['code']));
return dates.toList().length>2?dates.toList().sublist(0,2):dates.toList();
return dates.toList().length > 2
? dates.toList().sublist(0, 2)
: dates.toList();
}

void onChangeOfAmountType(value) {
waterconnection.paymentType = value;

Expand Down
Loading

0 comments on commit d041413

Please sign in to comment.