Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Muster roll service configurability and hcm payment changes #1854

Open
wants to merge 20 commits into
base: develop-hcm
Choose a base branch
from

Conversation

holashchand
Copy link
Collaborator

@holashchand holashchand commented Dec 20, 2024

Muster roll service changes -

Changes

  • Changed notification to be configurable
  • Configurable start day as Monday validation
  • Configurable bank account for muster roll health
  • Configurable recomputing attendance for muster roll update
  • Added configurable support for workflow in muster roll

New features

  • Update attendance register on approval of muster roll
  • Added configurable validation for number of days for attendance for muster roll apis
  • new /v2/_search API to search muster roll, to be able to use request body instead of params for bills with support of search using multiple register ids

Backward Compatibility

  • All changes are configurable and backward compatible

Summary by CodeRabbit

Based on the comprehensive changes across multiple files, here are the release notes:

Release Notes: Muster Roll Service Enhancements

New Features

  • Added configurable workflow management for muster rolls
  • Introduced enhanced search capabilities for muster rolls
  • Implemented optional SMS notifications for muster roll events
  • Added support for bank account details in attendance tracking
  • Enabled configurable attendance validation and recomputation

Configuration Improvements

  • Added multiple configuration flags to control service behavior
  • Introduced granular control over workflow, notification, and validation processes
  • Implemented default duration settings for muster rolls

Validation Enhancements

  • Added validation for attendance register dates
  • Implemented start date validation (optional Monday requirement)
  • Added constraints on attendance calculations

Performance Optimizations

  • Conditional processing of bank account details
  • Configurable attendance recomputation
  • Optimized search and filtering mechanisms

API Updates

  • Added new /v2/_search endpoint for muster roll searches
  • Improved error handling and validation in API controllers

Minor Improvements

  • Added new constants and utility methods
  • Enhanced logging and error tracking
  • Improved user role management

@holashchand holashchand requested a review from a team as a code owner December 20, 2024 06:53
Copy link
Contributor

coderabbitai bot commented Dec 20, 2024

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The pull request introduces extensive configuration and functionality enhancements for the muster roll service. The changes span multiple files and focus on adding configurable options for workflow management, attendance tracking, and user interactions. Key modifications include new configuration properties in the MusterRollServiceConfiguration, expanded validation logic, conditional feature toggles, and improved error handling across various service components.

Changes

