use of com.axelor.apps.production.db.ProductionOrder in project axelor-open-suite by axelor.
the class ProductionOrderSaleOrderServiceImpl method generateProductionOrder.
@Override
@Transactional(rollbackOn = { AxelorException.class })
public List<Long> generateProductionOrder(SaleOrder saleOrder) throws AxelorException {
boolean oneProdOrderPerSO = appProductionService.getAppProduction().getOneProdOrderPerSO();
List<Long> productionOrderIdList = new ArrayList<>();
if (saleOrder.getSaleOrderLineList() == null) {
return productionOrderIdList;
}
ProductionOrder productionOrder = null;
for (SaleOrderLine saleOrderLine : saleOrder.getSaleOrderLineList()) {
if (productionOrder == null || !oneProdOrderPerSO) {
productionOrder = this.createProductionOrder(saleOrder);
}
productionOrder = this.generateManufOrders(productionOrder, saleOrderLine);
if (productionOrder != null && !productionOrderIdList.contains(productionOrder.getId())) {
productionOrderIdList.add(productionOrder.getId());
}
}
return productionOrderIdList;
}
use of com.axelor.apps.production.db.ProductionOrder in project axelor-open-suite by axelor.
the class ProductionOrderServiceImpl method createProductionOrder.
public ProductionOrder createProductionOrder(SaleOrder saleOrder) throws AxelorException {
ProductionOrder productionOrder = new ProductionOrder(this.getProductionOrderSeq());
if (saleOrder != null) {
productionOrder.setClientPartner(saleOrder.getClientPartner());
productionOrder.setSaleOrder(saleOrder);
}
return productionOrder;
}
use of com.axelor.apps.production.db.ProductionOrder 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.db.ProductionOrder 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.db.ProductionOrder in project axelor-open-suite by axelor.
the class ProductionOrderBusinessController method generateSaleOrder.
public void generateSaleOrder(ActionRequest request, ActionResponse response) throws AxelorException {
ProductionOrder productionOrder = request.getContext().asType(ProductionOrder.class);
Beans.get(ProductionOrderSaleOrderServiceBusinessImpl.class).createSaleOrder(Beans.get(ProductionOrderRepository.class).find(productionOrder.getId()));
response.setReload(true);
}
Aggregations