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