Updated code

This commit is contained in:
nisha
2024-12-19 17:58:44 +05:30
parent a30637ddaa
commit 5c7f96574b
3 changed files with 20 additions and 25 deletions

View File

@@ -926,7 +926,8 @@ public class ApplicationDao {
private void sendMailToUserAndCompany(UserEntity userEntity, ApplicationEntity applicationEntity) {
CallEntity call =applicationEntity.getCall();
CompanyEntity company=companyService.validateCompany(applicationEntity.getCompanyId());
ProtocolEntity protocol = applicationEntity.getProtocol();
UserWithCompanyEntity userWithCompany=companyService.getUserWithCompany(userEntity.getId(),company.getId());
ProtocolEntity protocol= applicationEntity.getProtocol();
HubEntity hub = hubService.valdateHub(applicationEntity.getHubId());
SystemEmailTemplateResponse systemEmailTemplateResponse = systemEmailTemplatesService
.retrieveTemplateByTypeAndCall(SystemEmailTemplatesEntityTypeEnum.APPLICATION_SUBMISSION_TO_USER_AND_COMPANY,
@@ -957,8 +958,8 @@ public class ApplicationDao {
emailNotificationDao.sendMail(hub.getId(), subject, body, List.of(email),emailLogRequest);
List<String> recipientEmails = new ArrayList<>();
// recipientEmails.add(email);
String companyEmail = company.getEmail();
String contactEmail = company.getContactEmail();
String companyEmail = userWithCompany.getEmail();
String contactEmail = userWithCompany.getContactEmail();
if (companyEmail != null && !companyEmail.isEmpty()) {
recipientEmails.add(companyEmail);

View File

@@ -67,7 +67,7 @@ public class CompanyDao {
if (existingCompany != null) {
UserWithCompanyEntity existingRelation = userWithCompanyRepository.findByUserIdAndCompanyIdAndIsDeletedFalse(userEntity.getId(), existingCompany.getId()).orElse(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. **/
loggingUtil.addVersionHistory(
@@ -84,7 +84,7 @@ public class CompanyDao {
/** 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());
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, companyEntity, companyRequest.getIsLegalRepresentant(),companyRequest.getVatCheckResponse());
userWithCompanyEntity = createUserWithCompanyRelation(userEntity, companyEntity, companyRequest.getIsLegalRepresentant(),companyRequest);
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();
if (userEntity.getBeneficiary() != null) {
@@ -118,11 +118,11 @@ public class CompanyDao {
userWithCompanyEntity.setCompanyId(companyEntity.getId());
userWithCompanyEntity.setUserId(userEntity.getId());
userWithCompanyEntity.setIsLegalRepresentant(isLegalRepresentant);
userWithCompanyEntity.setEmail(companyEntity.getEmail());
userWithCompanyEntity.setPec(companyEntity.getPec());
userWithCompanyEntity.setContactName(companyEntity.getContactName());
userWithCompanyEntity.setContactEmail(companyEntity.getContactEmail());
userWithCompanyEntity.setJson(Utils.convertMapIntoJsonString(vatCheckResponse) );
userWithCompanyEntity.setEmail(companyRequest.getEmail());
userWithCompanyEntity.setPec(companyRequest.getPec());
userWithCompanyEntity.setContactName(companyRequest.getContactName());
userWithCompanyEntity.setContactEmail(companyRequest.getContactEmail());
userWithCompanyEntity.setJson(Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) );
UserWithCompanyEntity userWithCompany = userWithCompanyRepository.save(userWithCompanyEntity);
/** 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.setCap(request.getCap());
entity.setCountry(request.getCountry());
entity.setPec(request.getPec());
entity.setEmail(request.getEmail());
entity.setNumberOfEmployees(request.getNumberOfEmployees());
entity.setAnnualRevenue(request.getAnnualRevenue());
entity.setContactName(request.getContactName());
entity.setContactEmail(request.getContactEmail());
entity.setHub(userEntity.getHub());
return entity;
}
@@ -163,8 +159,8 @@ public class CompanyDao {
response.setProvince(entity.getProvince());
response.setCap(entity.getCap());
response.setCountry(entity.getCountry());
response.setPec(entity.getPec());
response.setEmail(entity.getEmail());
response.setPec(userWithCompanyEntity.getPec());
response.setEmail(userWithCompanyEntity.getEmail());
response.setNumberOfEmployees(entity.getNumberOfEmployees());
response.setAnnualRevenue(entity.getAnnualRevenue());
if(userWithCompanyEntity!=null) {
@@ -172,8 +168,8 @@ public class CompanyDao {
}
response.setCreatedDate(entity.getCreatedDate());
response.setUpdatedDate(entity.getUpdatedDate());
response.setContactName(entity.getContactName());
response.setContactEmail(entity.getContactEmail());
response.setContactName(userWithCompanyEntity.getContactName());
response.setContactEmail(userWithCompanyEntity.getContactEmail());
return response;
}
@@ -191,12 +187,8 @@ public class CompanyDao {
setIfUpdated(companyEntity::getProvince, companyEntity::setProvince, companyRequest.getProvince());
setIfUpdated(companyEntity::getCap, companyEntity::setCap, companyRequest.getCap());
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::getAnnualRevenue, companyEntity::setAnnualRevenue, companyRequest.getAnnualRevenue());
setIfUpdated(companyEntity::getContactName, companyEntity::setContactName, companyRequest.getContactName());
setIfUpdated(companyEntity::getContactEmail, companyEntity::setContactEmail, companyRequest.getContactEmail());
if(StringUtils.isNotBlank(companyRequest.getVatNumber())) {
CompanyEntity existingCompany = companyRepository.findByVatNumberAndHubId(companyRequest.getVatNumber(), userEntity.getHub().getId());

View File

@@ -92,8 +92,10 @@ public class EmailNotificationDao {
Optional<ApplicationEvaluationEntity> applicationEvaluationEntity = applicationEvaluationRepository.findByApplicationIdAndIsDeletedFalse(applicationEntity.getId());
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()) {
EmailLogRequest emailLogRequest = emailLogDao.createEmailLogRequest(systemEmailTemplateResponse.getEmailScenario(), RecipientTypeEnum.COMPANY,company.getId() ,