|
|
|
@@ -122,10 +122,40 @@ public class CompanyDao {
|
|
|
|
userWithCompanyEntity.setPec(companyRequest.getPec());
|
|
|
|
userWithCompanyEntity.setPec(companyRequest.getPec());
|
|
|
|
userWithCompanyEntity.setContactName(companyRequest.getContactName());
|
|
|
|
userWithCompanyEntity.setContactName(companyRequest.getContactName());
|
|
|
|
userWithCompanyEntity.setContactEmail(companyRequest.getContactEmail());
|
|
|
|
userWithCompanyEntity.setContactEmail(companyRequest.getContactEmail());
|
|
|
|
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. **/
|
|
|
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(userWithCompany).build());
|
|
|
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder().request(request).actionType(VersionActionTypeEnum.INSERT).oldData(null).newData(userWithCompany).build());
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(companyEntity.getJson())) {
|
|
|
|
|
|
|
|
companyEntity.setJson(Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()));
|
|
|
|
|
|
|
|
Map<String, Object> vatCheckResponse = companyRequest.getVatCheckResponse();
|
|
|
|
|
|
|
|
Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data");
|
|
|
|
|
|
|
|
if (data != null) {
|
|
|
|
|
|
|
|
if (data.containsKey("dettaglio")) {
|
|
|
|
|
|
|
|
Map<String, Object> dettaglio = (Map<String, Object>) data.get("dettaglio");
|
|
|
|
|
|
|
|
if (dettaglio != null) {
|
|
|
|
|
|
|
|
if (dettaglio.containsKey("codice_ateco")) {
|
|
|
|
|
|
|
|
Object codiceAtecoObj = dettaglio.get("codice_ateco");
|
|
|
|
|
|
|
|
String codiceAteco = (codiceAtecoObj != null) ? codiceAtecoObj.toString() : null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (codiceAteco != null) {
|
|
|
|
|
|
|
|
companyEntity.setCodiceAteco(codiceAteco);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
companyEntity = companyRepository.save(companyEntity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** This code is responsible for adding a version history log for "updating company json field" operation. **/
|
|
|
|
|
|
|
|
loggingUtil.addVersionHistory(VersionHistoryRequest.builder()
|
|
|
|
|
|
|
|
.request(request)
|
|
|
|
|
|
|
|
.actionType(VersionActionTypeEnum.INSERT)
|
|
|
|
|
|
|
|
.oldData(null)
|
|
|
|
|
|
|
|
.newData(companyEntity)
|
|
|
|
|
|
|
|
.build());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return userWithCompany;
|
|
|
|
return userWithCompany;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -143,6 +173,7 @@ public class CompanyDao {
|
|
|
|
entity.setNumberOfEmployees(request.getNumberOfEmployees());
|
|
|
|
entity.setNumberOfEmployees(request.getNumberOfEmployees());
|
|
|
|
entity.setAnnualRevenue(request.getAnnualRevenue());
|
|
|
|
entity.setAnnualRevenue(request.getAnnualRevenue());
|
|
|
|
entity.setHub(userEntity.getHub());
|
|
|
|
entity.setHub(userEntity.getHub());
|
|
|
|
|
|
|
|
entity.setJson(Utils.convertMapIntoJsonString(request.getVatCheckResponse()));
|
|
|
|
if (request.getVatCheckResponse() != null) {
|
|
|
|
if (request.getVatCheckResponse() != null) {
|
|
|
|
Map<String, Object> vatCheckResponse = request.getVatCheckResponse();
|
|
|
|
Map<String, Object> vatCheckResponse = request.getVatCheckResponse();
|
|
|
|
Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data");
|
|
|
|
Map<String, Object> data = (Map<String, Object>) vatCheckResponse.get("data");
|
|
|
|
@@ -226,10 +257,10 @@ public class CompanyDao {
|
|
|
|
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyId);
|
|
|
|
UserWithCompanyEntity userWithCompanyEntity = getUserWithCompany(userEntity.getId(), companyId);
|
|
|
|
//cloned entity for old data
|
|
|
|
//cloned entity for old data
|
|
|
|
UserWithCompanyEntity oldUserWithCompanyData = Utils.getClonedEntityForData(userWithCompanyEntity);
|
|
|
|
UserWithCompanyEntity oldUserWithCompanyData = Utils.getClonedEntityForData(userWithCompanyEntity);
|
|
|
|
if(StringUtils.isNotBlank(companyRequest.getVatNumber())) {
|
|
|
|
// if(StringUtils.isNotBlank(companyRequest.getVatNumber())) {
|
|
|
|
String responseJson = companyRequest.getVatCheckResponse() != null ? Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) : null;
|
|
|
|
// String responseJson = companyRequest.getVatCheckResponse() != null ? Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) : null;
|
|
|
|
setIfUpdated(userWithCompanyEntity::getJson, userWithCompanyEntity::setJson, responseJson);
|
|
|
|
// setIfUpdated(companyEntity::getJson, companyEntity::setJson, responseJson);
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
setIfUpdated(userWithCompanyEntity::getPec, userWithCompanyEntity::setPec, companyRequest.getPec());
|
|
|
|
setIfUpdated(userWithCompanyEntity::getPec, userWithCompanyEntity::setPec, companyRequest.getPec());
|
|
|
|
setIfUpdated(userWithCompanyEntity::getEmail, userWithCompanyEntity::setEmail, companyRequest.getEmail());
|
|
|
|
setIfUpdated(userWithCompanyEntity::getEmail, userWithCompanyEntity::setEmail, companyRequest.getEmail());
|
|
|
|
setIfUpdated(userWithCompanyEntity::getContactName, userWithCompanyEntity::setContactName, companyRequest.getContactName());
|
|
|
|
setIfUpdated(userWithCompanyEntity::getContactName, userWithCompanyEntity::setContactName, companyRequest.getContactName());
|
|
|
|
|