Search in sources :

Example 1 with I_M_Product

use of de.metas.adempiere.model.I_M_Product in project metasfresh-webui-api by metasfresh.

the class WEBUI_HUsToPick_PickCU method getProductToPack.

private I_M_Product getProductToPack() {
    if (_productToPack == null) {
        final PackageableRow packageableRow = getSingleSelectedPackageableRow();
        final int productId = packageableRow.getProductId();
        _productToPack = loadOutOfTrx(productId, I_M_Product.class);
    }
    return _productToPack;
}
Also used : PackageableRow(de.metas.ui.web.picking.packageable.PackageableRow) I_M_Product(de.metas.adempiere.model.I_M_Product)

Example 2 with I_M_Product

use of de.metas.adempiere.model.I_M_Product in project metasfresh-webui-api by metasfresh.

the class WEBUI_HUsToPick_PickCU method getProduct.

private I_M_Product getProduct() {
    final I_M_Product productToPack = getProductToPack();
    // NOTE: scannedProductId might be not set, in case we deactivate the process parameter.
    if (scannedProductId > 0 && scannedProductId != productToPack.getM_Product_ID()) {
        final I_M_Product scannedProduct = loadOutOfTrx(scannedProductId, I_M_Product.class);
        final String scannedProductStr = scannedProduct != null ? scannedProduct.getName() : "?";
        final String expectedProductStr = productToPack.getName();
        throw new AdempiereException(MSG_InvalidProduct, new Object[] { scannedProductStr, expectedProductStr });
    }
    return productToPack;
}
Also used : I_M_Product(de.metas.adempiere.model.I_M_Product) AdempiereException(org.adempiere.exceptions.AdempiereException) ITranslatableString(de.metas.i18n.ITranslatableString)

Example 3 with I_M_Product

use of de.metas.adempiere.model.I_M_Product in project metasfresh-webui-api by metasfresh.

the class WEBUI_HUsToPick_PickCU method pickCUs.

private void pickCUs() {
    final I_M_Product product = getProduct();
    final I_C_UOM uom = productBL.getStockingUOM(product);
    final Date date = SystemTime.asDate();
    final int huIdToSplit = retrieveHUIdToSplit();
    final List<I_M_HU> splitHUs = HUSplitBuilderCoreEngine.builder().huToSplit(load(huIdToSplit, I_M_HU.class)).requestProvider(huContext -> AllocationUtils.createAllocationRequestBuilder().setHUContext(huContext).setProduct(product).setQuantity(getQtyCU(), uom).setDate(date).setFromReferencedModel(// N/A
    null).setForceQtyAllocation(false).create()).destination(HUProducerDestination.ofVirtualPI()).build().withPropagateHUValues().withAllowPartialUnloads(// we allow partial loads and unloads so if a user enters a very large number, then that will just account to "all of it" and there will be no error
    true).performSplit();
    final I_M_HU splitCU = ListUtils.singleElement(splitHUs);
    addHUIdToCurrentPickingSlot(splitCU.getM_HU_ID());
    if (isAutoProcess) {
        final PickingSlotRow rowToProcess = getPickingSlotRow();
        pickingCandidateService.processForHUIds(ImmutableList.of(rowToProcess.getHuId()), rowToProcess.getPickingSlotId(), OptionalInt.empty());
    }
}
Also used : FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) GuavaCollectors(org.adempiere.util.GuavaCollectors) Date(java.util.Date) HUSplitBuilderCoreEngine(de.metas.handlingunits.allocation.transfer.impl.HUSplitBuilderCoreEngine) InterfaceWrapperHelper.loadOutOfTrx(org.adempiere.model.InterfaceWrapperHelper.loadOutOfTrx) Autowired(org.springframework.beans.factory.annotation.Autowired) OptionalInt(java.util.OptionalInt) PickingCandidateService(de.metas.handlingunits.picking.PickingCandidateService) HUProducerDestination(de.metas.handlingunits.allocation.impl.HUProducerDestination) PackageableRow(de.metas.ui.web.picking.packageable.PackageableRow) BigDecimal(java.math.BigDecimal) IProductBL(de.metas.product.IProductBL) AllocationUtils(de.metas.handlingunits.allocation.impl.AllocationUtils) ImmutableList(com.google.common.collect.ImmutableList) SystemTime(org.adempiere.util.time.SystemTime) I_M_HU(de.metas.handlingunits.model.I_M_HU) IProcessDefaultParameter(de.metas.process.IProcessDefaultParameter) IProcessPrecondition(de.metas.process.IProcessPrecondition) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU(de.metas.ui.web.handlingunits.WEBUI_HU_Constants.MSG_WEBUI_SELECT_ACTIVE_UNSELECTED_HU) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_C_UOM(org.compiere.model.I_C_UOM) ITranslatableString(de.metas.i18n.ITranslatableString) ProcessPreconditionsResolution(de.metas.process.ProcessPreconditionsResolution) Services(org.adempiere.util.Services) List(java.util.List) Param(de.metas.process.Param) AdempiereException(org.adempiere.exceptions.AdempiereException) ListUtils(org.adempiere.util.collections.ListUtils) PickingConfigRepository(de.metas.picking.api.PickingConfigRepository) IProcessDefaultParametersProvider(de.metas.process.IProcessDefaultParametersProvider) IMsgBL(de.metas.i18n.IMsgBL) I_M_Product(de.metas.adempiere.model.I_M_Product) InterfaceWrapperHelper.load(org.adempiere.model.InterfaceWrapperHelper.load) IProcessParametersCallout(de.metas.process.IProcessParametersCallout) PickingSlotRow(de.metas.ui.web.picking.pickingslot.PickingSlotRow) I_M_Product(de.metas.adempiere.model.I_M_Product) I_M_HU(de.metas.handlingunits.model.I_M_HU) I_C_UOM(org.compiere.model.I_C_UOM) Date(java.util.Date)

