Search in sources :

Example 1 with ProjectTask

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

the class TimesheetServiceImpl method setProjectTaskTotalRealHrs.

@Override
@Transactional
public void setProjectTaskTotalRealHrs(List<TimesheetLine> timesheetLines, boolean isAdd) {
    for (TimesheetLine timesheetLine : timesheetLines) {
        ProjectTask projectTask = timesheetLine.getProjectTask();
        if (projectTask != null) {
            projectTask = projectTaskRepo.find(projectTask.getId());
            BigDecimal totalrealhrs = isAdd ? projectTask.getTotalRealHrs().add(timesheetLine.getHoursDuration()) : projectTask.getTotalRealHrs().subtract(timesheetLine.getHoursDuration());
            projectTask.setTotalRealHrs(totalrealhrs);
            projectTaskRepo.save(projectTask);
        }
    }
}
Also used : TimesheetLine(com.axelor.apps.hr.db.TimesheetLine) ProjectTask(com.axelor.apps.project.db.ProjectTask) BigDecimal(java.math.BigDecimal) Transactional(com.google.inject.persist.Transactional)

Example 2 with ProjectTask

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

the class ProjectHRRepository method save.

@Override
public Project save(Project project) {
    project = super.save(project);
    if (!Beans.get(AppHumanResourceService.class).isApp("employee")) {
        return project;
    }
    List<ProjectPlanningTime> projectPlanningTimeList = planningTimeRepo.all().filter("self.project = ?1 OR self.project.parentProject = ?1", project).fetch();
    project.setTotalPlannedHrs(projectPlanningTimeService.getProjectPlannedHrs(project));
    Project parentProject = project.getParentProject();
    if (parentProject != null) {
        parentProject.setTotalPlannedHrs(projectPlanningTimeService.getProjectPlannedHrs(parentProject));
    }
    if (projectPlanningTimeList != null) {
        for (ProjectPlanningTime planningTime : projectPlanningTimeList) {
            ProjectTask task = planningTime.getProjectTask();
            if (task != null) {
                task.setTotalPlannedHrs(projectPlanningTimeService.getTaskPlannedHrs(task));
            }
        }
    }
    return project;
}
Also used : Project(com.axelor.apps.project.db.Project) ProjectPlanningTime(com.axelor.apps.project.db.ProjectPlanningTime) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 3 with ProjectTask

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

the class ProjectPlanningTimeHRRepository method save.

@Override
public ProjectPlanningTime save(ProjectPlanningTime projectPlanningTime) {
    super.save(projectPlanningTime);
    Project project = projectPlanningTime.getProject();
    project.setTotalPlannedHrs(planningTimeService.getProjectPlannedHrs(project));
    Project parentProject = project.getParentProject();
    if (parentProject != null) {
        parentProject.setTotalPlannedHrs(planningTimeService.getProjectPlannedHrs(parentProject));
    }
    ProjectTask task = projectPlanningTime.getProjectTask();
    if (task != null) {
        task.setTotalPlannedHrs(planningTimeService.getTaskPlannedHrs(task));
    }
    return projectPlanningTime;
}
Also used : Project(com.axelor.apps.project.db.Project) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 4 with ProjectTask

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

the class ProjectTaskBusinessSupportServiceImpl method create.

@Override
public ProjectTask create(TaskTemplate template, Project project, LocalDateTime date, BigDecimal qty) {
    ProjectTask task = super.create(template, project, date, qty);
    task.setInternalDescription(template.getInternalDescription());
    return task;
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 5 with ProjectTask

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

the class ProjectTaskController method updateToInvoice.

/**
 * Invert value of 'toInvoice' field and save the record
 *
 * @param request
 * @param response
 */
@Transactional
public void updateToInvoice(ActionRequest request, ActionResponse response) {
    ProjectTaskRepository projectTaskRepository = Beans.get(ProjectTaskRepository.class);
    try {
        ProjectTask projectTask = request.getContext().asType(ProjectTask.class);
        projectTask = projectTaskRepository.find(projectTask.getId());
        projectTask.setToInvoice(!projectTask.getToInvoice());
        projectTaskRepository.save(projectTask);
        response.setValue("toInvoice", projectTask.getToInvoice());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ProjectTaskRepository(com.axelor.apps.project.db.repo.ProjectTaskRepository) ProjectTask(com.axelor.apps.project.db.ProjectTask) Transactional(com.google.inject.persist.Transactional)

Aggregations

ProjectTask (com.axelor.apps.project.db.ProjectTask)43 Transactional (com.google.inject.persist.Transactional)14 ArrayList (java.util.ArrayList)7 Project (com.axelor.apps.project.db.Project)6 TimerProjectTaskService (com.axelor.apps.project.service.TimerProjectTaskService)6 BigDecimal (java.math.BigDecimal)5 Product (com.axelor.apps.base.db.Product)4 SaleOrderLine (com.axelor.apps.sale.db.SaleOrderLine)4 InvoicingProject (com.axelor.apps.businessproject.db.InvoicingProject)3 TimesheetLine (com.axelor.apps.hr.db.TimesheetLine)3 ProjectTaskRepository (com.axelor.apps.project.db.repo.ProjectTaskRepository)3 AxelorException (com.axelor.exception.AxelorException)3 LocalDateTime (java.time.LocalDateTime)3 InvoiceLine (com.axelor.apps.account.db.InvoiceLine)2 Timer (com.axelor.apps.base.db.Timer)2 TimerHistory (com.axelor.apps.base.db.TimerHistory)2 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)2 ExpenseLine (com.axelor.apps.hr.db.ExpenseLine)2 ProjectPlanningTime (com.axelor.apps.project.db.ProjectPlanningTime)2 ProjectTaskCategory (com.axelor.apps.project.db.ProjectTaskCategory)2