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