Search in sources :

Example 61 with Employee

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

the class EmploymentContractService method employmentContractExportSilae.

public void employmentContractExportSilae(EmploymentContract employmentContract, List<String[]> list) {
    String[] item = new String[21];
    item[0] = employmentContract.getId().toString();
    item[1] = employmentContract.getStartDate() == null ? "" : employmentContract.getStartDate().toString();
    item[2] = employmentContract.getEndDate() == null ? "" : employmentContract.getEndDate().toString();
    Employee employee = employmentContract.getEmployee();
    item[4] = employee.getMaritalName();
    Partner contactPartner = employee.getContactPartner();
    if (contactPartner != null) {
        item[3] = contactPartner.getName();
        item[5] = contactPartner.getFirstName();
        Address mainAddress = contactPartner.getMainAddress();
        if (mainAddress != null) {
            item[6] = mainAddress.getAddressL4();
            item[7] = mainAddress.getAddressL2();
            item[8] = mainAddress.getZip();
            if (mainAddress.getCity() != null) {
                item[9] = mainAddress.getCity().getName();
            } else {
                item[9] = "";
            }
        }
        item[10] = contactPartner.getMobilePhone();
        item[11] = contactPartner.getFixedPhone();
        item[12] = contactPartner.getEmailAddress() == null ? "" : contactPartner.getEmailAddress().getAddress();
    }
    item[13] = employee.getBirthDate() == null ? "" : employee.getBirthDate().toString();
    Department birthDepartment = employee.getDepartmentOfBirth();
    if (birthDepartment != null) {
        item[14] = birthDepartment.getName();
        item[16] = !birthDepartment.getCode().equals("99") ? "FR - FRANCE" : "Oui";
    }
    item[15] = employee.getCityOfBirth() == null ? "" : employee.getCityOfBirth().getName();
    item[17] = employee.getSocialSecurityNumber();
    item[18] = employmentContract.getPayCompany().getName();
    item[19] = employmentContract.getContractType() == null ? "" : employmentContract.getContractType().getId().toString();
    item[20] = employee.getMaidenName();
    list.add(item);
}
Also used : Department(com.axelor.apps.base.db.Department) Employee(com.axelor.apps.hr.db.Employee) Address(com.axelor.apps.base.db.Address) Partner(com.axelor.apps.base.db.Partner)

Example 62 with Employee

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

the class HRMenuTagService method countRecordsTag.

/**
 * @param modelConcerned
 * @param status 1 : Draft 2 : Confirmed 3 : Validated 4 : Refused 5 : Canceled
 * @return The number of records
 */
public <T extends Model> String countRecordsTag(Class<T> modelConcerned, int status) {
    User user = AuthUtils.getUser();
    Employee employee = user.getEmployee();
    String filter = "self.statusSelect = :_statusSelect";
    if (employee != null && employee.getHrManager()) {
        return Long.toString(JPA.all(modelConcerned).filter(filter).bind("_statusSelect", status).count());
    } else {
        filter += (employee == null || employee.getManagerUser() == null) ? " AND (self.user.id = :_userId OR self.user.employee.managerUser.id = :_userId)" : " AND self.user.employee.managerUser.id = :_userId";
        return Long.toString(JPA.all(modelConcerned).filter(filter).bind("_userId", user.getId()).bind("_statusSelect", status).count());
    }
}
Also used : User(com.axelor.auth.db.User) Employee(com.axelor.apps.hr.db.Employee)

Example 63 with Employee

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

the class BatchLeaveManagementReset method resetLeaveManagementLines.

public void resetLeaveManagementLines(List<Employee> employeeList) {
    for (Employee employee : employeeList.stream().filter(Objects::nonNull).collect(Collectors.toList())) {
        employee = employeeRepository.find(employee.getId());
        if (EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee)) {
            continue;
        }
        try {
            resetLeaveManagement(employee);
        } catch (AxelorException e) {
            TraceBackService.trace(e, ExceptionOriginRepository.LEAVE_MANAGEMENT, batch.getId());
            incrementAnomaly();
            if (e.getCategory() == TraceBackRepository.CATEGORY_NO_VALUE) {
                noValueAnomaly++;
            }
            if (e.getCategory() == TraceBackRepository.CATEGORY_CONFIGURATION_ERROR) {
                confAnomaly++;
            }
        } finally {
            total++;
            JPA.clear();
        }
    }
}
Also used : AxelorException(com.axelor.exception.AxelorException) Employee(com.axelor.apps.hr.db.Employee)

Example 64 with Employee

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

the class BatchTimesheetReminder method getEmployeesWithoutRecentTimesheet.

private List<Employee> getEmployeesWithoutRecentTimesheet(Company company) {
    LocalDate now = appBaseService.getTodayDate(company);
    long daysBeforeReminder = batch.getHrBatch().getDaysBeforeReminder();
    List<Employee> employees = employeeRepository.all().filter("self.timesheetReminder = 't' AND self.mainEmploymentContract.payCompany = :companyId").bind("companyId", batch.getHrBatch().getCompany().getId()).fetch();
    employees.removeIf(employee -> hasRecentTimesheet(now, daysBeforeReminder, employee) || EmployeeHRRepository.isEmployeeFormerNewOrArchived(employee));
    return employees;
}
Also used : Employee(com.axelor.apps.hr.db.Employee) LocalDate(java.time.LocalDate)

Example 65 with Employee

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

the class EmployeeHRRepository method copy.

@Override
public Employee copy(Employee entity, boolean deep) {
    entity.setContactPartner(null);
    entity.setFixedProPhone(null);
    entity.setMobileProPhone(null);
    entity.setPhoneAtCustomer(null);
    entity.setEmergencyContact(null);
    entity.setEmergencyNumber(null);
    entity.setHireDate(null);
    entity.setSeniorityDate(null);
    entity.setProfitSharingBeneficiary(null);
    entity.setMainEmploymentContract(null);
    entity.setExportCode(null);
    entity.setEmploymentContractList(null);
    entity.setLunchVoucherAdvanceList(null);
    entity.setEmployeeAdvanceList(null);
    entity.setKilometricLogList(null);
    entity.setLeaveLineList(null);
    Employee copy = super.copy(entity, deep);
    return copy;
}
Also used : Employee(com.axelor.apps.hr.db.Employee)

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