use of com.axelor.auth.db.User in project axelor-open-suite by axelor.
the class ExpenseController method showSubordinateExpenses.
public void showSubordinateExpenses(ActionRequest request, ActionResponse response) {
User user = AuthUtils.getUser();
Company activeCompany = user.getActiveCompany();
ActionViewBuilder actionView = ActionView.define(I18n.get("Expenses to be Validated by your subordinates")).model(Expense.class.getName()).add("grid", "expense-grid").add("form", "expense-form").param("search-filters", "expense-filters");
String domain = "self.user.employee.managerUser.employee.managerUser = :_user AND self.company = :_activeCompany AND self.statusSelect = 2";
long nbExpenses = Query.of(Expense.class).filter(domain).bind("_user", user).bind("_activeCompany", activeCompany).count();
if (nbExpenses == 0) {
response.setNotify(I18n.get("No expense to be validated by your subordinates"));
} else {
response.setView(actionView.domain(domain).context("_user", user).context("_activeCompany", activeCompany).map());
}
}
use of com.axelor.auth.db.User in project axelor-open-suite by axelor.
the class TimesheetReportServiceImpl method getTotalWorksHours.
private BigDecimal getTotalWorksHours(User user, LocalDate date, boolean isPublicHoliday, BigDecimal dailyWorkingHours) throws AxelorException {
Employee employee = user.getEmployee();
BigDecimal worksHour = employeeService.getDaysWorksInPeriod(employee, date, date).multiply(employee.getDailyWorkHours()).setScale(2, RoundingMode.HALF_UP);
if (isPublicHoliday) {
worksHour = worksHour.add(dailyWorkingHours);
}
double extraHours = extraHoursLineRepository.all().filter("self.user = ? AND self.date = ? AND (self.extraHours.statusSelect = ? OR self.extraHours.statusSelect = ?)", user, date, ExtraHoursRepository.STATUS_VALIDATED, ExtraHoursRepository.STATUS_CONFIRMED).fetchStream().mapToDouble(ehl -> Double.parseDouble(ehl.getQty().toString())).sum();
worksHour = worksHour.add(new BigDecimal(extraHours));
return worksHour.setScale(2, RoundingMode.HALF_UP);
}
use of com.axelor.auth.db.User in project axelor-open-suite by axelor.
the class TimesheetReportServiceImpl method getTotalWeekWorksHours.
private BigDecimal getTotalWeekWorksHours(User user, LocalDate fromDate, LocalDate toDate, BigDecimal publicHolidays) throws AxelorException {
Employee employee = user.getEmployee();
BigDecimal worksHour = employeeService.getDaysWorksInPeriod(employee, fromDate, toDate).multiply(employee.getDailyWorkHours()).setScale(2, RoundingMode.HALF_UP);
worksHour = worksHour.add(publicHolidays.multiply(employee.getDailyWorkHours()));
double extraHours = extraHoursLineRepository.all().filter("self.user = ? AND (self.date BETWEEN ? AND ?) AND (self.extraHours.statusSelect = ? OR self.extraHours.statusSelect = ?)", user, fromDate, toDate, ExtraHoursRepository.STATUS_VALIDATED, ExtraHoursRepository.STATUS_CONFIRMED).fetchStream().mapToDouble(ehl -> Double.parseDouble(ehl.getQty().toString())).sum();
worksHour = worksHour.add(new BigDecimal(extraHours));
return worksHour.setScale(2, RoundingMode.HALF_UP);
}
use of com.axelor.auth.db.User in project axelor-open-suite by axelor.
the class TimesheetController method validateTimesheet.
public void validateTimesheet(ActionRequest request, ActionResponse response) {
User user = AuthUtils.getUser();
Employee employee = user.getEmployee();
ActionViewBuilder actionView = ActionView.define(I18n.get("Timesheets to Validate")).model(Timesheet.class.getName()).add("grid", "timesheet-validate-grid").add("form", "timesheet-form").param("search-filters", "timesheet-filters").context("todayDate", Beans.get(AppBaseService.class).getTodayDate(user.getActiveCompany()));
Beans.get(HRMenuValidateService.class).createValidateDomain(user, employee, actionView);
response.setView(actionView.map());
}
use of com.axelor.auth.db.User in project axelor-open-suite by axelor.
the class TimesheetController method allTimesheet.
public void allTimesheet(ActionRequest request, ActionResponse response) {
User user = AuthUtils.getUser();
Employee employee = user.getEmployee();
ActionViewBuilder actionView = ActionView.define(I18n.get("Timesheets")).model(Timesheet.class.getName()).add("grid", "all-timesheet-grid").add("form", "timesheet-form").param("search-filters", "timesheet-filters");
if (employee == null || !employee.getHrManager()) {
if (employee == null || employee.getManagerUser() == null) {
actionView.domain("self.user = :_user OR self.user.employee.managerUser = :_user").context("_user", user);
} else {
actionView.domain("self.user.employee.managerUser = :_user").context("_user", user);
}
}
response.setView(actionView.map());
}
Aggregations