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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
d81cfcb
Added configurability for recomputing attendance for muster roll update
holashchand Dec 19, 2024
e50e62c
added build configs for health muster roll
holashchand Dec 20, 2024
d49fcf0
Revert "added build configs for health muster roll"
holashchand Dec 23, 2024
4a5d4a8
Update build-config.yml
Harish-egov Dec 23, 2024
718729d
Update build-config.yml
Harish-egov Dec 23, 2024
8d584bd
Muster role service changes for validation, search and skills
holashchand Dec 26, 2024
38f9691
Added configurable bank account for muster roll health
holashchand Dec 26, 2024
47c753f
Fixed test case failure
holashchand Dec 26, 2024
d8c3d62
Added logic to update attendance register on approval of muster roll
holashchand Dec 27, 2024
7547e8e
minor fix
holashchand Dec 27, 2024
55af80b
changed notification to be configurable
holashchand Dec 27, 2024
4d6a7eb
updated build config
holashchand Jan 3, 2025
daa8181
Updated attendance register field for review status
holashchand Jan 3, 2025
4c8b162
Added configurable support for workflow in muster roll
holashchand Jan 6, 2025
29f23f4
Fixed musterroll enrichment on update
holashchand Jan 6, 2025
cc2ab2e
Fixed musterroll tests
holashchand Jan 6, 2025
d3130a6
Added validation for number of days for attendance for muster roll apis
holashchand Jan 8, 2025
2fc92e5
Fixed musterroll null pointer exception for create
holashchand Jan 9, 2025
c5c7022
added updated swagger contracts
holashchand Jan 21, 2025
a172b51
updated code with coderabbitai suggestions
holashchand Jan 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 127 additions & 21 deletions backend/muster-roll/Muster-Roll-Service-1.0.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@ info:
title: Muster Roll Service
description: ''

servers:
- url: /health-muster-roll
description: Base context path for the API
- url: http://localhost:8080/health-muster-roll
description: Base context path for the API

paths:
/muster-roll/v1/_estimate:
/v1/_estimate:
post:
tags:
- Muster Roll
Expand All @@ -22,7 +28,7 @@ paths:
schema:
$ref: '#/components/schemas/MusterRollResponse'

/muster-roll/v1/_create:
/v1/_create:
post:
tags:
- Muster Roll
Expand All @@ -39,7 +45,7 @@ paths:
schema:
$ref: '#/components/schemas/MusterRollResponse'

/muster-roll/v1/_update:
/v1/_update:
post:
tags:
- Muster Roll
Expand All @@ -56,7 +62,7 @@ paths:
schema:
$ref: '#/components/schemas/MusterRollResponse'

/muster-roll/v1/_search:
/v1/_search:
post:
tags:
- Muster Roll
Expand All @@ -66,7 +72,7 @@ paths:
schema:
$ref: '#/components/schemas/RequestInfoWrapper'
parameters:
- $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/parameters/tenantId'
- $ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/parameters/tenantId'
- name: ids
description: Ids of the muster roll
in: query
Expand Down Expand Up @@ -109,6 +115,13 @@ paths:
in: query
schema:
type: string
- name: referenceIds
description: Ids of the entity to which register is associated. Example ContractId
in: query
schema:
type: array
items:
type: string
- name: serviceCode
description: Service to which register is associated.
in: query
Expand All @@ -122,6 +135,23 @@ paths:
schema:
$ref: '#/components/schemas/MusterRollResponse'

/v2/_search:
post:
tags:
- Muster Roll
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/MusterRollSearchRequest'
responses:
'200':
description: 'Search results'
content:
application/json:
schema:
$ref: '#/components/schemas/MusterRollResponse'

components:
schemas:
MusterRoll:
Expand Down Expand Up @@ -196,11 +226,12 @@ components:
description: Reference of the attendee from the Individual Registry.
actualTotalAttendance:
type: number
minimum: 0
readOnly: true
description: It is the computed sum of attendance in the given time period of the muster roll. This will be stored in the muster roll service's db. It will be computed only when the muster is created. So the computation will happen with CREATE actions only.
modifiedTotalAttendance:
type: number
readOnly: true
minimum: 0
description: It is the modified sum of attendance in the given time period of the muster roll. This will be stored in the muster roll service's db. It will be stored when the totalAttendance is edited. So the updation will happen with EDIT actions only.
attendanceEntries:
type: array
Expand Down Expand Up @@ -232,23 +263,11 @@ components:
type: object
description: This is an updatable field from the user's input.

AttendanceLog:
$ref: 'https://github.com/egovernments/DIGIT-Works/blob/develop/backend/attendance-service/Attendance-Service-1.0.0.yaml#/components/schemas/AttendanceLog'

