use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class ManufOrderServiceBusinessImpl method propagateIsToInvoice.
@Transactional
public void propagateIsToInvoice(ManufOrder manufOrder) {
logger.debug("{} is to invoice ? {}", manufOrder.getManufOrderSeq(), manufOrder.getIsToInvoice());
boolean isToInvoice = manufOrder.getIsToInvoice();
if (manufOrder.getOperationOrderList() != null) {
for (OperationOrder operationOrder : manufOrder.getOperationOrderList()) {
operationOrder.setIsToInvoice(isToInvoice);
}
}
manufOrderRepo.save(manufOrder);
}
use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class OperationOrderServiceBusinessImpl method createOperationOrder.
@Transactional
public OperationOrder createOperationOrder(ManufOrder manufOrder, int priority, boolean isToInvoice, WorkCenter workCenter, Machine machine, MachineTool machineTool, ProdProcessLine prodProcessLine) throws AxelorException {
logger.debug("Création d'une opération {} pour l'OF {}", priority, manufOrder.getManufOrderSeq());
String operationName = prodProcessLine.getName();
OperationOrder operationOrder = new OperationOrder(priority, this.computeName(manufOrder, priority, operationName), operationName, manufOrder, workCenter, machine, OperationOrderRepository.STATUS_DRAFT, prodProcessLine, machineTool);
operationOrder.setIsToInvoice(isToInvoice);
this._createHumanResourceList(operationOrder, workCenter);
return Beans.get(OperationOrderRepository.class).save(operationOrder);
}
use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class OperationOrderServiceBusinessImpl method createOperationOrder.
@Override
@Transactional(rollbackOn = { Exception.class })
public OperationOrder createOperationOrder(ManufOrder manufOrder, ProdProcessLine prodProcessLine) throws AxelorException {
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
return super.createOperationOrder(manufOrder, prodProcessLine);
}
if (prodProcessLine.getWorkCenter() == null) {
throw new AxelorException(TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.PROD_PROCESS_LINE_MISSING_WORK_CENTER), prodProcessLine.getProdProcess() != null ? prodProcessLine.getProdProcess().getCode() : "null", prodProcessLine.getName());
}
OperationOrder operationOrder = this.createOperationOrder(manufOrder, prodProcessLine.getPriority(), manufOrder.getIsToInvoice(), prodProcessLine.getWorkCenter(), prodProcessLine.getWorkCenter().getMachine(), prodProcessLine.getMachineTool(), prodProcessLine);
return Beans.get(OperationOrderRepository.class).save(operationOrder);
}
use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class OperationOrderTimesheetServiceImpl method updateOperationOrders.
@Override
@Transactional(rollbackOn = { Exception.class })
public void updateOperationOrders(Timesheet timesheet) throws AxelorException {
if (timesheet.getTimesheetLineList() == null) {
return;
}
// ensure that correct hoursDuration is filled
TimesheetLineService timesheetLineService = Beans.get(TimesheetLineService.class);
for (TimesheetLine timesheetLine : timesheet.getTimesheetLineList()) {
BigDecimal hoursDuration = timesheetLineService.computeHoursDuration(timesheet, timesheetLine.getDuration(), true);
timesheetLine.setHoursDuration(hoursDuration);
}
if (!Beans.get(AppProductionService.class).getAppProduction().getEnableTimesheetOnManufOrder()) {
return;
}
List<TimesheetLine> oldTimesheetLineList = Beans.get(TimesheetLineRepository.class).all().filter("self.timesheet.id = :timesheetId").bind("timesheetId", timesheet.getId()).fetch();
List<TimesheetLine> newTimesheetLineList = timesheet.getTimesheetLineList();
List<TimesheetLine> allTimesheetLineList = new ArrayList<>(oldTimesheetLineList);
allTimesheetLineList.addAll(newTimesheetLineList);
List<OperationOrder> operationOrdersToUpdate = allTimesheetLineList.stream().map(TimesheetLine::getOperationOrder).filter(Objects::nonNull).distinct().collect(Collectors.toList());
operationOrdersToUpdate.forEach(operationOrder -> updateOperationOrder(operationOrder, oldTimesheetLineList, newTimesheetLineList));
}
use of com.axelor.apps.production.db.OperationOrder in project axelor-open-suite by axelor.
the class OperationOrderController method computeDuration.
public void computeDuration(ActionRequest request, ActionResponse response) {
OperationOrder operationOrder = request.getContext().asType(OperationOrder.class);
operationOrder = Beans.get(OperationOrderRepository.class).find(operationOrder.getId());
Beans.get(OperationOrderWorkflowService.class).computeDuration(operationOrder);
response.setReload(true);
}
Aggregations