Added json field in company

This commit is contained in:
nisha
2024-12-04 20:02:45 +05:30
parent 346b550466
commit dcaa769903
13 changed files with 71 additions and 24 deletions

View File

@@ -2,6 +2,7 @@ package net.gepafin.tendermanagement.dao;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.entities.*;
@@ -78,6 +79,8 @@ public class CompanyDao {
} else {
validateCompany(userEntity, companyRequest);
CompanyEntity companyEntity = convertCompanyRequestToCompanyEntity(userEntity, companyRequest);
companyEntity.setJson(Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) );
CompanyEntity companyData = companyRepository.save(companyEntity);
/** This code is responsible for adding a version history log for "creating company" operation. **/
@@ -178,7 +181,6 @@ public class CompanyDao {
CompanyEntity oldCompanyData = Utils.getClonedEntityForData(companyEntity);
setIfUpdated(companyEntity::getCompanyName, companyEntity::setCompanyName, companyRequest.getCompanyName());
setIfUpdated(companyEntity::getVatNumber, companyEntity::setVatNumber, companyRequest.getVatNumber());
setIfUpdated(companyEntity::getCodiceFiscale, companyEntity::setCodiceFiscale, companyRequest.getCodiceFiscale());
setIfUpdated(companyEntity::getAddress, companyEntity::setAddress, companyRequest.getAddress());
setIfUpdated(companyEntity::getPhoneNumber, companyEntity::setPhoneNumber, companyRequest.getPhoneNumber());
@@ -192,6 +194,17 @@ public class CompanyDao {
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());
if(existingCompany!=null){
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.VATNUMBER_ALREADY_EXISTS));
}
companyEntity.setVatNumber(companyRequest.getVatNumber());
String responseJson = companyRequest.getVatCheckResponse() != null ? Utils.convertMapIntoJsonString(companyRequest.getVatCheckResponse()) : null;
setIfUpdated(companyEntity::getJson, companyEntity::setJson, responseJson);
}
companyRepository.save(companyEntity);
/** This code is responsible for adding a version history log for the "Update company" operation. **/