Search in sources :

Example 21 with HuId

use of de.metas.handlingunits.HuId in project metasfresh-webui-api by metasfresh.

the class PickingHURowsRepository method retrieveSourceHUs.

/**
 * Retrieve the union of all HUs that match any one of the given shipment schedule IDs and that are flagged to be fine picking source HUs.
 *
 * @param shipmentScheduleIds
 * @return
 */
public List<HUEditorRow> retrieveSourceHUs(@NonNull final PickingSlotRepoQuery query) {
    final HUEditorViewRepository huEditorRepo = getHUEditorViewRepository();
    final MatchingSourceHusQuery matchingSourceHUsQuery = createMatchingSourceHusQuery(query);
    final Set<HuId> sourceHUIds = SourceHUsService.get().retrieveMatchingSourceHUIds(matchingSourceHUsQuery);
    return huEditorRepo.retrieveHUEditorRows(sourceHUIds, HUEditorRowFilter.ALL);
}
Also used : MatchingSourceHusQuery(de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery) SqlHUEditorViewRepository(de.metas.ui.web.handlingunits.SqlHUEditorViewRepository) HUEditorViewRepository(de.metas.ui.web.handlingunits.HUEditorViewRepository) HuId(de.metas.handlingunits.HuId)

Example 22 with HuId

use of de.metas.handlingunits.HuId in project metasfresh-webui-api by metasfresh.

the class PickingSlotRowId method fromStringPartsList.

public static final PickingSlotRowId fromStringPartsList(final List<String> parts) {
    final int partsCount = parts.size();
    if (partsCount < 1) {
        throw new IllegalArgumentException("Invalid id: " + parts);
    }
    final PickingSlotId pickingSlotId = !Check.isEmpty(parts.get(0), true) ? PickingSlotId.ofRepoIdOrNull(Integer.parseInt(parts.get(0))) : null;
    final HuId huId = partsCount >= 2 ? HuId.ofRepoIdOrNull(Integer.parseInt(parts.get(1))) : null;
    final int huStorageProductId = partsCount >= 3 ? Integer.parseInt(parts.get(2)) : 0;
    return new PickingSlotRowId(pickingSlotId, huId, huStorageProductId);
}
Also used : PickingSlotId(de.metas.picking.api.PickingSlotId) HuId(de.metas.handlingunits.HuId)

Example 23 with HuId

use of de.metas.handlingunits.HuId in project metasfresh-webui-api by metasfresh.

the class PickingSlotRowId method ofPickingSlotId.

public static final PickingSlotRowId ofPickingSlotId(final PickingSlotId pickingSlotId) {
    final HuId huId = null;
    final int huStorageProductId = -1;
    return new PickingSlotRowId(pickingSlotId, huId, huStorageProductId);
}
Also used : HuId(de.metas.handlingunits.HuId)

Example 24 with HuId

use of de.metas.handlingunits.HuId in project metasfresh-webui-api by metasfresh.

the class ProductsToPickRowsDataFactoryTest method test_AlreadyExistingPickingCandidate.

@Test
public void test_AlreadyExistingPickingCandidate() {
    final HuId huId1 = testHelper.prepareExistingHU().locatorId(locatorId).productId(productId).qty(Quantity.of(999, uomKg)).build();
    final I_M_Picking_Candidate pickingCandidateRecord = newInstance(I_M_Picking_Candidate.class);
    pickingCandidateRecord.setM_ShipmentSchedule_ID(shipmentScheduleId.getRepoId());
    pickingCandidateRecord.setStatus(PickingCandidateStatus.Draft.getCode());
    pickingCandidateRecord.setPickStatus(PickingCandidatePickStatus.PICKED.getCode());
    pickingCandidateRecord.setApprovalStatus(PickingCandidateApprovalStatus.TO_BE_APPROVED.getCode());
    pickingCandidateRecord.setQtyPicked(new BigDecimal("5"));
    pickingCandidateRecord.setC_UOM_ID(uomKg.getC_UOM_ID());
    pickingCandidateRecord.setPickFrom_HU_ID(huId1.getRepoId());
    saveRecord(pickingCandidateRecord);
    final PackageableRow packageableRow = preparePackageableRow().qtyToDeliver(5).bestBeforePolicy(ShipmentAllocationBestBeforePolicy.Expiring_First).build();
    final ProductsToPickRowsDataFactory productsToPickRowsDataFactory = testHelper.createProductsToPickRowsDataFactory();
    final Collection<ProductsToPickRow> rows = productsToPickRowsDataFactory.create(packageableRow).getTopLevelRows();
    assertThat(rows).hasSize(1);
    final ProductsToPickRow row = rows.iterator().next();
    assertThat(row.getQtyEffective()).isEqualTo(Quantity.of(5, uomKg));
    assertThat(row.getType()).isEqualTo(ProductsToPickRowType.PICK_FROM_HU);
    assertThat(row.getPickFromHUId()).isEqualTo(huId1);
}
Also used : PackageableRow(de.metas.ui.web.pickingV2.packageable.PackageableRow) ProductsToPickRow(de.metas.ui.web.pickingV2.productsToPick.rows.ProductsToPickRow) HuId(de.metas.handlingunits.HuId) ProductsToPickRowsDataFactory(de.metas.ui.web.pickingV2.productsToPick.rows.factory.ProductsToPickRowsDataFactory) I_M_Picking_Candidate(de.metas.handlingunits.model.I_M_Picking_Candidate) BigDecimal(java.math.BigDecimal) Test(org.junit.jupiter.api.Test)

Example 25 with HuId

use of de.metas.handlingunits.HuId in project metasfresh-webui-api by metasfresh.

the class WEBUI_HUsToPick_PickCU method performPickCU.

private HuId performPickCU() {
    final HuId huIdToSplit = retrieveHUIdToSplit();
    final List<I_M_HU> splitHUs = HUSplitBuilderCoreEngine.builder().huToSplit(handlingUnitsDAO.getById(huIdToSplit)).requestProvider(this::createSplitAllocationRequest).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 = CollectionUtils.singleElement(splitHUs);
    final HuId splitCUId = HuId.ofRepoId(splitCU.getM_HU_ID());
    addHUIdToCurrentPickingSlot(splitCUId);
    return splitCUId;
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) HuId(de.metas.handlingunits.HuId)

Aggregations

HuId (de.metas.handlingunits.HuId)54 I_M_HU (de.metas.handlingunits.model.I_M_HU)17 AdempiereException (org.adempiere.exceptions.AdempiereException)11 ProductId (de.metas.product.ProductId)10 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)8 ImmutableSet (com.google.common.collect.ImmutableSet)7 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)7 NonNull (lombok.NonNull)7 ImmutableList (com.google.common.collect.ImmutableList)6 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)6 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)6 Services (de.metas.util.Services)6 List (java.util.List)6 Set (java.util.Set)6 IHUQueryBuilder (de.metas.handlingunits.IHUQueryBuilder)5 PickingSlotId (de.metas.picking.api.PickingSlotId)5 Quantity (de.metas.quantity.Quantity)5 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)5 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)5 OrderLineId (de.metas.order.OrderLineId)4