Updated code

This commit is contained in:
rajesh
2025-07-01 18:15:28 +05:30
parent 188aa78d15
commit d8a7b4bd84

View File

@@ -154,6 +154,13 @@ public class AppointmentDao {
ApplicationEntity oldApplication = Utils.getClonedEntityForData(application); ApplicationEntity oldApplication = Utils.getClonedEntityForData(application);
NdgResponse ndgResponse = new NdgResponse(); NdgResponse ndgResponse = new NdgResponse();
CompanyEntity company = companyService.validateCompany(application.getCompanyId());
NdganagEntity ndganagEntity = ndganagRepository.findByVatNumber(company.getVatNumber());
if (ndganagEntity != null && ndganagEntity.getNdg() != null) {
ndgResponse.setNdg(ndganagEntity.getNdg());
return ndgResponse;
}
if (application.getNdgStatus() != null && application.getNdgStatus().equalsIgnoreCase(GepafinConstant.NDG_IN_PROGRESS)) { if (application.getNdgStatus() != null && application.getNdgStatus().equalsIgnoreCase(GepafinConstant.NDG_IN_PROGRESS)) {
log.warn("NDG generation already in progress. applicationId: {}", applicationId); log.warn("NDG generation already in progress. applicationId: {}", applicationId);
throw new CustomValidationException(Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_GENERATION_IS_IN_PROGRESS)); throw new CustomValidationException(Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_GENERATION_IS_IN_PROGRESS));
@@ -165,7 +172,7 @@ public class AppointmentDao {
} }
// Update application status // Update application status
log.info("Updating NDG status to IN_PROGRESS. applicationId: {}", applicationId); log.info("Updating NDG status of applicationId: {}", applicationId);
application.setNdgStatus(NdgStatusEnum.NDG_INITITATED.getValue()); application.setNdgStatus(NdgStatusEnum.NDG_INITITATED.getValue());
applicationRepository.save(application); applicationRepository.save(application);
@@ -538,13 +545,9 @@ public class AppointmentDao {
String authorizationToken = getBearerToken(hub); String authorizationToken = getBearerToken(hub);
// Try retrieving NDG by VAT number // Try retrieving NDG by VAT number
NdganagEntity ndganagEntity = ndganagRepository.findByVatNumber(company.getVatNumber());
AppointmentLoginResponse ndgResponse=new AppointmentLoginResponse(); AppointmentLoginResponse ndgResponse=new AppointmentLoginResponse();
if (ndganagEntity != null || ndganagEntity.getNdg() != null) {
ndgResponse.setNdg(ndganagEntity.getNdg());
}else {
ndgResponse = retrieveNdgByVatNumber(company.getVatNumber(), authorizationToken, hub, application); ndgResponse = retrieveNdgByVatNumber(company.getVatNumber(), authorizationToken, hub, application);
}
if (isNdgValid(ndgResponse.getNdg())) { if (isNdgValid(ndgResponse.getNdg())) {
saveNdg(application, company, ndgResponse.getNdg()); saveNdg(application, company, ndgResponse.getNdg());
log.info("NDG successfully generated for applicationId: {}", applicationId); log.info("NDG successfully generated for applicationId: {}", applicationId);