|
|
@@ -61,6 +61,10 @@ public class CustomerService {
|
|
|
public Page<Customer> all(String search, PageQuery pageQuery, Integer customerType, List<Long> saleId, Integer pageType, CustomerSource customerSource, CustomerIndustry industry) {
|
|
|
return customerRepo.findAll((Specification<Customer>) (root, criteriaQuery, criteriaBuilder) -> {
|
|
|
List<javax.persistence.criteria.Predicate> predicates = toPredicates(pageQuery, Customer.class, root, criteriaQuery, criteriaBuilder);
|
|
|
+ if (SecurityUtils.getAuthenticatedUser().getCompanyId() != null) {
|
|
|
+ predicates.add(criteriaBuilder
|
|
|
+ .equal(root.get("companyId"), SecurityUtils.getAuthenticatedUser().getCompanyId()));
|
|
|
+ }
|
|
|
if (customerType != null) {
|
|
|
List<Contract> expireContract = contractRepo.queryExpired(LocalDateTime.now(), LocalDateTime.now()
|
|
|
.plusDays(customerType));
|
|
|
@@ -102,6 +106,9 @@ public class CustomerService {
|
|
|
}
|
|
|
|
|
|
public Customer save(Customer customer) {
|
|
|
+ if (SecurityUtils.getAuthenticatedUser().getCompanyId() != null) {
|
|
|
+ customer.setCompanyId(SecurityUtils.getAuthenticatedUser().getCompanyId());
|
|
|
+ }
|
|
|
if (StringUtils.isEmpty(customer.getCustomerNumber())) {
|
|
|
customer.setCustomerNumber(customerRepo.nextCustomerNumber());
|
|
|
}
|