use of com.axelor.apps.project.db.ProjectTask in project axelor-open-suite by axelor.
the class ProjectTaskServiceImpl method updateNextTask.
@Override
@Transactional
public void updateNextTask(ProjectTask projectTask) {
ProjectTask nextProjectTask = projectTask.getNextProjectTask();
if (nextProjectTask != null) {
updateModuleFields(projectTask, nextProjectTask);
projectTaskRepo.save(nextProjectTask);
updateNextTask(nextProjectTask);
}
}
use of com.axelor.apps.project.db.ProjectTask in project axelor-open-suite by axelor.
the class ProjectTaskServiceImpl method create.
@Override
@Transactional
public ProjectTask create(String subject, Project project, User assignedTo) {
ProjectTask task = new ProjectTask();
task.setName(subject);
task.setAssignedTo(assignedTo);
task.setTaskDate(appBaseService.getTodayDate(project.getCompany()));
task.setStatus(ProjectTaskRepository.STATUS_NEW);
task.setPriority(ProjectTaskRepository.PRIORITY_NORMAL);
project.addProjectTaskListItem(task);
projectTaskRepo.save(task);
return task;
}
use of com.axelor.apps.project.db.ProjectTask in project axelor-open-suite by axelor.
the class ProjectTaskBusinessProjectServiceImpl method createInvoiceLines.
@Override
public List<InvoiceLine> createInvoiceLines(Invoice invoice, List<ProjectTask> projectTaskList, int priority) throws AxelorException {
List<InvoiceLine> invoiceLineList = new ArrayList<>();
int count = 0;
for (ProjectTask projectTask : projectTaskList) {
invoiceLineList.addAll(this.createInvoiceLine(invoice, projectTask, priority * 100 + count));
count++;
}
return invoiceLineList;
}
use of com.axelor.apps.project.db.ProjectTask in project axelor-open-suite by axelor.
the class InvoicingProjectService method populate.
public List<InvoiceLine> populate(Invoice invoice, InvoicingProject folder) throws AxelorException {
List<SaleOrderLine> saleOrderLineList = new ArrayList<SaleOrderLine>(folder.getSaleOrderLineSet());
List<PurchaseOrderLine> purchaseOrderLineList = new ArrayList<PurchaseOrderLine>(folder.getPurchaseOrderLineSet());
List<TimesheetLine> timesheetLineList = new ArrayList<TimesheetLine>(folder.getLogTimesSet());
List<ExpenseLine> expenseLineList = new ArrayList<ExpenseLine>(folder.getExpenseLineSet());
List<ProjectTask> projectTaskList = new ArrayList<ProjectTask>(folder.getProjectTaskSet());
List<InvoiceLine> invoiceLineList = new ArrayList<InvoiceLine>();
invoiceLineList.addAll(this.createSaleOrderInvoiceLines(invoice, saleOrderLineList, folder.getSaleOrderLineSetPrioritySelect()));
invoiceLineList.addAll(this.createPurchaseOrderInvoiceLines(invoice, purchaseOrderLineList, folder.getPurchaseOrderLineSetPrioritySelect()));
invoiceLineList.addAll(timesheetService.createInvoiceLines(invoice, timesheetLineList, folder.getLogTimesSetPrioritySelect()));
invoiceLineList.addAll(expenseService.createInvoiceLines(invoice, expenseLineList, folder.getExpenseLineSetPrioritySelect()));
invoiceLineList.addAll(projectTaskBusinessProjectService.createInvoiceLines(invoice, projectTaskList, folder.getProjectTaskSetPrioritySelect()));
Collections.sort(invoiceLineList, new InvoiceLineComparator());
for (InvoiceLine invoiceLine : invoiceLineList) {
invoiceLine.setSequence(sequence);
sequence++;
}
return invoiceLineList;
}
use of com.axelor.apps.project.db.ProjectTask in project axelor-open-suite by axelor.
the class ProjectPlanningTimeServiceImpl method addMultipleProjectPlanningTime.
@Override
@Transactional(rollbackOn = { Exception.class })
public void addMultipleProjectPlanningTime(Map<String, Object> datas) throws AxelorException {
if (datas.get("project") == null || datas.get("user") == null || datas.get("fromDate") == null || datas.get("toDate") == null) {
return;
}
DateTimeFormatter formatter = DateTimeFormatter.ISO_DATE_TIME;
LocalDateTime fromDate = LocalDateTime.parse(datas.get("fromDate").toString(), formatter);
LocalDateTime toDate = LocalDateTime.parse(datas.get("toDate").toString(), formatter);
ProjectTask projectTask = null;
Map<String, Object> objMap = (Map) datas.get("project");
Project project = projectRepo.find(Long.parseLong(objMap.get("id").toString()));
Integer timePercent = 0;
if (datas.get("timepercent") != null) {
timePercent = Integer.parseInt(datas.get("timepercent").toString());
}
objMap = (Map) datas.get("user");
User user = userRepo.find(Long.parseLong(objMap.get("id").toString()));
if (user.getEmployee() == null) {
return;
}
if (datas.get("task") != null) {
objMap = (Map) datas.get("task");
projectTask = projectTaskRepo.find(Long.valueOf(objMap.get("id").toString()));
}
Product activity = null;
if (datas.get("product") != null) {
objMap = (Map) datas.get("product");
activity = productRepo.find(Long.valueOf(objMap.get("id").toString()));
}
Employee employee = user.getEmployee();
BigDecimal dailyWorkHrs = employee.getDailyWorkHours();
while (fromDate.isBefore(toDate)) {
LocalDate date = fromDate.toLocalDate();
LOG.debug("Create Planning for the date: {}", date);
double dayHrs = 0;
if (employee.getWeeklyPlanning() != null) {
dayHrs = weeklyPlanningService.getWorkingDayValueInDays(employee.getWeeklyPlanning(), date);
}
if (dayHrs > 0 && !holidayService.checkPublicHolidayDay(date, employee)) {
ProjectPlanningTime planningTime = new ProjectPlanningTime();
planningTime.setProjectTask(projectTask);
planningTime.setProduct(activity);
planningTime.setTimepercent(timePercent);
planningTime.setUser(user);
planningTime.setDate(date);
planningTime.setProject(project);
planningTime.setIsIncludeInTurnoverForecast((Boolean) datas.get("isIncludeInTurnoverForecast"));
BigDecimal totalHours = BigDecimal.ZERO;
if (timePercent > 0) {
totalHours = dailyWorkHrs.multiply(new BigDecimal(timePercent)).divide(new BigDecimal(100));
}
planningTime.setPlannedHours(totalHours);
planningTimeRepo.save(planningTime);
}
fromDate = fromDate.plusDays(1);
}
}
Aggregations