Search in sources :

Example 6 with Timesheet

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

the class TimesheetController method updateTimeLoggingPreference.

/**
 * Called from timesheet form, on user change. Call {@link
 * TimesheetService#updateTimeLoggingPreference(Timesheet)} to update the timesheet, and update
 * the dummy field $periodTotalConvert
 *
 * @param request
 * @param response
 */
public void updateTimeLoggingPreference(ActionRequest request, ActionResponse response) {
    try {
        Timesheet timesheet = request.getContext().asType(Timesheet.class);
        Beans.get(TimesheetService.class).updateTimeLoggingPreference(timesheet);
        response.setAttr("$periodTotalConvert", "hidden", false);
        response.setAttr("$periodTotalConvert", "value", Beans.get(TimesheetLineService.class).computeHoursDuration(timesheet, timesheet.getPeriodTotal(), false));
        response.setAttr("$periodTotalConvert", "title", Beans.get(TimesheetService.class).getPeriodTotalConvertTitle(timesheet));
        response.setValue("timeLoggingPreferenceSelect", timesheet.getTimeLoggingPreferenceSelect());
        response.setValue("timesheetLineList", timesheet.getTimesheetLineList());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Timesheet(com.axelor.apps.hr.db.Timesheet) TimesheetService(com.axelor.apps.hr.service.timesheet.TimesheetService) AxelorException(com.axelor.exception.AxelorException)

Example 7 with Timesheet

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

the class TimesheetController method draft.

/**
 * Called from timesheet form view, on clicking "return to draft" button. <br>
 * Call {@link TimesheetService#draft(Timesheet)}
 *
 * @param request
 * @param response
 */
public void draft(ActionRequest request, ActionResponse response) {
    try {
        Timesheet timesheet = request.getContext().asType(Timesheet.class);
        timesheet = Beans.get(TimesheetRepository.class).find(timesheet.getId());
        Beans.get(TimesheetService.class).draft(timesheet);
        response.setReload(true);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Timesheet(com.axelor.apps.hr.db.Timesheet) TimesheetService(com.axelor.apps.hr.service.timesheet.TimesheetService) AxelorException(com.axelor.exception.AxelorException)

Example 8 with Timesheet

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

the class TimesheetController method printTimesheet.

public void printTimesheet(ActionRequest request, ActionResponse response) throws AxelorException {
    Timesheet timesheet = request.getContext().asType(Timesheet.class);
    String name = I18n.get("Timesheet") + " " + timesheet.getFullName().replace("/", "-");
    String fileLink = ReportFactory.createReport(IReport.TIMESHEET, name).addParam("TimesheetId", timesheet.getId()).addParam("Timezone", timesheet.getCompany() != null ? timesheet.getCompany().getTimezone() : null).addParam("Locale", ReportSettings.getPrintingLocale(null)).toAttach(timesheet).generate().getFileLink();
    logger.debug("Printing {}", name);
    response.setView(ActionView.define(name).add("html", fileLink).map());
}
Also used : Timesheet(com.axelor.apps.hr.db.Timesheet)

Example 9 with Timesheet

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

the class TimesheetController method timesheetPeriodTotalController.

public void timesheetPeriodTotalController(ActionRequest request, ActionResponse response) {
    try {
        Timesheet timesheet = request.getContext().asType(Timesheet.class);
        TimesheetService timesheetService = Beans.get(TimesheetService.class);
        BigDecimal periodTotal = timesheetService.computePeriodTotal(timesheet);
        response.setAttr("periodTotal", "value", periodTotal);
        response.setAttr("$periodTotalConvert", "hidden", false);
        response.setAttr("$periodTotalConvert", "value", Beans.get(TimesheetLineService.class).computeHoursDuration(timesheet, periodTotal, false));
        response.setAttr("$periodTotalConvert", "title", timesheetService.getPeriodTotalConvertTitle(timesheet));
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Timesheet(com.axelor.apps.hr.db.Timesheet) TimesheetService(com.axelor.apps.hr.service.timesheet.TimesheetService) BigDecimal(java.math.BigDecimal) AxelorException(com.axelor.exception.AxelorException)

Example 10 with Timesheet

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

the class TimesheetLineController method setDuration.

/**
 * Called from timesheet editor Get the timesheet corresponding to timesheetline and call {@link
 * TimesheetLineService#computeHoursDuration(Timesheet, BigDecimal, boolean)}
 *
 * @param request
 * @param response
 */
public void setDuration(ActionRequest request, ActionResponse response) {
    try {
        TimesheetLine timesheetLine = request.getContext().asType(TimesheetLine.class);
        Timesheet timesheet;
        Context parent = request.getContext().getParent();
        if (parent != null && parent.getContextClass().equals(Timesheet.class)) {
            timesheet = parent.asType(Timesheet.class);
        } else {
            timesheet = timesheetLine.getTimesheet();
        }
        BigDecimal duration = Beans.get(TimesheetLineService.class).computeHoursDuration(timesheet, timesheetLine.getHoursDuration(), false);
        response.setValue(DURATION_FIELD, duration);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : Context(com.axelor.rpc.Context) TimesheetLine(com.axelor.apps.hr.db.TimesheetLine) Timesheet(com.axelor.apps.hr.db.Timesheet) TimesheetLineService(com.axelor.apps.hr.service.timesheet.TimesheetLineService) BigDecimal(java.math.BigDecimal)

Aggregations

Timesheet (com.axelor.apps.hr.db.Timesheet)29 AxelorException (com.axelor.exception.AxelorException)14 TimesheetService (com.axelor.apps.hr.service.timesheet.TimesheetService)13 TimesheetLine (com.axelor.apps.hr.db.TimesheetLine)6 Message (com.axelor.apps.message.db.Message)6 BigDecimal (java.math.BigDecimal)6 Employee (com.axelor.apps.hr.db.Employee)5 MessageServiceBaseImpl (com.axelor.apps.base.service.message.MessageServiceBaseImpl)4 TimesheetLineService (com.axelor.apps.hr.service.timesheet.TimesheetLineService)4 Transactional (com.google.inject.persist.Transactional)4 Company (com.axelor.apps.base.db.Company)3 TimesheetRepository (com.axelor.apps.hr.db.repo.TimesheetRepository)3 User (com.axelor.auth.db.User)3 Context (com.axelor.rpc.Context)3 LocalDate (java.time.LocalDate)3 Product (com.axelor.apps.base.db.Product)2 OperationOrderTimesheetService (com.axelor.apps.businessproduction.service.OperationOrderTimesheetService)2 TimesheetLineRepository (com.axelor.apps.hr.db.repo.TimesheetLineRepository)2 Project (com.axelor.apps.project.db.Project)2 IOException (java.io.IOException)2