Search in sources :

Example 31 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewServiceImpl method getTicketsOfUser.

/* Helpdesk Query */
@Override
public List<Filter> getTicketsOfUser(User user) {
    List<Filter> filters = new ArrayList<>();
    Filter filterFromPermission = security.getFilter(JpaSecurity.CAN_READ, Ticket.class);
    Filter filter = new JPQLFilter("self.customer.id = " + user.getPartner().getId() + " AND self.assignedToUser.id = " + user.getId());
    filters.add(filter);
    addPermissionFilter(filters, filterFromPermission);
    return filters;
}
Also used : Filter(com.axelor.rpc.filter.Filter) JPQLFilter(com.axelor.rpc.filter.JPQLFilter) ArrayList(java.util.ArrayList) JPQLFilter(com.axelor.rpc.filter.JPQLFilter)

Example 32 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewServiceImpl method getCompanyTicketsOfUser.

@Override
public List<Filter> getCompanyTicketsOfUser(User user) {
    List<Filter> filters = new ArrayList<>();
    Filter filterFromPermission = security.getFilter(JpaSecurity.CAN_READ, Ticket.class);
    Filter filter = new JPQLFilter("self.customer.id = " + user.getPartner().getId() + " AND self.assignedToUser.id = " + user.getActiveCompany().getId());
    filters.add(filter);
    addPermissionFilter(filters, filterFromPermission);
    return filters;
}
Also used : Filter(com.axelor.rpc.filter.Filter) JPQLFilter(com.axelor.rpc.filter.JPQLFilter) ArrayList(java.util.ArrayList) JPQLFilter(com.axelor.rpc.filter.JPQLFilter)

Example 33 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewServiceImpl method getRefundOfUser.

@Override
public List<Filter> getRefundOfUser(User user) {
    List<Filter> filters = new ArrayList<>();
    Filter filterFromPermission = security.getFilter(JpaSecurity.CAN_READ, Invoice.class);
    Filter filter = new JPQLFilter("self.partner.id = " + user.getPartner().getId() + " AND self.operationTypeSelect = " + InvoiceRepository.OPERATION_TYPE_CLIENT_REFUND);
    if (user.getActiveCompany() != null) {
        filter = Filter.and(filter, new JPQLFilter(" self.company.id = " + user.getActiveCompany().getId()));
    }
    filters.add(filter);
    addPermissionFilter(filters, filterFromPermission);
    return filters;
}
Also used : Filter(com.axelor.rpc.filter.Filter) JPQLFilter(com.axelor.rpc.filter.JPQLFilter) ArrayList(java.util.ArrayList) JPQLFilter(com.axelor.rpc.filter.JPQLFilter)

Example 34 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewServiceImpl method getTasksDueOfUser.

@Override
public List<Filter> getTasksDueOfUser(User user) {
    List<Filter> filters = new ArrayList<>();
    Filter filterFromPermission = security.getFilter(JpaSecurity.CAN_READ, ProjectTask.class);
    Filter filter = new JPQLFilter("self.status IN ('" + ProjectTaskRepository.STATUS_NEW + "','" + ProjectTaskRepository.STATUS_IN_PROGRESS + "') AND self.project.clientPartner.id = " + user.getPartner().getId() + " AND self.typeSelect = '" + ProjectTaskRepository.TYPE_TASK + "' AND self.taskEndDate  < current_date() ");
    if (user.getActiveCompany() != null) {
        filter = Filter.and(filter, new JPQLFilter(" self.project.company.id = " + user.getActiveCompany().getId()));
    }
    filters.add(filter);
    addPermissionFilter(filters, filterFromPermission);
    return filters;
}
Also used : Filter(com.axelor.rpc.filter.Filter) JPQLFilter(com.axelor.rpc.filter.JPQLFilter) ArrayList(java.util.ArrayList) JPQLFilter(com.axelor.rpc.filter.JPQLFilter)

Example 35 with Filter

use of com.axelor.rpc.filter.Filter in project axelor-open-suite by axelor.

the class ClientViewServiceImpl method getOverdueInvoicesOfUser.

/* Invoice Query */
@Override
public List<Filter> getOverdueInvoicesOfUser(User user) {
    List<Filter> filters = new ArrayList<>();
    Filter filterFromPermission = security.getFilter(JpaSecurity.CAN_READ, Invoice.class);
    Filter filter = new JPQLFilter("self.partner.id = " + user.getPartner().getId() + " AND self.dueDate < current_date() " + " AND self.amountRemaining != 0 AND self.statusSelect != " + InvoiceRepository.STATUS_DRAFT + " AND self.statusSelect != " + InvoiceRepository.STATUS_CANCELED);
    if (user.getActiveCompany() != null) {
        filter = Filter.and(filter, new JPQLFilter(" self.company.id = " + user.getActiveCompany().getId()));
    }
    filters.add(filter);
    addPermissionFilter(filters, filterFromPermission);
    return filters;
}
Also used : Filter(com.axelor.rpc.filter.Filter) JPQLFilter(com.axelor.rpc.filter.JPQLFilter) ArrayList(java.util.ArrayList) JPQLFilter(com.axelor.rpc.filter.JPQLFilter)

Aggregations

Filter (com.axelor.rpc.filter.Filter)47 JPQLFilter (com.axelor.rpc.filter.JPQLFilter)23 ArrayList (java.util.ArrayList)22 User (com.axelor.auth.db.User)21 ClientViewService (com.axelor.apps.portal.service.ClientViewService)19 StockMove (com.axelor.apps.stock.db.StockMove)7 Invoice (com.axelor.apps.account.db.Invoice)5 Ticket (com.axelor.apps.helpdesk.db.Ticket)5 SaleOrder (com.axelor.apps.sale.db.SaleOrder)5 ProjectTask (com.axelor.apps.project.db.ProjectTask)4 StockMoveRepository (com.axelor.apps.stock.db.repo.StockMoveRepository)3 HashMap (java.util.HashMap)3 AdvancedExport (com.axelor.apps.base.db.AdvancedExport)2 AdvancedExportService (com.axelor.apps.base.service.advancedExport.AdvancedExportService)2 Project (com.axelor.apps.project.db.Project)2 SaleOrderRepository (com.axelor.apps.sale.db.repo.SaleOrderRepository)2 JpaSecurity (com.axelor.db.JpaSecurity)2 Model (com.axelor.db.Model)2 I18n (com.axelor.i18n.I18n)2 Beans (com.axelor.inject.Beans)2