Search in sources :

Example 1 with PPOrderId

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());
}
Also used : BOMComponentType(org.eevolution.api.BOMComponentType) I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) ListMultimap(com.google.common.collect.ListMultimap) IPPOrderBOMDAO(de.metas.material.planning.pporder.IPPOrderBOMDAO) ProductId(de.metas.product.ProductId) BigDecimal(java.math.BigDecimal) SqlHUEditorViewRepository(de.metas.ui.web.handlingunits.SqlHUEditorViewRepository) InterfaceWrapperHelper(org.adempiere.model.InterfaceWrapperHelper) GuavaCollectors(de.metas.util.GuavaCollectors) I_PP_Order(de.metas.handlingunits.model.I_PP_Order) HUPackingInfos(de.metas.ui.web.handlingunits.util.HUPackingInfos) DocTypeId(de.metas.document.DocTypeId) PPOrderId(de.metas.material.planning.pporder.PPOrderId) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) MatchingSourceHusQuery(de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery) IPPOrderBOMBL(de.metas.material.planning.pporder.IPPOrderBOMBL) ImmutableSet(com.google.common.collect.ImmutableSet) IPPOrderDAO(org.eevolution.api.IPPOrderDAO) ITranslatableString(de.metas.i18n.ITranslatableString) NonNull(lombok.NonNull) SourceHUsService(de.metas.handlingunits.sourcehu.SourceHUsService) SqlViewBinding(de.metas.ui.web.view.descriptor.SqlViewBinding) List(java.util.List) Builder(lombok.Builder) I_C_DocType(org.compiere.model.I_C_DocType) IHUPPOrderQtyBL(de.metas.handlingunits.pporder.api.IHUPPOrderQtyBL) TranslatableStrings(de.metas.i18n.TranslatableStrings) WarehouseId(org.adempiere.warehouse.WarehouseId) PPOrderPlanningStatus(org.eevolution.api.PPOrderPlanningStatus) IHUPPOrderBL(de.metas.handlingunits.pporder.api.IHUPPOrderBL) IDocTypeDAO(de.metas.document.IDocTypeDAO) I_PP_Order_Qty(de.metas.handlingunits.model.I_PP_Order_Qty) Function(java.util.function.Function) ImmutableList(com.google.common.collect.ImmutableList) Quantity(de.metas.quantity.Quantity) CoalesceUtil(de.metas.util.lang.CoalesceUtil) Nullable(javax.annotation.Nullable) IHUPPOrderQtyDAO(de.metas.handlingunits.pporder.api.IHUPPOrderQtyDAO) I_C_UOM(org.compiere.model.I_C_UOM) HUPackingInfoFormatter(de.metas.ui.web.handlingunits.util.HUPackingInfoFormatter) HUEditorViewRepository(de.metas.ui.web.handlingunits.HUEditorViewRepository) IModelTranslationMap(de.metas.i18n.IModelTranslationMap) WindowId(de.metas.ui.web.window.datatypes.WindowId) IHUPackingInfo(de.metas.ui.web.handlingunits.util.IHUPackingInfo) I_PP_Order_BOMLine(de.metas.handlingunits.model.I_PP_Order_BOMLine) ASIViewRowAttributesProvider(de.metas.ui.web.view.ASIViewRowAttributesProvider) Services(de.metas.util.Services) HuId(de.metas.handlingunits.HuId) HUReservationService(de.metas.handlingunits.reservation.HUReservationService) Comparator(java.util.Comparator) HUEditorRowAttributesProvider(de.metas.ui.web.handlingunits.HUEditorRowAttributesProvider) I_PP_Order_Qty(de.metas.handlingunits.model.I_PP_Order_Qty) ImmutableList(com.google.common.collect.ImmutableList) WarehouseId(org.adempiere.warehouse.WarehouseId) I_PP_Order(de.metas.handlingunits.model.I_PP_Order) IPPOrderDAO(org.eevolution.api.IPPOrderDAO) PPOrderPlanningStatus(org.eevolution.api.PPOrderPlanningStatus)

Example 2 with PPOrderId

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");
    }
}
Also used : PPOrderBOMLineId(de.metas.material.planning.pporder.PPOrderBOMLineId) I_PP_Order(de.metas.handlingunits.model.I_PP_Order) IPPOrderDAO(org.eevolution.api.IPPOrderDAO) AdempiereException(org.adempiere.exceptions.AdempiereException) PPOrderLineType(de.metas.ui.web.pporder.PPOrderLineType) PPOrderId(de.metas.material.planning.pporder.PPOrderId) I_PP_Order_BOMLine(org.eevolution.model.I_PP_Order_BOMLine)

Example 3 with PPOrderId

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;
}
Also used : PPOrderLinesView(de.metas.ui.web.pporder.PPOrderLinesView) I_M_HU(de.metas.handlingunits.model.I_M_HU) AdempiereException(org.adempiere.exceptions.AdempiereException) HUsToNewTUsRequest(de.metas.handlingunits.allocation.transfer.HUTransformService.HUsToNewTUsRequest) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) PPOrderId(de.metas.material.planning.pporder.PPOrderId)

Example 4 with PPOrderId

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;
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) IPPOrderDAO(org.eevolution.api.IPPOrderDAO) OrderLineId(de.metas.order.OrderLineId) AdempiereException(org.adempiere.exceptions.AdempiereException) PPOrderId(de.metas.material.planning.pporder.PPOrderId)

Example 5 with PPOrderId

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;
}
Also used : PPOrderLinesView(de.metas.ui.web.pporder.PPOrderLinesView) I_M_Source_HU(de.metas.handlingunits.model.I_M_Source_HU) HashMap(java.util.HashMap) I_M_HU(de.metas.handlingunits.model.I_M_HU) HUsToNewTUsRequest(de.metas.handlingunits.allocation.transfer.HUTransformService.HUsToNewTUsRequest) PPOrderId(de.metas.material.planning.pporder.PPOrderId) AdempiereException(org.adempiere.exceptions.AdempiereException) EmptyHUListener(de.metas.handlingunits.storage.EmptyHUListener) PPOrderLineRow(de.metas.ui.web.pporder.PPOrderLineRow)

Aggregations

PPOrderId (de.metas.material.planning.pporder.PPOrderId)11 AdempiereException (org.adempiere.exceptions.AdempiereException)7 PPOrderLinesView (de.metas.ui.web.pporder.PPOrderLinesView)5 I_M_HU (de.metas.handlingunits.model.I_M_HU)4 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)4 ImmutableList (com.google.common.collect.ImmutableList)3 I_PP_Order (de.metas.handlingunits.model.I_PP_Order)3 IHUPPOrderBL (de.metas.handlingunits.pporder.api.IHUPPOrderBL)3 SourceHUsService (de.metas.handlingunits.sourcehu.SourceHUsService)3 IPPOrderBOMBL (de.metas.material.planning.pporder.IPPOrderBOMBL)3 IPPOrderBOMDAO (de.metas.material.planning.pporder.IPPOrderBOMDAO)3 Quantity (de.metas.quantity.Quantity)3 IPPOrderDAO (org.eevolution.api.IPPOrderDAO)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 ListMultimap (com.google.common.collect.ListMultimap)2 DocTypeId (de.metas.document.DocTypeId)2 IDocTypeDAO (de.metas.document.IDocTypeDAO)2 HuId (de.metas.handlingunits.HuId)2 HUsToNewTUsRequest (de.metas.handlingunits.allocation.transfer.HUTransformService.HUsToNewTUsRequest)2 I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)2