Search in sources :

Example 46 with Employee

use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.

the class TimesheetController method validateTimesheetLine.

public void validateTimesheetLine(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Employee employee = user.getEmployee();
    ActionViewBuilder actionView = ActionView.define(I18n.get("See timesheet lines")).model(TimesheetLine.class.getName()).add("grid", "timesheet-line-grid").add("form", "timesheet-line-form").context("todayDate", Beans.get(AppBaseService.class).getTodayDate(user.getActiveCompany()));
    Beans.get(TimesheetService.class).createValidateDomainTimesheetLine(user, employee, actionView);
    response.setView(actionView.map());
}
Also used : User(com.axelor.auth.db.User) Employee(com.axelor.apps.hr.db.Employee) TimesheetService(com.axelor.apps.hr.service.timesheet.TimesheetService) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 47 with Employee

use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.

the class ExpenseController method historicExpense.

public void historicExpense(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Employee employee = user.getEmployee();
    ActionViewBuilder actionView = ActionView.define(I18n.get("Historic colleague Expenses")).model(Expense.class.getName()).add("grid", "expense-grid").add("form", "expense-form").param("search-filters", "expense-filters");
    actionView.domain("self.company = :_activeCompany AND (self.statusSelect = 3 OR self.statusSelect = 4)").context("_activeCompany", user.getActiveCompany());
    if (employee == null || !employee.getHrManager()) {
        actionView.domain(actionView.get().getDomain() + " AND self.user.employee.managerUser = :_user").context("_user", user);
    }
    response.setView(actionView.map());
}
Also used : User(com.axelor.auth.db.User) Employee(com.axelor.apps.hr.db.Employee) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 48 with Employee

use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.

the class ExpenseController method computeKilometricExpense.

public void computeKilometricExpense(ActionRequest request, ActionResponse response) throws AxelorException {
    ExpenseLine expenseLine = request.getContext().asType(ExpenseLine.class);
    if (expenseLine.getKilometricAllowParam() == null || expenseLine.getDistance().compareTo(BigDecimal.ZERO) == 0 || expenseLine.getExpenseDate() == null) {
        return;
    }
    String userId;
    String userName;
    if (expenseLine.getExpense() != null) {
        setExpense(request, expenseLine);
    }
    Expense expense = expenseLine.getExpense();
    if (expense != null && expenseLine.getUser() != null) {
        userId = expense.getUser().getId().toString();
        userName = expense.getUser().getFullName();
    } else {
        userId = request.getContext().getParent().asType(Expense.class).getUser().getId().toString();
        userName = request.getContext().getParent().asType(Expense.class).getUser().getFullName();
    }
    Employee employee = Beans.get(EmployeeRepository.class).all().filter("self.user.id = ?1", userId).fetchOne();
    if (employee == null) {
        throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.LEAVE_USER_EMPLOYEE), userName);
    }
    BigDecimal amount = BigDecimal.ZERO;
    try {
        amount = Beans.get(KilometricService.class).computeKilometricExpense(expenseLine, employee);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
    response.setValue("totalAmount", amount);
    response.setValue("untaxedAmount", amount);
}
Also used : EmployeeRepository(com.axelor.apps.hr.db.repo.EmployeeRepository) AxelorException(com.axelor.exception.AxelorException) Employee(com.axelor.apps.hr.db.Employee) Expense(com.axelor.apps.hr.db.Expense) ExpenseLine(com.axelor.apps.hr.db.ExpenseLine) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException)

Example 49 with Employee

use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.

the class ExtraHoursController method historicExtraHours.

public void historicExtraHours(ActionRequest request, ActionResponse response) {
    User user = AuthUtils.getUser();
    Employee employee = user.getEmployee();
    ActionViewBuilder actionView = ActionView.define(I18n.get("Historic colleague extra hours")).model(ExtraHours.class.getName()).add("grid", "extra-hours-grid").add("form", "extra-hours-form").param("search-filters", "extra-hours-filters");
    actionView.domain("self.company = :_activeCompany AND (self.statusSelect = 3 OR self.statusSelect = 4)").context("_activeCompany", user.getActiveCompany());
    if (employee == null || !employee.getHrManager()) {
        actionView.domain(actionView.get().getDomain() + " AND self.user.employee.managerUser = :_user").context("_user", user);
    }
    response.setView(actionView.map());
}
Also used : User(com.axelor.auth.db.User) Employee(com.axelor.apps.hr.db.Employee) ActionViewBuilder(com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)

Example 50 with Employee

use of com.axelor.apps.hr.db.Employee in project axelor-open-suite by axelor.

the class LeaveController method leaveReasonToJustify.

/* Count Tags displayed on the menu items */
@Transactional
public void leaveReasonToJustify(ActionRequest request, ActionResponse response) {
    try {
        LeaveRequest leave = request.getContext().asType(LeaveRequest.class);
        Boolean leaveToJustify = leave.getToJustifyLeaveReason();
        LeaveLine leaveLine = null;
        if (!leaveToJustify) {
            return;
        }
        Company company = leave.getCompany();
        if (leave.getUser() == null) {
            return;
        }
        if (company == null) {
            company = leave.getUser().getActiveCompany();
        }
        if (company == null) {
            return;
        }
        Beans.get(HRConfigService.class).getLeaveReason(company.getHrConfig());
        Employee employee = leave.getUser().getEmployee();
        LeaveReason leaveReason = Beans.get(LeaveReasonRepository.class).find(company.getHrConfig().getToJustifyLeaveReason().getId());
        if (employee != null) {
            employee = Beans.get(EmployeeRepository.class).find(leave.getUser().getEmployee().getId());
            leaveLine = Beans.get(LeaveService.class).addLeaveReasonOrCreateIt(employee, leaveReason);
            response.setValue("leaveLine", leaveLine);
        }
    } catch (AxelorException e) {
        TraceBackService.trace(response, e);
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Company(com.axelor.apps.base.db.Company) LeaveReasonRepository(com.axelor.apps.hr.db.repo.LeaveReasonRepository) Employee(com.axelor.apps.hr.db.Employee) LeaveLine(com.axelor.apps.hr.db.LeaveLine) HRConfigService(com.axelor.apps.hr.service.config.HRConfigService) LeaveRequest(com.axelor.apps.hr.db.LeaveRequest) LeaveReason(com.axelor.apps.hr.db.LeaveReason) Transactional(com.google.inject.persist.Transactional)

Aggregations

Employee (com.axelor.apps.hr.db.Employee)71 AxelorException (com.axelor.exception.AxelorException)34 User (com.axelor.auth.db.User)28 Transactional (com.google.inject.persist.Transactional)21 BigDecimal (java.math.BigDecimal)18 ActionViewBuilder (com.axelor.meta.schema.actions.ActionView.ActionViewBuilder)14 LocalDate (java.time.LocalDate)13 TimesheetLine (com.axelor.apps.hr.db.TimesheetLine)9 EmployeeRepository (com.axelor.apps.hr.db.repo.EmployeeRepository)9 WeeklyPlanning (com.axelor.apps.base.db.WeeklyPlanning)8 Message (com.axelor.apps.message.db.Message)8 LeaveRequest (com.axelor.apps.hr.db.LeaveRequest)7 ArrayList (java.util.ArrayList)7 HashSet (java.util.HashSet)7 DayPlanning (com.axelor.apps.base.db.DayPlanning)6 LeaveLine (com.axelor.apps.hr.db.LeaveLine)6 LeaveService (com.axelor.apps.hr.service.leave.LeaveService)6 HashMap (java.util.HashMap)6 Map (java.util.Map)6 Company (com.axelor.apps.base.db.Company)5