File Change Summary
backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java Added multiple configuration properties for workflow, notifications, attendance, and user management
backend/muster-roll/src/main/java/org/egov/repository/querybuilder/MusterRollQueryBuilder.java Enhanced query building logic to handle registerIds filtering
backend/muster-roll/src/main/resources/application.properties Introduced new configuration properties for muster roll service features
backend/muster-roll/src/main/java/org/egov/web/models/* Added new models like MusterRollSearchRequest, AttendanceRegisterRequest, and enhanced existing models

Sequence Diagram

sequenceDiagram
    participant Client
    participant MusterRollController
    participant MusterRollService
    participant MusterRollValidator
    participant WorkflowService
    participant NotificationService

    Client->>MusterRollController: Create/Update Muster Roll
    MusterRollController->>MusterRollService: Process Request
    MusterRollService->>MusterRollValidator: Validate Request
    alt Workflow Enabled
        MusterRollService->>WorkflowService: Update Workflow Status
    end
    alt Notification Enabled
        MusterRollService->>NotificationService: Send Notifications
    end
    MusterRollService-->>Client: Return Muster Roll Response
Loading

Possibly related PRs

Suggested reviewers

  • shailesh-egov

Poem

🐰 A Rabbit's Ode to Configuration

In lines of code, new toggles arise,
Muster rolls dance before my eyes!
Workflows enabled, notifications bright,
Configuration's magic takes flight!
Hop, hop, hooray for flexible code! 🎉


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>, please review it.
    • Generate unit testing code 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 testing code 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@holashchand holashchand changed the title Added configurability for recomputing attendance for muster roll update Muster roll service configurability and hcm payment changes Dec 31, 2024
@holashchand holashchand changed the base branch from develop to develop-hcm January 20, 2025 05:54
@holashchand
Copy link
Collaborator Author

@coderabbitai review

Copy link
Contributor

coderabbitai bot commented Jan 20, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@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.

Actionable comments posted: 25

🔭 Outside diff range comments (3)
backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceConstants.java (1)

Line range hint 1-43: Consider grouping related constants for better maintainability.

The constants in this file would benefit from logical grouping. Consider organizing them into sections with comments, grouping related constants like:

  • Workflow actions (ACTION_*, WF_*)
  • Status constants (STATUS_*)
  • Event types (*_EVENT)
  • MDMS related (MDMS_*, MASTER_*)
  • Notification codes (*_NOTIFICATION_*)

Example structure:

public class MusterRollServiceConstants {
    // Workflow Actions
    public static final String ACTION_APPROVE = "APPROVE";
    public static final String ACTION_REJECT = "REJECT";
    public static final String WF_APPROVE_CODE = "APPROVE";
    public static final String WF_SEND_BACK_TO_CBO_CODE = "SENDBACKTOCBO";

    // Status Constants
    public static final String STATUS_APPROVED = "APPROVED";

    // Event Types
    public static final String ENTRY_EVENT = "ENTRY";
    public static final String EXIT_EVENT = "EXIT";
    
    // ... other groupings
}
backend/muster-roll/src/main/resources/application.properties (1)

Line range hint 8-11: Security: Avoid committing sensitive information.

Database credentials and sensitive configuration should not be committed directly in the properties file. Consider:

  1. Using environment variables or external configuration management
  2. Implementing a secure secrets management solution
-spring.datasource.url=jdbc:postgresql://localhost:5432/digit-works
-spring.datasource.username=postgres
-spring.datasource.password=egov
+spring.datasource.url=${SPRING_DATASOURCE_URL}
+spring.datasource.username=${SPRING_DATASOURCE_USERNAME}
+spring.datasource.password=${SPRING_DATASOURCE_PASSWORD}
backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java (1)

Line range hint 292-297: Typo Error: Incorrect Constant Name COMPUTE_ATTENDENSE

There's a typo in the constant name COMPUTE_ATTENDENSE. It should be COMPUTE_ATTENDANCE to maintain consistency and avoid confusion. This typo can lead to issues when the code tries to find the value in the JSON node.

Please correct the constant name and its usages:

- private static final String COMPUTE_ATTENDENSE = "computeAttendance";
+ private static final String COMPUTE_ATTENDANCE = "computeAttendance";

And update its usage in isComputeAttendance method:

- if (node.findValue(COMPUTE_ATTENDENSE) != null && StringUtils.isNotBlank(node.findValue(COMPUTE_ATTENDENSE).textValue())) {
+ if (node.findValue(COMPUTE_ATTENDANCE) != null && StringUtils.isNotBlank(node.findValue(COMPUTE_ATTENDANCE).textValue())) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a34b8f6 and 2fc92e5.

📒 Files selected for processing (20)
  • backend/muster-roll/src/main/java/org/egov/config/MusterRollServiceConfiguration.java (3 hunks)
  • backend/muster-roll/src/main/java/org/egov/repository/querybuilder/MusterRollQueryBuilder.java (1 hunks)
  • backend/muster-roll/src/main/java/org/egov/service/CalculationService.java (1 hunks)
  • backend/muster-roll/src/main/java/org/egov/service/EnrichmentService.java (2 hunks)
  • backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java (4 hunks)
  • backend/muster-roll/src/main/java/org/egov/service/NotificationService.java (1 hunks)
  • backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceConstants.java (1 hunks)
  • backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java (5 hunks)
  • backend/muster-roll/src/main/java/org/egov/util/UserUtil.java (4 hunks)
  • backend/muster-roll/src/main/java/org/egov/validator/MusterRollValidator.java (9 hunks)
  • backend/muster-roll/src/main/java/org/egov/web/controllers/MusterRollApiController.java (2 hunks)
  • backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegister.java (1 hunks)
  • backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegisterRequest.java (1 hunks)
  • backend/muster-roll/src/main/java/org/egov/web/models/IndividualEntry.java (2 hunks)
  • backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchCriteria.java (1 hunks)
  • backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchRequest.java (1 hunks)
  • backend/muster-roll/src/main/resources/application.properties (3 hunks)
  • backend/muster-roll/src/test/java/org/egov/service/MusterRollServiceTest.java (1 hunks)
  • backend/muster-roll/src/test/java/org/egov/validator/MusterRollValidatorTest.java (3 hunks)
  • build/build-config.yml (1 hunks)
🔇 Additional comments (24)
backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceConstants.java (1)

18-18: Verify the distinction between ACTION_APPROVE and WF_APPROVE_CODE.

The constant addition follows consistent naming. However, there's already a constant WF_APPROVE_CODE with the same value "APPROVE". Let's verify they serve different purposes.

✅ Verification successful

The constants ACTION_APPROVE and WF_APPROVE_CODE serve distinct purposes and are correctly separated.

While both constants share the same value "APPROVE", they are used in different contexts - ACTION_APPROVE for action handling in the main service and WF_APPROVE_CODE specifically for workflow notifications. This separation is intentional and follows good practices.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for usages of both constants to understand their distinct purposes
echo "Searching for ACTION_APPROVE usage:"
rg "ACTION_APPROVE" -A 3

echo -e "\nSearching for WF_APPROVE_CODE usage:"
rg "WF_APPROVE_CODE" -A 3

Length of output: 3084

build/build-config.yml (2)

45-51: Verify Dockerfile consistency across health services.

The new health-muster-roll service uses maven-java17/Dockerfile while the existing health-attendance service uses maven/Dockerfile. This inconsistency might lead to version compatibility issues.

Run this script to check Dockerfile usage across health services:


47-48: Review shared work directory with digit-works muster-roll.

Both health-muster-roll and digit-works/backend/muster-roll services use the same work directory backend/muster-roll. This might cause conflicts or unintended sharing of resources.

Run this script to check for potential conflicts:

backend/muster-roll/src/main/java/org/egov/service/EnrichmentService.java (1)

164-165: LGTM! Appropriate conditional logging for workflow actions.

The workflow action logging is correctly guarded by the configuration flag, aligning with the PR's objective of making workflow configurable.

backend/muster-roll/src/main/java/org/egov/util/UserUtil.java (3)

24-28: Good improvement in field declarations!

Making the fields final improves thread safety and enforces immutability, which is a good practice for dependency injection.


34-37: Constructor changes look good!

The constructor properly initializes all final fields and correctly incorporates the new configuration dependency.


50-52: Verify endpoint configuration values.

The endpoint checks now use configuration methods instead of hardcoded values. Please ensure that all required endpoint configurations are properly set in the configuration files.

✅ Verification successful

Endpoint configurations are properly set and complete

All required user endpoint configurations are present in backend/muster-roll/src/main/resources/application.properties:

  • User host and context path
  • Create endpoint
  • Search endpoint
  • Update endpoint
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for endpoint configurations in application properties files
rg -l "user\.(search|create|update)\.endpoint" --type properties

Length of output: 101


Script:

#!/bin/bash
# Find configuration files
echo "=== Configuration Files ==="
fd -e yml -e yaml -e properties

# Search for endpoint configurations in Java files
echo -e "\n=== Java Configurations ==="
rg "user\.(search|create|update)\.endpoint" -t java

# Search within found configuration files
echo -e "\n=== Configuration Content ==="
fd -e yml -e yaml -e properties -x rg -l "user\.(search|create|update)"

Length of output: 3438


Script:

#!/bin/bash
# Check content of muster-roll's application.properties
echo "=== Muster Roll Application Properties ==="
cat backend/muster-roll/src/main/resources/application.properties | grep -A 2 -B 2 "user\."

Length of output: 454

backend/muster-roll/src/main/java/org/egov/web/models/AttendanceRegisterRequest.java (2)

1-6: LGTM! Clean and minimal imports.

The package structure and imports are well-organized and contain only the necessary dependencies.


13-15: LGTM! Well-implemented builder pattern.

The static factory method for the builder follows best practices.

backend/muster-roll/src/main/java/org/egov/web/models/IndividualEntry.java (2)

42-43: LGTM! Good validation constraint.

The @min(0) constraint appropriately prevents negative values for actual attendance, which aligns with business logic.


46-47: 🧹 Nitpick (assertive)

Consider additional validation between actual and modified attendance.

While the @min(0) constraint is good, consider adding validation to ensure modifiedTotalAttendance doesn't exceed some reasonable threshold compared to actualTotalAttendance, preventing potential data entry errors.

Let's verify if such validation exists elsewhere:

backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchRequest.java (1)

1-21: LGTM! Well-structured request wrapper.

The implementation follows eGov patterns and includes proper validation annotations.

backend/muster-roll/src/main/java/org/egov/web/models/MusterRollSearchCriteria.java (1)

34-36: Verify the coexistence of registerId and registerIds fields.

Having both singular and plural versions of the same field could lead to confusion. Please clarify:

  1. Can both fields be used simultaneously?
  2. Should there be validation to ensure only one is used at a time?
✅ Verification successful

Both fields serve distinct purposes and can coexist safely

The codebase shows a clear separation of concerns:

  • registerId: Used for single record operations (exact match)
  • registerIds: Used for search/filter operations (multiple matches)

This is a common and valid pattern in search criteria objects.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for usage patterns of registerId and registerIds
echo "Searching for usage patterns..."
rg -A 5 "registerId|registerIds" --type java

Length of output: 84289

backend/muster-roll/src/main/resources/application.properties (1)

123-130: 🧹 Nitpick (assertive)

Review security implications of default configurations.

Several critical configurations are enabled by default which might have security implications:

  1. Bank account details feature is enabled (musterroll.add.bank.account.details.enabled=true)
  2. Attendance register validation is disabled (musterroll.validate.attendance.register.enabled=false)

Consider:

  • Disabling sensitive features by default
  • Enabling validation by default
  • Making these configurations environment-specific
-musterroll.add.bank.account.details.enabled=true
+musterroll.add.bank.account.details.enabled=${MUSTERROLL_ADD_BANK_DETAILS_ENABLED:false}
-musterroll.validate.attendance.register.enabled=false
+musterroll.validate.attendance.register.enabled=${MUSTERROLL_VALIDATE_ATTENDANCE_REGISTER:true}
backend/muster-roll/src/main/java/org/egov/util/MusterRollServiceUtil.java (2)

153-163: LGTM: Role information added correctly

The logic for adding roles to the additionalDetails when individualEntryRolesEnabled is configured is correctly implemented. The exception handling appropriately addresses scenarios where no user is found for a given individual ID.


290-315: Method updateAttendanceRegister added correctly

The new method updateAttendanceRegister is appropriately implemented to update the attendance register. The request construction and error handling enhance the robustness of the service.

backend/muster-roll/src/main/java/org/egov/validator/MusterRollValidator.java (4)

100-105: Good Practice: Configurable Validation Checks Implemented

The addition of configuration checks for attendance validation and workflow enables flexibility in the validation process. By checking serviceConfiguration.isValidateAttendanceRegisterEnabled() and serviceConfiguration.isMusterRollWorkflowEnabled(), the system can dynamically enable or disable features based on configuration, enhancing maintainability.

Also applies to: 134-139


198-200: Enhanced Flexibility: Conditional Start Date Validation

The start date validation now checks the configuration isValidateStartDateMondayEnabled before enforcing that the start date must be a Monday. This provides greater configurability, allowing the system to adapt to different business requirements without code changes.


208-212: Improvement: Configurable Default Duration for Muster Roll

By introducing isMusterRollSetDefaultDurationEnabled, the system can conditionally set the end date of the muster roll based on a default duration specified in the configuration. This enhances the flexibility and adaptability of the muster roll creation process.


313-341: Well-Structured: Attendance Validation and Enrichment Logic Added

The new validateAndEnrichAttendance method adds robust validation to ensure that attendance days do not exceed the days available in the attendance register. It also aligns the muster roll's start and end dates with those of the attendance register, ensuring data consistency.

backend/muster-roll/src/main/java/org/egov/service/MusterRollService.java (1)

130-134: Configurable Workflow Handling Implemented

The inclusion of configuration checks config.isMusterRollWorkflowEnabled() before updating the workflow status in both createMusterRoll and updateMusterRoll methods is commendable. This allows for dynamic enabling or disabling of workflow features without code modifications.

Also applies to: 218-220

backend/muster-roll/src/main/java/org/egov/service/NotificationService.java (1)

45-45: Good Practice: Added Configuration Check for Notifications

The addition of if(!config.isSendNotificationEnabled()) return; ensures that notifications are sent only when the feature is enabled. This allows for easier management of notification settings and prevents unintended message sending.

backend/muster-roll/src/test/java/org/egov/service/MusterRollServiceTest.java (1)

84-84: LGTM! Test setup correctly enables workflow validation.

The mock configurations ensure that workflow validation is enabled during the tests, which is necessary for verifying the workflow-related error scenarios.

Also applies to: 145-145

backend/muster-roll/src/test/java/org/egov/validator/MusterRollValidatorTest.java (1)

50-50: LGTM! Test setup correctly enables required validations.

The mock configurations ensure that both start date validation and workflow validation are enabled during the tests, which is necessary for verifying the validation logic.

Also applies to: 135-135

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants