Search in sources :

Example 6 with ProjectTask

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

the class ProjectTaskController method compute.

public void compute(ActionRequest request, ActionResponse response) {
    ProjectTask projectTask = request.getContext().asType(ProjectTask.class);
    try {
        projectTask = Beans.get(ProjectTaskBusinessProjectService.class).compute(projectTask);
        response.setValue("priceDiscounted", projectTask.getPriceDiscounted());
        response.setValue("exTaxTotal", projectTask.getExTaxTotal());
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 7 with ProjectTask

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

the class ProjectTaskScript method computeFullname.

public Object computeFullname(Object bean, Map<String, Object> values) {
    ProjectTask task = ((ProjectTask) bean);
    Beans.get(ProjectTaskRepository.class).save(task);
    return task;
}
Also used : ProjectTaskRepository(com.axelor.apps.project.db.repo.ProjectTaskRepository) ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 8 with ProjectTask

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

the class ProjectTaskProjectRepository method validate.

@Override
public Map<String, Object> validate(Map<String, Object> json, Map<String, Object> context) {
    logger.debug("Validate project task:{}", json);
    logger.debug("Planned progress:{}, ProgressSelect: {}, DurationHours: {}, TaskDuration: {}", json.get("plannedProgress"), json.get("progressSelect"), json.get("durationHours"), json.get("taskDuration"));
    if (json.get("id") != null) {
        ProjectTask savedTask = find(Long.parseLong(json.get("id").toString()));
        if (json.get("plannedProgress") != null) {
            BigDecimal plannedProgress = new BigDecimal(json.get("plannedProgress").toString());
            if (plannedProgress != null && savedTask.getPlannedProgress().intValue() != plannedProgress.intValue()) {
                logger.debug("Updating progressSelect: {}", ((int) (plannedProgress.intValue() * 0.10)) * 10);
                json.put("progressSelect", ((int) (plannedProgress.intValue() * 0.10)) * 10);
            }
        } else if (json.get("progressSelect") != null) {
            Integer progressSelect = new Integer(json.get("progressSelect").toString());
            logger.debug("Updating plannedProgress: {}", progressSelect);
            json.put("plannedProgress", new BigDecimal(progressSelect));
        }
        if (json.get("durationHours") != null) {
            BigDecimal durationHours = new BigDecimal(json.get("durationHours").toString());
            if (durationHours != null && savedTask.getDurationHours().intValue() != durationHours.intValue()) {
                logger.debug("Updating taskDuration: {}", durationHours.divide(new BigDecimal(24), RoundingMode.HALF_UP).intValue());
                json.put("taskDuration", durationHours.multiply(new BigDecimal(3600)).intValue());
            }
        } else if (json.get("taskDuration") != null) {
            Integer taskDuration = new Integer(json.get("taskDuration").toString());
            logger.debug("Updating durationHours: {}", taskDuration / 3600);
            json.put("durationHours", new BigDecimal(taskDuration / 3600));
        }
    } else {
        if (json.get("progressSelect") != null) {
            Integer progressSelect = new Integer(json.get("progressSelect").toString());
            json.put("plannedProgress", new BigDecimal(progressSelect));
        }
        if (json.get("taskDuration") != null) {
            Integer taskDuration = new Integer(json.get("taskDuration").toString());
            json.put("durationHours", new BigDecimal(taskDuration / 3600));
        }
    }
    return super.validate(json, context);
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask) BigDecimal(java.math.BigDecimal)

Example 9 with ProjectTask

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

the class ProjectTaskProjectRepository method copy.

@Override
public ProjectTask copy(ProjectTask entity, boolean deep) {
    ProjectTask task = super.copy(entity, deep);
    task.setAssignedTo(null);
    task.setTaskDate(null);
    task.setPriority(null);
    task.setProgressSelect(null);
    task.setTaskEndDate(null);
    task.setMetaFile(null);
    return task;
}
Also used : ProjectTask(com.axelor.apps.project.db.ProjectTask)

Example 10 with ProjectTask

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

the class ProjectTaskController method manageTimerButtons.

public void manageTimerButtons(ActionRequest request, ActionResponse response) {
    try {
        ProjectTask task = request.getContext().asType(ProjectTask.class);
        TimerProjectTaskService service = Beans.get(TimerProjectTaskService.class);
        if (task.getId() == null) {
            return;
        }
        Timer timer = service.find(task);
        boolean hideStart = false;
        boolean hideCancel = true;
        if (timer != null) {
            hideStart = timer.getStatusSelect() == TimerRepository.TIMER_STARTED;
            hideCancel = timer.getTimerHistoryList().isEmpty();
        }
        response.setAttr("startTimerBtn", HIDDEN_ATTR, hideStart);
        response.setAttr("stopTimerBtn", HIDDEN_ATTR, !hideStart);
        response.setAttr("cancelTimerBtn", HIDDEN_ATTR, hideCancel);
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : TimerProjectTaskService(com.axelor.apps.project.service.TimerProjectTaskService) Timer(com.axelor.apps.base.db.Timer) ProjectTask(com.axelor.apps.project.db.ProjectTask)

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