Conflicts resolved

This commit is contained in:
harish
2024-08-27 15:41:01 +05:30
3 changed files with 29 additions and 2 deletions

View File

@@ -236,10 +236,12 @@ public class CallDao {
Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
}
if (createCallRequest.getStartDate().toLocalDate().isBefore(LocalDate.now())
|| createCallRequest.getEndDate().toLocalDate().isBefore(LocalDate.now())) {
|| createCallRequest.getEndDate().toLocalDate().isBefore(LocalDate.now()) || createCallRequest
.getStartDate().toLocalDate().isAfter(createCallRequest.getEndDate().toLocalDate())) {
throw new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
}
}
public CreateCallResponseBean convertToCallResponseBean(CallEntity callEntity) {
@@ -379,7 +381,7 @@ public class CallDao {
public CallEntity getCallById(Long callId) {
return callRepository.findById(callId).orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.NAME_NOT_EMPTY_MSG)));
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
}
public CreateCallResponseBean createCallStep2(CreateCallRequestStep2 createCallRequest, Long userId) {
@@ -409,8 +411,31 @@ public class CallDao {
return createCallResponseBean;
}
public void isValidDateRange(UpdateCallRequestStep1 updateCallRequest, CallEntity callEntity) {
LocalDate startDate = updateCallRequest.getStartDate() != null ? updateCallRequest.getStartDate().toLocalDate()
: null;
LocalDate endDate = updateCallRequest.getEndDate() != null ? updateCallRequest.getEndDate().toLocalDate()
: null;
Boolean isValid = true;
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
isValid = false;
} else if (startDate != null && callEntity.getEndDate() != null
&& startDate.isAfter(callEntity.getEndDate().toLocalDate())) {
isValid = false;
} else if (endDate != null && callEntity.getStartDate() != null
&& callEntity.getStartDate().toLocalDate().isAfter(endDate)) {
isValid = false;
}
if (Boolean.FALSE.equals(isValid)) {
throw new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
}
}
public CreateCallResponseBean updateCallStep1(Long callId, UpdateCallRequestStep1 updateCallRequest, Long userId) {
CallEntity callEntity = getCallById(callId);
isValidDateRange(updateCallRequest, callEntity);
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
setIfUpdated(callEntity::getDescriptionShort, callEntity::setDescriptionShort,
updateCallRequest.getDescriptionShort());

View File

@@ -48,6 +48,7 @@ call.invalid.date=Invalid start or end date.
call.update.successfully=Call updated successfully.
call.fetch.success=Call details fetched successfully.
call.not.found=Call not found.
# Login-related messages
login.successfully=Login successfully.

View File

@@ -46,6 +46,7 @@ document.id.not.found=ID documento non trovato.
call.invalid.date=Data di inizio o fine non valida.
call.update.successfully=Chiamata aggiornata con successo.
call.fetch.success=Dettagli della chiamata recuperati con successo.
call.not.found=Chiamata non trovata.
# Login-related messages
login.successfully=Accesso effettuato con successo.