Example 4 with I_M_Product

use of de.metas.adempiere.model.I_M_Product in project metasfresh-webui-api by metasfresh.

the class WebuiHUTransformParametersFiller method retrieveHUPItemProductsForNewTU.

private static LookupValuesList retrieveHUPItemProductsForNewTU(final HUEditorRow cuRow) {
    final I_M_Product product = cuRow.getM_Product();
    final I_C_BPartner bPartner = cuRow.getM_HU().getC_BPartner();
    return WEBUI_ProcessHelper.retrieveHUPIItemProducts(Env.getCtx(), product, bPartner, // includeVirtualItem = false..moving a cu onto a "virtual" TU makes no sense. Instead, the user can just leave the CU as it is, or take it out of a physical TU
    false);
}
Also used : I_M_Product(de.metas.adempiere.model.I_M_Product) I_C_BPartner(org.compiere.model.I_C_BPartner)

Example 5 with I_M_Product

use of de.metas.adempiere.model.I_M_Product in project metasfresh-webui-api by metasfresh.

the class PickingHURowsRepositoryTest method testRetrieveActiveSourceHusQuery_fromShipmentSchedules.

@Test
public void testRetrieveActiveSourceHusQuery_fromShipmentSchedules() {
    final I_M_Warehouse wh = newInstance(I_M_Warehouse.class);
    save(wh);
    final I_M_Product product = newInstance(I_M_Product.class);
    save(product);
    final I_M_ShipmentSchedule shipmentSchedule1 = newInstance(I_M_ShipmentSchedule.class);
    shipmentSchedule1.setM_Warehouse(wh);
    shipmentSchedule1.setM_Product(product);
    save(shipmentSchedule1);
    final I_M_ShipmentSchedule shipmentSchedule2 = newInstance(I_M_ShipmentSchedule.class);
    shipmentSchedule2.setM_Warehouse(wh);
    shipmentSchedule2.setM_Product(product);
    save(shipmentSchedule2);
    final MatchingSourceHusQuery query = PickingHURowsRepository.createMatchingSourceHusQuery(PickingSlotRepoQuery.builder().currentShipmentScheduleId(shipmentSchedule1.getM_ShipmentSchedule_ID()).shipmentScheduleId(shipmentSchedule1.getM_ShipmentSchedule_ID()).shipmentScheduleId(shipmentSchedule2.getM_ShipmentSchedule_ID()).build());
    assertThat(query.getWarehouseId()).isEqualTo(wh.getM_Warehouse_ID());
    assertThat(query.getProductIds()).containsExactly(product.getM_Product_ID());
}
Also used : MatchingSourceHusQuery(de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery) I_M_Product(de.metas.adempiere.model.I_M_Product) I_M_ShipmentSchedule(de.metas.handlingunits.model.I_M_ShipmentSchedule) I_M_Warehouse(de.metas.handlingunits.model.I_M_Warehouse) Test(org.junit.Test)

Aggregations

I_M_Product (de.metas.adempiere.model.I_M_Product)5 ITranslatableString (de.metas.i18n.ITranslatableString)2 PackageableRow (de.metas.ui.web.picking.packageable.PackageableRow)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 ImmutableList (com.google.common.collect.ImmutableList)1 AllocationUtils (de.metas.handlingunits.allocation.impl.AllocationUtils)1 HUProducerDestination (de.metas.handlingunits.allocation.impl.HUProducerDestination)1 HUSplitBuilderCoreEngine (de.metas.handlingunits.allocation.transfer.impl.HUSplitBuilderCoreEngine)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_ShipmentSchedule (de.metas.handlingunits.model.I_M_ShipmentSchedule)1 I_M_Warehouse (de.metas.handlingunits.model.I_M_Warehouse)1 PickingCandidateService (de.metas.handlingunits.picking.PickingCandidateService)1 MatchingSourceHusQuery (de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery)1 IMsgBL (de.metas.i18n.IMsgBL)1 PickingConfigRepository (de.metas.picking.api.PickingConfigRepository)1 IProcessDefaultParameter (de.metas.process.IProcessDefaultParameter)1 IProcessDefaultParametersProvider (de.metas.process.IProcessDefaultParametersProvider)1 IProcessParametersCallout (de.metas.process.IProcessParametersCallout)1 IProcessPrecondition (de.metas.process.IProcessPrecondition)1 Param (de.metas.process.Param)1