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

Develop #723

Merged
merged 62 commits into from
Mar 13, 2024
Merged

Develop #723

merged 62 commits into from
Mar 13, 2024

Conversation

gargrahuldev
Copy link
Contributor

@gargrahuldev gargrahuldev commented Feb 8, 2024

Summary by CodeRabbit

  • New Features
    • Added new methods for calculating billing cycle months and handling boundary lists in consumer details.
    • Introduced a method to calculate the total bill amount and send SMS notifications accordingly.
    • Added leap year calculation and month subtraction utilities.
  • Enhancements
    • Updated the handling of longitude and latitude data types to be dynamic.
    • Modified the logic for assigning locality based on the boundary list size.
    • Updated URL constants for improved service integration.
    • Enhanced logic for determining building type based on property information.
  • Configuration
    • Added a new Kafka consumer configuration property to manage polling intervals.

Copy link

coderabbitai bot commented Mar 5, 2024

Walkthrough

The recent updates encompass a series of changes across various components of a municipal services application. These modifications include adjustments to data types, logic enhancements, and service improvements. From refining data handling in consumer details to updating billing and expenses logic, alongside adjustments in property and water service calculations, the changes aim to enhance system functionality and performance.

Changes

Files Summary of Changes
.../lib/model/mdms/tenants.dart, .../lib/model/mdms/tenants.g.dart Changed longitude and latitude data types to dynamic; removed conversion to double.
.../lib/providers/consumer_details_provider.dart Updated boundaryList handling; added methods for billing cycle calculation.
.../lib/providers/expenses_details_provider.dart Modified logic for assigning code variable.
.../lib/screeens/consumer_details/consumer_details.dart Adjusted method parameters for improved data handling.
.../lib/services/urls.dart Updated URL constant for MDMS.
.../lib/utils/common_methods.dart Added leap year and days calculation methods.
.../service/BoundaryService.java, .../service/EnrichmentService.java Adjusted logic flow by commenting out a method call.
.../wscalculation/service/DemandService.java Introduced new parameters and methods for bill calculations.
.../wscalculation/service/EstimationService.java Updated logic for determining buildingType.
.../resources/application.properties Added configuration property for Kafka consumer.

🐰✨

