use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.
the class ProductionOrderSaleOrderServiceBusinessImpl method createProductionOrder.
@Override
protected ProductionOrder createProductionOrder(SaleOrder saleOrder) throws AxelorException {
ProductionOrder productionOrder = super.createProductionOrder(saleOrder);
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (appProductionService.isApp("production") && appProductionService.getAppProduction().getManageBusinessProduction()) {
productionOrder.setProject(saleOrder.getProject());
}
return productionOrder;
}
use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.
the class ProductionOrderWizardServiceBusinessImpl method validate.
@Override
@SuppressWarnings("unchecked")
public Long validate(Context context) throws AxelorException {
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
return super.validate(context);
}
Map<String, Object> bomContext = (Map<String, Object>) context.get("billOfMaterial");
BillOfMaterial billOfMaterial = billOfMaterialRepo.find(((Integer) bomContext.get("id")).longValue());
BigDecimal qty = new BigDecimal((String) context.get("qty"));
Product product = null;
if (context.get("product") != null) {
Map<String, Object> productContext = (Map<String, Object>) context.get("product");
product = productRepo.find(((Integer) productContext.get("id")).longValue());
} else {
product = billOfMaterial.getProduct();
}
ZonedDateTime startDateT, endDateT = null;
if (context.containsKey("_startDate") && context.get("_startDate") != null) {
startDateT = ZonedDateTime.parse(context.get("_startDate").toString(), DateTimeFormatter.ISO_INSTANT.withZone(ZoneId.systemDefault()));
} else {
startDateT = appProductionService.getTodayDateTime();
}
if (context.containsKey("_endDate") && context.get("_endDate") != null) {
endDateT = ZonedDateTime.parse(context.get("_endDate").toString(), DateTimeFormatter.ISO_INSTANT.withZone(ZoneId.systemDefault()));
}
Project project = null;
if (context.get("business_id") != null) {
project = Beans.get(ProjectRepository.class).find(((Integer) context.get("business_id")).longValue());
}
ProductionOrder productionOrder = productionOrderServiceBusinessImpl.generateProductionOrder(product, billOfMaterial, qty, project, startDateT.toLocalDateTime(), endDateT != null ? endDateT.toLocalDateTime() : null, null);
if (productionOrder != null) {
return productionOrder.getId();
} else {
throw new AxelorException(TraceBackRepository.CATEGORY_CONFIGURATION_ERROR, I18n.get(IExceptionMessage.PRODUCTION_ORDER_2));
}
}
use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.
the class TimesheetBusinessProductionServiceImpl method cancel.
@Override
@Transactional
public void cancel(Timesheet timesheet) {
super.cancel(timesheet);
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (appProductionService.isApp("production") && appProductionService.getAppProduction().getManageBusinessProduction()) {
Beans.get(OperationOrderTimesheetServiceImpl.class).updateAllRealDuration(timesheet.getTimesheetLineList());
}
}
use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.
the class CostSheetServiceBusinessImpl method computeRealHumanResourceCost.
@Override
protected void computeRealHumanResourceCost(OperationOrder operationOrder, int priority, int bomLevel, CostSheetLine parentCostSheetLine, LocalDate previousCostSheetDate) throws AxelorException {
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
super.computeRealHumanResourceCost(operationOrder, priority, bomLevel, parentCostSheetLine, previousCostSheetDate);
return;
}
if (operationOrder.getTimesheetLineList() != null) {
Long duration = 0L;
if (parentCostSheetLine.getCostSheet().getCalculationTypeSelect() == CostSheetRepository.CALCULATION_END_OF_PRODUCTION || parentCostSheetLine.getCostSheet().getCalculationTypeSelect() == CostSheetRepository.CALCULATION_PARTIAL_END_OF_PRODUCTION) {
Period period = previousCostSheetDate != null ? Period.between(parentCostSheetLine.getCostSheet().getCalculationDate(), previousCostSheetDate) : null;
duration = period != null ? Long.valueOf(period.getDays() * 24) : operationOrder.getRealDuration();
} else if (parentCostSheetLine.getCostSheet().getCalculationTypeSelect() == CostSheetRepository.CALCULATION_WORK_IN_PROGRESS) {
duration = operationOrder.getRealDuration() - (operationOrder.getPlannedDuration() * costSheet.getManufOrderProducedRatio().longValue());
}
// TODO get the timesheet Line done when we run the calculation.
this.computeRealHumanResourceCost(null, operationOrder.getWorkCenter(), priority, bomLevel, parentCostSheetLine, duration);
}
}
use of com.axelor.apps.production.service.app.AppProductionService in project axelor-open-suite by axelor.
the class InvoicingProjectServiceBusinessProdImpl method setLines.
@Override
public void setLines(InvoicingProject invoicingProject, Project project, int counter) {
AppProductionService appProductionService = Beans.get(AppProductionService.class);
if (!appProductionService.isApp("production") || !appProductionService.getAppProduction().getManageBusinessProduction()) {
super.setLines(invoicingProject, project, counter);
return;
}
if (counter > ProjectServiceImpl.MAX_LEVEL_OF_PROJECT) {
return;
}
counter++;
this.fillLines(invoicingProject, project);
if (!invoicingProject.getConsolidatePhaseWhenInvoicing()) {
return;
}
List<Project> projectChildrenList = Beans.get(ProjectRepository.class).all().filter("self.parentProject = ?1", project).fetch();
for (Project projectChild : projectChildrenList) {
this.setLines(invoicingProject, projectChild, counter);
}
return;
}
Aggregations