Updated code
This commit is contained in:
@@ -926,6 +926,7 @@ public class ApplicationDao {
|
|||||||
private void sendMailToUserAndCompany(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
private void sendMailToUserAndCompany(UserEntity userEntity, ApplicationEntity applicationEntity) {
|
||||||
CallEntity call =applicationEntity.getCall();
|
CallEntity call =applicationEntity.getCall();
|
||||||
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
|
||||||
|
UserWithCompanyEntity userWithCompany=companyService.getUserWithCompany(userEntity.getId(),company.getId());
|
||||||
ProtocolEntity protocol= applicationEntity.getProtocol();
|
ProtocolEntity protocol= applicationEntity.getProtocol();
|
||||||
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
|
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
|
||||||
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
|
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
|
||||||
@@ -957,8 +958,8 @@ public class ApplicationDao {
|
|||||||
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email),emailLogRequest);
|
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email),emailLogRequest);
|
||||||
List<String> recipientEmails = new ArrayList<>();
|
List<String> recipientEmails = new ArrayList<>();
|
||||||
// recipientEmails.add(email);
|
// recipientEmails.add(email);
|
||||||
String companyEmail = company.getEmail();
|
String companyEmail = userWithCompany.getEmail();
|
||||||
String contactEmail = company.getContactEmail();
|
String contactEmail = userWithCompany.getContactEmail();
|
||||||
|
|
||||||
if (companyEmail != null && !companyEmail.isEmpty()) {
|
if (companyEmail != null && !companyEmail.isEmpty()) {
|
||||||
recipientEmails.add(companyEmail);
|
recipientEmails.add(companyEmail);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class CompanyDao {
|
|||||||
if (existingCompany != null) {
|
if (existingCompany != null) {
|
||||||
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), existingCompany.getId()).orElse(null);
|
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), existingCompany.getId()).orElse(null);
|
||||||
if (existingRelation == null) {
|
if (existingRelation == null) {
|
||||||
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, existingCompany, companyRequest.getIsLegalRepresentant(),companyRequest.getVatCheckResponse());
|
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, existingCompany, companyRequest.getIsLegalRepresentant(),companyRequest);
|
||||||
|
|
||||||
/** This code is responsible for adding a version history log for "adding user with company" operation. **/
|
/** This code is responsible for adding a version history log for "adding user with company" operation. **/
|
||||||
loggingUtil.addVersionHistory(
|
loggingUtil.addVersionHistory(
|
||||||
@@ -84,7 +84,7 @@ public class CompanyDao {
|
|||||||
/** This code is responsible for adding a version history log for "creating company" operation. **/
|
/** This code is responsible for adding a version history log for "creating company" operation. **/
|
||||||
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(companyData).build());
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(companyData).build());
|
||||||
|
|
||||||
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, companyEntity, companyRequest.getIsLegalRepresentant(),companyRequest.getVatCheckResponse());
|
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, companyEntity, companyRequest.getIsLegalRepresentant(),companyRequest);
|
||||||
|
|
||||||
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
return convertCompanyEntityToCompanyResponse(companyEntity, userWithCompanyEntity);
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ public class CompanyDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private UserWithCompanyEntity createUserWithCompanyRelation(UserEntity userEntity, CompanyEntity companyEntity, Boolean isLegalRepresentant,Map<String, Object> vatCheckResponse) {
|
private UserWithCompanyEntity createUserWithCompanyRelation(UserEntity userEntity, CompanyEntity companyEntity, Boolean isLegalRepresentant,CompanyRequest companyRequest) {
|
||||||
|
|
||||||
UserWithCompanyEntity userWithCompanyEntity = new UserWithCompanyEntity();
|
UserWithCompanyEntity userWithCompanyEntity = new UserWithCompanyEntity();
|
||||||
if (userEntity.getBeneficiary() != null) {
|
if (userEntity.getBeneficiary() != null) {
|
||||||
@@ -118,11 +118,11 @@ public class CompanyDao {
|
|||||||
userWithCompanyEntity.setCompanyId(companyEntity.getId());
|
userWithCompanyEntity.setCompanyId(companyEntity.getId());
|
||||||
userWithCompanyEntity.setUserId(userEntity.getId());
|
userWithCompanyEntity.setUserId(userEntity.getId());
|
||||||
userWithCompanyEntity.setIsLegalRepresentant(isLegalRepresentant);
|
userWithCompanyEntity.setIsLegalRepresentant(isLegalRepresentant);
|
||||||
userWithCompanyEntity.setEmail(companyEntity.getEmail());
|
userWithCompanyEntity.setEmail(companyRequest.getEmail());
|
||||||
userWithCompanyEntity.setPec(companyEntity.getPec());
|
userWithCompanyEntity.setPec(companyRequest.getPec());
|
||||||
userWithCompanyEntity.setContactName(companyEntity.getContactName());
|
userWithCompanyEntity.setContactName(companyRequest.getContactName());
|
||||||
userWithCompanyEntity.setContactEmail(companyEntity.getContactEmail());
|
userWithCompanyEntity.setContactEmail(companyRequest.getContactEmail());
|
||||||
userWithCompanyEntity.setJson(Utils.convertMapIntoJsonString(vatCheckResponse) );
|
userWithCompanyEntity.setJson(Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) );
|
||||||
UserWithCompanyEntity userWithCompany = userWithCompanyRepository.save(userWithCompanyEntity);
|
UserWithCompanyEntity userWithCompany = userWithCompanyRepository.save(userWithCompanyEntity);
|
||||||
|
|
||||||
/** This code is responsible for adding a version history log for the "adding user with company" operation. **/
|
/** This code is responsible for adding a version history log for the "adding user with company" operation. **/
|
||||||
@@ -141,12 +141,8 @@ public class CompanyDao {
|
|||||||
entity.setProvince(request.getProvince());
|
entity.setProvince(request.getProvince());
|
||||||
entity.setCap(request.getCap());
|
entity.setCap(request.getCap());
|
||||||
entity.setCountry(request.getCountry());
|
entity.setCountry(request.getCountry());
|
||||||
entity.setPec(request.getPec());
|
|
||||||
entity.setEmail(request.getEmail());
|
|
||||||
entity.setNumberOfEmployees(request.getNumberOfEmployees());
|
entity.setNumberOfEmployees(request.getNumberOfEmployees());
|
||||||
entity.setAnnualRevenue(request.getAnnualRevenue());
|
entity.setAnnualRevenue(request.getAnnualRevenue());
|
||||||
entity.setContactName(request.getContactName());
|
|
||||||
entity.setContactEmail(request.getContactEmail());
|
|
||||||
entity.setHub(userEntity.getHub());
|
entity.setHub(userEntity.getHub());
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
@@ -163,8 +159,8 @@ public class CompanyDao {
|
|||||||
response.setProvince(entity.getProvince());
|
response.setProvince(entity.getProvince());
|
||||||
response.setCap(entity.getCap());
|
response.setCap(entity.getCap());
|
||||||
response.setCountry(entity.getCountry());
|
response.setCountry(entity.getCountry());
|
||||||
response.setPec(entity.getPec());
|
response.setPec(userWithCompanyEntity.getPec());
|
||||||
response.setEmail(entity.getEmail());
|
response.setEmail(userWithCompanyEntity.getEmail());
|
||||||
response.setNumberOfEmployees(entity.getNumberOfEmployees());
|
response.setNumberOfEmployees(entity.getNumberOfEmployees());
|
||||||
response.setAnnualRevenue(entity.getAnnualRevenue());
|
response.setAnnualRevenue(entity.getAnnualRevenue());
|
||||||
if(userWithCompanyEntity!=null) {
|
if(userWithCompanyEntity!=null) {
|
||||||
@@ -172,8 +168,8 @@ public class CompanyDao {
|
|||||||
}
|
}
|
||||||
response.setCreatedDate(entity.getCreatedDate());
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
response.setUpdatedDate(entity.getUpdatedDate());
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
response.setContactName(entity.getContactName());
|
response.setContactName(userWithCompanyEntity.getContactName());
|
||||||
response.setContactEmail(entity.getContactEmail());
|
response.setContactEmail(userWithCompanyEntity.getContactEmail());
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,12 +187,8 @@ public class CompanyDao {
|
|||||||
setIfUpdated(companyEntity::getProvince, companyEntity::setProvince, companyRequest.getProvince());
|
setIfUpdated(companyEntity::getProvince, companyEntity::setProvince, companyRequest.getProvince());
|
||||||
setIfUpdated(companyEntity::getCap, companyEntity::setCap, companyRequest.getCap());
|
setIfUpdated(companyEntity::getCap, companyEntity::setCap, companyRequest.getCap());
|
||||||
setIfUpdated(companyEntity::getCountry, companyEntity::setCountry, companyRequest.getCountry());
|
setIfUpdated(companyEntity::getCountry, companyEntity::setCountry, companyRequest.getCountry());
|
||||||
setIfUpdated(companyEntity::getPec, companyEntity::setPec, companyRequest.getPec());
|
|
||||||
setIfUpdated(companyEntity::getEmail, companyEntity::setEmail, companyRequest.getEmail());
|
|
||||||
setIfUpdated(companyEntity::getNumberOfEmployees, companyEntity::setNumberOfEmployees, companyRequest.getNumberOfEmployees());
|
setIfUpdated(companyEntity::getNumberOfEmployees, companyEntity::setNumberOfEmployees, companyRequest.getNumberOfEmployees());
|
||||||
setIfUpdated(companyEntity::getAnnualRevenue, companyEntity::setAnnualRevenue, companyRequest.getAnnualRevenue());
|
setIfUpdated(companyEntity::getAnnualRevenue, companyEntity::setAnnualRevenue, companyRequest.getAnnualRevenue());
|
||||||
setIfUpdated(companyEntity::getContactName, companyEntity::setContactName, companyRequest.getContactName());
|
|
||||||
setIfUpdated(companyEntity::getContactEmail, companyEntity::setContactEmail, companyRequest.getContactEmail());
|
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(companyRequest.getVatNumber())) {
|
if(StringUtils.isNotBlank(companyRequest.getVatNumber())) {
|
||||||
CompanyEntity existingCompany = companyRepository.findByVatNumberAndHubId(companyRequest.getVatNumber(), userEntity.getHub().getId());
|
CompanyEntity existingCompany = companyRepository.findByVatNumberAndHubId(companyRequest.getVatNumber(), userEntity.getHub().getId());
|
||||||
|
|||||||
@@ -92,8 +92,10 @@ public class EmailNotificationDao {
|
|||||||
|
|
||||||
Optional<ApplicationEvaluationEntity> applicationEvaluationEntity = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationEntity.getId());
|
Optional<ApplicationEvaluationEntity> applicationEvaluationEntity = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationEntity.getId());
|
||||||
CompanyEntity company = companyService.validateCompany(applicationEntity.getCompanyId());
|
CompanyEntity company = companyService.validateCompany(applicationEntity.getCompanyId());
|
||||||
String companyEmail = company.getEmail();
|
|
||||||
String contactEmail = company.getContactEmail();
|
UserWithCompanyEntity userWithCompany=companyService.getUserWithCompany(userEntity.getId(),company.getId());
|
||||||
|
String companyEmail = userWithCompany.getEmail();
|
||||||
|
String contactEmail = userWithCompany.getContactEmail();
|
||||||
|
|
||||||
if (companyEmail != null && !companyEmail.isEmpty()) {
|
if (companyEmail != null && !companyEmail.isEmpty()) {
|
||||||
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.COMPANY,company.getId() ,
|
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.COMPANY,company.getId() ,
|
||||||
|
|||||||
Reference in New Issue
Block a user