Changes here, changes there,
Code hopping everywhere.
From the length of days to the type of building,
Our updates are surely thrilling.
With every line and every byte,
We leap towards a future bright.
🌟🐾

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 10

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 88bcf48 and a893b59.
Files ignored due to path filters (5)
  • frontend/mgramseva/package.json is excluded by: !**/*.json
  • frontend/mgramseva/pubspec.yaml is excluded by: !**/*.yaml
  • municipal-services/vendor/src/main/java/org/egov/vendor/service/BoundaryService.java is excluded by: !**/vendor/**
  • municipal-services/vendor/src/main/java/org/egov/vendor/service/EnrichmentService.java is excluded by: !**/vendor/**
  • municipal-services/vendor/src/main/java/org/egov/vendor/validator/VendorValidator.java is excluded by: !**/vendor/**
Files selected for processing (12)
  • frontend/mgramseva/lib/model/mdms/tenants.dart (1 hunks)
  • frontend/mgramseva/lib/model/mdms/tenants.g.dart (1 hunks)
  • frontend/mgramseva/lib/providers/consumer_details_provider.dart (2 hunks)
  • frontend/mgramseva/lib/providers/expenses_details_provider.dart (1 hunks)
  • frontend/mgramseva/lib/screeens/consumer_details/consumer_details.dart (2 hunks)
  • frontend/mgramseva/lib/services/urls.dart (1 hunks)
  • frontend/mgramseva/lib/utils/common_methods.dart (2 hunks)
  • municipal-services/property-services/src/main/java/org/egov/pt/service/BoundaryService.java (1 hunks)
  • municipal-services/property-services/src/main/java/org/egov/pt/service/EnrichmentService.java (1 hunks)
  • municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java (3 hunks)
  • municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java (1 hunks)
  • municipal-services/ws-calculator/src/main/resources/application.properties (1 hunks)
Additional comments: 10
frontend/mgramseva/lib/model/mdms/tenants.g.dart (1)
  • 88-89: The removal of explicit type conversion for longitude and latitude during JSON deserialization aligns with the updated dynamic data types in the City class. This change is necessary for consistency and to prevent deserialization errors.
municipal-services/property-services/src/main/java/org/egov/pt/service/BoundaryService.java (1)
  • 53-53: The added comment provides useful context about the previous usage of the getAreaType method. It's important to verify the impact of this change on the application's logic and ensure that the intended functionality is maintained.
frontend/mgramseva/lib/services/urls.dart (1)
  • 6-6: The update to the MDMS URL constant reflects a change to the service endpoint. Ensure that all references to the MDMS service within the application are updated to use this new endpoint.
municipal-services/ws-calculator/src/main/resources/application.properties (1)
  • 25-25: The addition of the max.poll.interval.ms configuration property with a value of 600000 is a good practice to improve Kafka consumer reliability, especially for long-running processes. Ensure that this value aligns with the expected processing times in your application.
municipal-services/property-services/src/main/java/org/egov/pt/service/EnrichmentService.java (1)
  • 202-202: The line calling boundaryService.getAreaType has been commented out in the enrichBoundary method. It's crucial to verify the impact of this change on property boundary enrichment and ensure that the intended functionality is preserved.
Verification successful

The search results indicate that the enrichBoundary method is still actively used in the application, suggesting that the functionality for property boundary enrichment is maintained, albeit potentially in a modified form. Given this context, it appears that the impact of commenting out the boundaryService.getAreaType call has been mitigated or addressed through other means within the application. Therefore, the original concern about preserving intended functionality seems to be addressed by the continued use and potential modification of the enrichBoundary method.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for alternative implementations or references to boundary enrichment to ensure functionality is maintained.
rg --type java 'enrichBoundary'

Length of output: 822

frontend/mgramseva/lib/utils/common_methods.dart (2)
  • 88-101: The isLeapYear method correctly implements the leap year calculation following standard rules. Good job on structuring the logic clearly.
  • 103-116: The daysToSubtract method correctly calculates the total days to subtract based on the given parameters. However, please verify the index calculation when accessing daysInMonthLeap and daysInMonth arrays to ensure there are no off-by-one errors.
municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/EstimationService.java (1)
  • 277-279: The logic for determining the buildingType has been updated to use PropertyType instead of UsageCategory. This change aims to improve the accuracy of categorization based on property information. However, ensure that all downstream logic that relies on buildingType is compatible with this change and that PropertyType values are consistently used across the application to prevent any inconsistencies.
frontend/mgramseva/lib/screeens/consumer_details/consumer_details.dart (1)
  • 512-519: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [515-536]

The modifications to the itemAsString and controller parameters in the SelectFieldBuilder calls are noteworthy. Ensure that these changes accurately reflect the desired display and management of items within the select fields. Specifically, the use of ApplicationLocalizations.of(context).translate in itemAsString is a good practice for supporting localization. However, verify that all possible values passed to translate are accounted for in your localization files to prevent runtime errors or missing translations.

municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java (1)
  • 305-308: The addition of the totalAmount check before sending SMS notifications is a good practice to ensure that notifications are only sent when there is a non-zero amount to be notified about. However, it's important to ensure that totalAmount is accurately calculated and includes all relevant charges to avoid scenarios where a notification might be mistakenly not sent due to an incorrect calculation of totalAmount.

Comment on lines 367 to 387
}
String messageString = localizationMessage.get(WSCalculationConstant.MSG_KEY);

System.out.println("Localization message get bill::" + messageString);
System.out.println("isForConnectionNO:" + isForConnectionNO);
//System.out.println("Localization message get bill::" + messageString);
//System.out.println("isForConnectionNO:" + isForConnectionNO);
if (!StringUtils.isEmpty(messageString) && isForConnectionNO) {
log.info("Demand Object get bill" + demands.toString());
log.info("requestInfo get Bill" + requestInfo);
log.info("bill number get bill size :" + billNumbers.size());
if (billNumbers.size() > 0) {
if (totalamount!=null && billNumbers.size() > 0 && totalamount.signum()>0) {
actionLink = actionLink.replace("$billNumber", billNumbers.get(0));
messageString = messageString.replace("{ownername}", owner.getName());
messageString = messageString.replace("{Period}", billCycle);
messageString = messageString.replace("{consumerno}", consumerCode);
messageString = messageString.replace("{billamount}", demandDetails.stream()
.map(DemandDetail::getTaxAmount).reduce(BigDecimal.ZERO, BigDecimal::add).toString());
messageString = messageString.replace("{billamount}", totalamount.toString());
messageString = messageString.replace("{BILL_LINK}", getShortenedUrl(actionLink));

System.out.println("Demand genaration Message get bill::" + messageString);
// System.out.println("Demand genaration Message get bill::" + messageString);

SMSRequest sms = SMSRequest.builder().mobileNumber(owner.getMobileNumber()).message(messageString).tenantid(tenantId)
.category(Category.TRANSACTION).build();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [354-384]

The method sendDownloadBillSMSNotification has been updated to include a new parameter totalamount, which is used to conditionally send SMS notifications based on the bill amount. This is a logical improvement for user experience, ensuring that notifications are meaningful. However, ensure that:

  1. The totalamount parameter is accurately calculated and represents the total bill amount correctly.
  2. The method's documentation is updated to reflect the new parameter and its usage.
  3. Any upstream method calls to sendDownloadBillSMSNotification are updated to pass the totalamount parameter.

Additionally, consider handling potential exceptions or errors that might occur during the SMS sending process to ensure the application's robustness.

// Suggestion to handle potential exceptions in SMS sending logic
try {
    // Existing logic to send SMS
} catch (Exception e) {
    log.error("Error sending SMS notification", e);
    // Handle exception appropriately
}

Comment on lines 652 to 684
//Displaying Billing Cycle Vaule (EX- JAN-2021,,)
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);

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

/// if selected year is future year means all the months will be removed
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()}'};
dates.add(r);
}
}
if (dates.length > 0 && waterconnection.connectionType == 'Non_Metered') {
return dates;
}
return <Map<String,dynamic>>[];
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The addition of getBillingCycleMonthCountCurrent method is a good approach to encapsulate the logic for calculating billing cycle months. However, consider the following points for improvement:

  • Code Clarity: The method involves complex date manipulations and conditions. Adding comments to explain the logic, especially around the calculation of months and the condition for clearing months, would improve readability and maintainability.
  • Error Handling: There's no explicit error handling for potential issues with date parsing or invalid billYear values. Consider adding checks or try-catch blocks to handle unexpected inputs gracefully.
  • Consistency: Ensure that the method's approach to handling dates and billing cycles is consistent with other parts of the application. Inconsistencies in date handling can lead to subtle bugs that are difficult to track down.

Enhance code clarity with comments explaining complex logic and consider adding error handling for more robustness. Ensure consistency in date handling across the application.

Comment on lines 512 to 519
'',
consumerProvider
.onChangeOfBillYear,
consumerProvider
.getFinancialYearList(),
[consumerProvider
.getFinancialYearList().first],
true,
itemAsString: (i) =>'${ApplicationLocalizations.of(context).translate(i.financialYear)}',
controller: consumerProvider
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [92-94]

There's an issue in the dispose method where it adds the _numberFocus listener instead of removing it. This can lead to memory leaks and unintended behavior. The correct approach is to remove the listener when the widget is disposed of.

- _numberFocus.addListener(_onFocusChange);
+ _numberFocus.removeListener(_onFocusChange);

frontend/mgramseva/lib/utils/common_methods.dart Outdated Show resolved Hide resolved
frontend/mgramseva/lib/utils/common_methods.dart Outdated Show resolved Hide resolved
Comment on lines 169 to 219
static List<DatePeriod> getPastMonthUntilFinancialYTDMonthCount(DatePeriod ytd,
{int monthCount=2,bool showCurrentMonth = false}) {
var monthList = <DateTime>[];
final currentTime = DateTime.now();
DatePeriod newDT = DatePeriod(ytd.endDate.subtract(Duration(days: daysToSubtract(monthCount,currentTime.year,currentTime.month))), ytd.endDate, DateType.MONTH);
if (currentTime.year < newDT.startDate.year) {
return <DatePeriod>[];
}
if (currentTime.year == newDT.startDate.year) {
//when current year is same as start year of financial year
for (int i = newDT.startDate.month;
i <= (showCurrentMonth ? currentTime.month : currentTime.month - 1);
i++) {
monthList.add(DateTime(currentTime.year, i));
}
} else if (currentTime.year == newDT.endDate.year) {
//when current year is same as end year of financial year
for (int i = newDT.startDate.month; i <= 12; i++) {
monthList.add(DateTime(newDT.startDate.year, i));
}
for (int i = 1;
i <=
(currentTime.month <= newDT.endDate.month
? showCurrentMonth
? currentTime.month
: currentTime.month - 1
: newDT.endDate.month);
/*
* if current month is less than or equal to end month of financial year
* we are using months less than current month and if it is more than
* end month of financial year we are using till end month of financial
* year
*/
i++) {
monthList.add(DateTime(newDT.endDate.year, i));
}
} else {
for (int i = newDT.startDate.month; i <= 12; i++) {
monthList.add(DateTime(newDT.startDate.year, i));
}
for (int i = 1; i <= newDT.endDate.month; i++) {
monthList.add(DateTime(newDT.endDate.year, i));
}
}
var list = monthList
.map((e) => DatePeriod(DateTime(e.year, e.month, 1),
DateTime(e.year, e.month + 1, 0, 23, 59, 59, 999), DateType.MONTH))
.toList()
.reversed
.toList();
return list;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The getPastMonthUntilFinancialYTDMonthCount method correctly calculates the list of DatePeriod objects for months considering a specific month count. Consider adding comments to explain the logic, especially for complex parts, to improve maintainability.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between a893b59 and c930a71.
Files ignored due to path filters (1)
  • build/build-config.yml is excluded by: !**/*.yml
Files selected for processing (3)
  • frontend/mgramseva/lib/providers/consumer_details_provider.dart (3 hunks)
  • frontend/mgramseva/lib/screeens/consumer_details/consumer_details.dart (2 hunks)
  • frontend/mgramseva/lib/utils/common_methods.dart (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • frontend/mgramseva/lib/providers/consumer_details_provider.dart
  • frontend/mgramseva/lib/screeens/consumer_details/consumer_details.dart
  • frontend/mgramseva/lib/utils/common_methods.dart

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c930a71 and fdd4ec9.
Files selected for processing (1)
  • municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • municipal-services/ws-calculator/src/main/java/org/egov/wscalculation/service/DemandService.java

Copy link
Contributor

@rahuldevgarg rahuldevgarg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@debasishchakraborty-egovt Please take the action on the comments

@@ -199,7 +199,7 @@ public PropertyCriteria getPropertyCriteriaFromPropertyIds(List<Property> proper
*/
public void enrichBoundary(Property property, RequestInfo requestInfo){

boundaryService.getAreaType(property, requestInfo, PTConstants.BOUNDARY_HEIRARCHY_CODE);
// boundaryService.getAreaType(property, requestInfo, PTConstants.BOUNDARY_HEIRARCHY_CODE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As in MDMS V2 we are not using location-service to get location

@rahuldevgarg rahuldevgarg merged commit 779cb99 into master Mar 13, 2024
1 of 2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants