use of de.metas.material.planning.pporder.PPOrderId in project metasfresh-webui-api by metasfresh.
the class PPOrderLinesLoader method retrieveData.
/**
* Loads {@link PPOrderLinesViewData}s.
*
* @param viewId viewId to be set to newly created {@link PPOrderLineRow}s.
*/
public PPOrderLinesViewData retrieveData(final PPOrderId ppOrderId) {
final I_PP_Order ppOrder = Services.get(IPPOrderDAO.class).getById(ppOrderId, I_PP_Order.class);
final int mainProductBOMLineId = 0;
final ListMultimap<Integer, I_PP_Order_Qty> ppOrderQtysByBOMLineId = ppOrderQtyDAO.streamOrderQtys(ppOrderId).collect(GuavaCollectors.toImmutableListMultimap(ppOrderQty -> CoalesceUtil.firstGreaterThanZero(ppOrderQty.getPP_Order_BOMLine_ID(), mainProductBOMLineId)));
final ImmutableList.Builder<PPOrderLineRow> records = ImmutableList.builder();
// Main product
final PPOrderLineRow rowForMainProduct = createRowForMainProduct(ppOrder, ppOrderQtysByBOMLineId.get(mainProductBOMLineId));
records.add(rowForMainProduct);
// BOM lines
final List<PPOrderLineRow> bomLineRows = createRowsForBomLines(ppOrder, ppOrderQtysByBOMLineId);
records.addAll(bomLineRows);
// Source HUs
final WarehouseId warehouseId = WarehouseId.ofRepoId(ppOrder.getM_Warehouse_ID());
final List<PPOrderLineRow> sourceHuRowsForIssueProducts = createRowsForIssueProductSourceHUs(warehouseId, bomLineRows);
records.addAll(sourceHuRowsForIssueProducts);
final PPOrderPlanningStatus planningStatus = PPOrderPlanningStatus.ofCode(ppOrder.getPlanningStatus());
return new PPOrderLinesViewData(extractDescription(ppOrder), planningStatus, records.build());
}
use of de.metas.material.planning.pporder.PPOrderId in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_Receipt method createDefaultLUTUConfigManager.
private IDocumentLUTUConfigurationManager createDefaultLUTUConfigManager(@NonNull final PPOrderLineRow row) {
final PPOrderLineType type = row.getType();
if (type == PPOrderLineType.MainProduct) {
final PPOrderId ppOrderId = row.getOrderId();
final I_PP_Order ppOrder = Services.get(IPPOrderDAO.class).getById(ppOrderId, I_PP_Order.class);
return huPPOrderBL.createReceiptLUTUConfigurationManager(ppOrder);
} else if (type == PPOrderLineType.BOMLine_ByCoProduct) {
final PPOrderBOMLineId ppOrderBOMLineId = row.getOrderBOMLineId();
final I_PP_Order_BOMLine ppOrderBOMLine = Services.get(IPPOrderBOMDAO.class).getOrderBOMLineById(ppOrderBOMLineId);
return huPPOrderBL.createReceiptLUTUConfigurationManager(ppOrderBOMLine);
} else {
throw new AdempiereException("Receiving is not allowed");
}
}
use of de.metas.material.planning.pporder.PPOrderId in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_HUEditor_IssueTUs method doIt.
@Override
protected String doIt() throws Exception {
final HUEditorRow row = getSingleSelectedRow();
final I_M_HU sourceLUorTU = row.getM_HU();
final HUsToNewTUsRequest request = HUsToNewTUsRequest.forSourceHuAndQty(sourceLUorTU, qtyTUs);
final List<I_M_HU> extractedTUs = HUTransformService.newInstance().husToNewTUs(request);
if (extractedTUs.isEmpty()) {
throw new AdempiereException("@NoSelection@");
}
final PPOrderLinesView ppOrderView = getPPOrderView().get();
final PPOrderId ppOrderId = ppOrderView.getPpOrderId();
Services.get(IHUPPOrderBL.class).createIssueProducer(ppOrderId).createIssues(extractedTUs);
getView().invalidateAll();
ppOrderView.invalidateAll();
return MSG_OK;
}
use of de.metas.material.planning.pporder.PPOrderId in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_IssueReceipt_BarcodeLauncher method doIt.
@Override
protected String doIt() {
final OrderLineId orderLineId = OrderCheckupBarcode.fromBarcodeString(p_Barcode).getOrderLineId();
final PPOrderId ppOrderId = Services.get(IPPOrderDAO.class).retrievePPOrderIdByOrderLineId(orderLineId);
if (ppOrderId == null) {
throw new AdempiereException("@NotFound@ @PP_Order_ID@");
}
final TableRecordReference ppOrderRef = TableRecordReference.of(org.eevolution.model.I_PP_Order.Table_Name, ppOrderId);
getResult().setRecordToOpen(ppOrderRef, PPOrderConstants.AD_WINDOW_ID_IssueReceipt.toInt(), OpenTarget.GridView);
return MSG_OK;
}
use of de.metas.material.planning.pporder.PPOrderId in project metasfresh-webui-api by metasfresh.
the class WEBUI_PP_Order_M_Source_HU_IssueTuQty method doIt.
@Override
protected String doIt() throws Exception {
final PPOrderLineRow row = getSingleSelectedRow();
final List<I_M_Source_HU> sourceHus = WEBUI_PP_Order_ProcessHelper.retrieveActiveSourceHus(row);
if (sourceHus.isEmpty()) {
throw new AdempiereException("@NoSelection@");
}
final Map<Integer, I_M_Source_HU> huId2SourceHu = new HashMap<>();
final ImmutableList<I_M_HU> husThatAreFlaggedAsSource = sourceHus.stream().peek(sourceHu -> huId2SourceHu.put(sourceHu.getM_HU_ID(), sourceHu)).map(I_M_Source_HU::getM_HU).collect(ImmutableList.toImmutableList());
final HUsToNewTUsRequest request = HUsToNewTUsRequest.builder().sourceHUs(husThatAreFlaggedAsSource).qtyTU(qtyTU.intValue()).build();
EmptyHUListener emptyHUListener = EmptyHUListener.doBeforeDestroyed(hu -> {
if (huId2SourceHu.containsKey(hu.getM_HU_ID())) {
SourceHUsService.get().snapshotSourceHU(huId2SourceHu.get(hu.getM_HU_ID()));
}
}, "Create snapshot of source-HU before it is destroyed");
final List<I_M_HU> extractedTUs = HUTransformService.builder().emptyHUListener(emptyHUListener).build().husToNewTUs(request);
final PPOrderLinesView ppOrderView = getView();
final PPOrderId ppOrderId = ppOrderView.getPpOrderId();
Services.get(IHUPPOrderBL.class).createIssueProducer(ppOrderId).createIssues(extractedTUs);
getView().invalidateAll();
ppOrderView.invalidateAll();
return MSG_OK;
}
Aggregations