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());
}
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());
}
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);
}
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());
}
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);
}
}
Aggregations