AttendanceLogResponse:
$ref: 'https://github.com/egovernments/DIGIT-Works/blob/develop/backend/attendance-service/Attendance-Service-1.0.0.yaml#/components/schemas/AttendanceLogResponse'

AttendanceRegister:
$ref: 'https://github.com/egovernments/DIGIT-Works/blob/develop/backend/attendance-service/Attendance-Service-1.0.0.yaml#/components/schemas/AttendanceRegister'

AttendanceRegisterResponse:
$ref: 'https://github.com/egovernments/DIGIT-Works/blob/develop/backend/attendance-service/Attendance-Service-1.0.0.yaml#/components/schemas/AttendanceRegisterResponse'

MusterRollRequest:
type: object
properties:
requestInfo:
$ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/RequestHeader'
$ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/definitions/RequestInfo'
musterRoll:
$ref: '#/components/schemas/MusterRoll'
workflow:
Expand All @@ -272,7 +291,7 @@ components:
type: object
properties:
responseInfo:
$ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/ResponseHeader'
$ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/definitions/ResponseInfo'
musterRolls:
type: array
items:
Expand All @@ -282,4 +301,91 @@ components:
type: object
properties:
requestInfo:
$ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/components/schemas/RequestHeader'
$ref: 'https://raw.githubusercontent.com/egovernments/DIGIT-OSS/master/core-services/docs/common-contract.yml#/definitions/RequestInfo'

MusterRollSearchCriteria:
type: object
properties:
ids:
type: array
items:
type: string
description: Ids of the muster roll
tenantId:
type: string
minLength: 2
maxLength: 64
description: Tenant ID (must be between 2 and 64 characters)
musterRollNumber:
type: string
description: (Custom-formatted) Muster roll number
registerId:
type: string
description: Register ID
registerIds:
type: array
items:
type: string
description: List of Register IDs
fromDate:
type: number
format: double
description: Start date (timestamp in milliseconds)
toDate:
type: number
format: double
description: End date (timestamp in milliseconds)
status:
$ref: '#/components/schemas/Status'
musterRollStatus:
type: string
description: Status of the muster roll (string representation)
example: APPROVAL_PENDING
referenceId:
type: string
description: Project ID where the register is created
default: null
serviceCode:
type: string
description: Service code
default: null
limit:
type: integer
description: Maximum number of results to return
offset:
type: integer
description: Offset for pagination
sortBy:
type: string
description: Field to sort by
order:
$ref: '#/components/schemas/PaginationOrderEnum'
required:
- tenantId

MusterRollSearchRequest:
allOf:
- $ref: '#/components/schemas/RequestInfoWrapper'
- type: object
properties:
musterRoll:
$ref: '#/components/schemas/MusterRollSearchCriteria'
required:
- musterRoll

Status:
type: string
enum:
- ACTIVE
- INWORKFLOW
- INACTIVE
- CANCELLED
description: state of the muster roll
example: ACTIVE

PaginationOrderEnum:
type: string
description: Order of sorting
enum:
- ASC
- DESC
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public class MusterRollServiceConfiguration {
private String attendanceLogEndpoint;
@Value("${works.attendance.register.search.endpoint}")
private String attendanceRegisterEndpoint;
@Value("${works.attendance.register.update.endpoint}")
private String attendanceRegisterUpdateEndpoint;
holashchand marked this conversation as resolved.
Show resolved Hide resolved
@Value("${works.attendance.register.search.limit}")
private String attendanceRegisterSearchLimit;

Expand All @@ -105,6 +107,9 @@ public class MusterRollServiceConfiguration {
@Value("${kafka.topics.notification.sms}")
private String smsNotificationTopic;

@Value("${notification.sms.enabled:false}")
private boolean sendNotificationEnabled;

//Expense Service
@Value("${works.expense.calculator.host}")
private String expenseCalculatorServiceHost;
Expand All @@ -127,6 +132,51 @@ public class MusterRollServiceConfiguration {
@Value("${works.contract.service.code}")
private String contractServiceCode;

@Value("${musterroll.update.recompute.attendance.enabled:true}")
private boolean recomputeAttendanceEnabled;

@Value("${musterroll.workflow.enabled:true}")
private boolean musterRollWorkflowEnabled;

@Value("${musterroll.noworkflow.create.status}")
private String musterRollNoWorkflowCreateStatus;

@Value("${musterroll.individual.entry.roles.enabled:false}")
private boolean individualEntryRolesEnabled;

@Value("${musterroll.validate.start.date.monday.enabled:true}")
private boolean validateStartDateMondayEnabled;

@Value("${musterroll.validate.attendance.register.enabled:false}")
private boolean validateAttendanceRegisterEnabled;

@Value("${musterroll.set.default.duration.enabled:false}")
private boolean musterRollSetDefaultDurationEnabled;

@Value("${musterroll.default.duration.days:6}")
private int musterRollDefaultDuration;

@Value("${musterroll.add.bank.account.details.enabled:true}")
private boolean addBankAccountDetails;

@Value("${musterroll.update.attendance.register.review.status.enabled:true}")
private boolean updateAttendanceRegisterReviewStatusEnabled;

@Value("${egov.user.host}")
private String userHost;

@Value("${egov.user.context.path}")
private String userContextPath;

@Value("${egov.user.create.path}")
private String userCreateEndpoint;

@Value("${egov.user.search.path}")
private String userSearchEndpoint;

@Value("${egov.user.update.path}")
private String userUpdateEndpoint;

@PostConstruct
public void initialize() {
TimeZone.setDefault(TimeZone.getTimeZone(timeZone));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ private StringBuilder prepareSearchQuery(MusterRollSearchCriteria searchCriteria
addClauseIfRequired(preparedStmtList, queryBuilder);
queryBuilder.append(" muster.attendance_register_id=? ");
preparedStmtList.add(searchCriteria.getRegisterId());
} else if (searchCriteria.getRegisterIds() != null && !searchCriteria.getRegisterIds().isEmpty()) {
addClauseIfRequired(preparedStmtList, queryBuilder);
queryBuilder.append(" muster.attendance_register_id IN (").append(createQuery(searchCriteria.getRegisterIds())).append(")");
addToPreparedStatement(preparedStmtList, searchCriteria.getRegisterIds());
holashchand marked this conversation as resolved.
Show resolved Hide resolved
} else if (registerIds != null && !registerIds.isEmpty()) {
addClauseIfRequired(preparedStmtList, queryBuilder);
queryBuilder.append(" muster.attendance_register_id IN (").append(createQuery(registerIds)).append(")");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ public void createAttendance(MusterRollRequest musterRollRequest, boolean isCrea
//Add all absentee individualIds as well
individualIds.addAll(absenteesList.stream().map(entry-> entry.getIndividualId()).collect(Collectors.toSet()));
List<Individual> individuals = fetchIndividualDetails(individualIds, musterRollRequest.getRequestInfo(),musterRoll.getTenantId(),musterRoll);
List<BankAccount> bankAccounts = fetchBankaccountDetails(individualIds, musterRollRequest.getRequestInfo(),musterRoll.getTenantId());

for (Map.Entry<String,List<LocalDateTime>> entry : individualExitAttendanceMap.entrySet()) {
IndividualEntry individualEntry = new IndividualEntry();
Expand Down Expand Up @@ -197,29 +196,33 @@ public void createAttendance(MusterRollRequest musterRollRequest, boolean isCrea
individualEntries.add(individualEntry);
}

// Loop through and set individual and bank account details
for (IndividualEntry entry : individualEntries) {

// Set individual details in additionalDetails
if (!CollectionUtils.isEmpty(individuals) /* && !CollectionUtils.isEmpty(bankAccounts) */) {
Individual individual = individuals.stream()
.filter(ind -> ind.getId().equalsIgnoreCase(entry.getIndividualId())).findFirst()
.orElse(null);
BankAccount bankAccount = bankAccounts.stream()
.filter(account -> account.getReferenceId().equalsIgnoreCase(entry.getIndividualId()))
.findFirst().orElse(null);

if (individual != null /* && bankAccount != null */) {
setAdditionalDetails(entry, individualEntriesFromRequest, mdmsV2Data, individual,
bankAccount, isCreate);
} else {
log.info(
"CalculationService::createAttendance::No match found in individual and bank account service for the individual id from attendance log - "
+ entry.getIndividualId());
}

}
}
if(config.isAddBankAccountDetails()) {
List<BankAccount> bankAccounts = fetchBankaccountDetails(individualIds, musterRollRequest.getRequestInfo(),musterRoll.getTenantId());
// Loop through and set individual and bank account details
for (IndividualEntry entry : individualEntries) {

// Set individual details in additionalDetails
if (!CollectionUtils.isEmpty(individuals)) {
Individual individual = individuals.stream()
.filter(ind -> ind.getId().equalsIgnoreCase(entry.getIndividualId())).findFirst()
.orElse(null);
BankAccount bankAccount = bankAccounts.stream()
.filter(account -> account.getReferenceId().equalsIgnoreCase(entry.getIndividualId()))
.findFirst().orElse(null);

if (individual != null) {
setAdditionalDetails(entry, individualEntriesFromRequest, mdmsV2Data, individual,
bankAccount, isCreate);
} else {
log.info(
"CalculationService::createAttendance::No match found in individual and bank account service for the individual id from attendance log - "
+ entry.getIndividualId());
}

}
}
}


musterRoll.setIndividualEntries(individualEntries);
log.debug("CalculationService::createAttendance::Individuals::size::"+musterRoll.getIndividualEntries().size());
Expand Down
Loading