Merge pull request #318 from Kitzanos/ndg-application-prod
Cherry-pick (NDG changes)
This commit is contained in:
@@ -154,6 +154,13 @@ public class AppointmentDao {
|
||||
ApplicationEntity oldApplication = Utils.getClonedEntityForData(application);
|
||||
|
||||
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)) {
|
||||
log.warn("NDG generation already in progress. applicationId: {}", applicationId);
|
||||
throw new CustomValidationException(Status.SUCCESS, Translator.toLocale(GepafinConstant.NDG_GENERATION_IS_IN_PROGRESS));
|
||||
@@ -165,7 +172,7 @@ public class AppointmentDao {
|
||||
}
|
||||
|
||||
// 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());
|
||||
applicationRepository.save(application);
|
||||
|
||||
@@ -538,13 +545,9 @@ public class AppointmentDao {
|
||||
String authorizationToken = getBearerToken(hub);
|
||||
|
||||
// Try retrieving NDG by VAT number
|
||||
NdganagEntity ndganagEntity = ndganagRepository.findByVatNumber(company.getVatNumber());
|
||||
AppointmentLoginResponse ndgResponse=new AppointmentLoginResponse();
|
||||
if (ndganagEntity != null || ndganagEntity.getNdg() != null) {
|
||||
ndgResponse.setNdg(ndganagEntity.getNdg());
|
||||
}else {
|
||||
ndgResponse = retrieveNdgByVatNumber(company.getVatNumber(), authorizationToken, hub, application);
|
||||
}
|
||||
|
||||
if (isNdgValid(ndgResponse.getNdg())) {
|
||||
saveNdg(application, company, ndgResponse.getNdg());
|
||||
log.info("NDG successfully generated for applicationId: {}", applicationId);
|
||||
|
||||
Reference in New Issue
Block a user