Search in sources :

Example 1 with I_M_ShipmentSchedule

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

the class WEBUI_Picking_PickQtyToNewHU method getM_HU_PI_Item_Products.

/**
 * @return a list of PI item products that match the selected shipment schedule's product and partner, sorted by name.
 */
@ProcessParamLookupValuesProvider(parameterName = PARAM_M_HU_PI_Item_Product_ID, dependsOn = {}, numericKey = true, lookupTableName = I_M_HU_PI_Item_Product.Table_Name)
private LookupValuesList getM_HU_PI_Item_Products() {
    final Properties ctx = getCtx();
    // can't be null
    final I_M_ShipmentSchedule shipmentSchedule = getView().getCurrentShipmentSchedule();
    return WEBUI_ProcessHelper.retrieveHUPIItemProducts(ctx, shipmentSchedule.getM_Product(), shipmentSchedule.getC_BPartner(), // includeVirtualItem = true..similar case as with production
    true);
}
Also used : I_M_ShipmentSchedule(de.metas.handlingunits.model.I_M_ShipmentSchedule) Properties(java.util.Properties) ProcessParamLookupValuesProvider(de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider)

Example 2 with I_M_ShipmentSchedule

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

the class PickingSlotViewRepositoryTests method testRetrievePickingSlotRows_One_TU_with_CU.

@Test
public void testRetrievePickingSlotRows_One_TU_with_CU() {
    final I_M_ShipmentSchedule shipmentSchedule = newInstance(I_M_ShipmentSchedule.class);
    save(shipmentSchedule);
    final I_M_PickingSlot pickingSlot = newInstance(I_M_PickingSlot.class);
    save(pickingSlot);
    final boolean pickingSlotRowProcessed = false;
    final PickingSlotRepoQuery query = PickingSlotRepoQuery.of(shipmentSchedule.getM_ShipmentSchedule_ID());
    // set up a picked TU with a CU to be returned by the pickingHUsRepo.
    {
        final ListMultimap<Integer, PickedHUEditorRow> husIndexedByPickingSlotId = ImmutableListMultimap.of(pickingSlot.getM_PickingSlot_ID(), new PickedHUEditorRow(HUEditorRow.builder(WindowId.of(423)).setRowId(HUEditorRowId.ofTopLevelHU(100)).setType(HUEditorRowType.TU).setTopLevel(true).addIncludedRow(HUEditorRow.builder(WindowId.of(423)).setRowId(HUEditorRowId.ofHU(101, 100)).setType(HUEditorRowType.VHU).setTopLevel(false).build()).build(), pickingSlotRowProcessed));
        // @formatter:off return an empty list
        new Expectations() {

            {
                pickingHUsRepo.retrievePickedHUsIndexedByPickingSlotId(query);
                result = husIndexedByPickingSlotId;
            }
        };
    // @formatter:on
    }
    final PickingSlotViewRepository pickingSlotViewRepository = createPickingSllotViewRepository();
    final List<PickingSlotRow> rowsByShipmentScheduleId = pickingSlotViewRepository.retrievePickingSlotRows(query);
    assertThat(rowsByShipmentScheduleId.size(), is(1));
    final PickingSlotRow pickingSlotRow = rowsByShipmentScheduleId.get(0);
    assertThat(pickingSlotRow.isPickingSlotRow(), is(true));
    assertThat(pickingSlotRow.isPickedHURow(), is(false));
    assertThat(pickingSlotRow.isProcessed(), is(pickingSlotRowProcessed));
    assertThat(pickingSlotRow.getIncludedRows().size(), is(1));
    final PickingSlotRow tuRow = pickingSlotRow.getIncludedRows().get(0);
    assertThat(tuRow.isPickingSlotRow(), is(false));
    assertThat(tuRow.isPickedHURow(), is(true));
    assertThat(tuRow.getHuId(), is(100));
    assertThat(tuRow.getIncludedRows().size(), is(1));
    final PickingSlotRow whuRow = tuRow.getIncludedRows().get(0);
    assertThat(whuRow.isPickingSlotRow(), is(false));
    assertThat(whuRow.isPickedHURow(), is(true));
    assertThat(whuRow.getHuId(), is(101));
}
Also used : Expectations(mockit.Expectations) I_M_PickingSlot(de.metas.picking.model.I_M_PickingSlot) I_M_ShipmentSchedule(de.metas.handlingunits.model.I_M_ShipmentSchedule) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow) ListMultimap(com.google.common.collect.ListMultimap) ImmutableListMultimap(com.google.common.collect.ImmutableListMultimap) Test(org.junit.Test)

Example 3 with I_M_ShipmentSchedule

use of de.metas.handlingunits.model.I_M_ShipmentSchedule 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)

Example 4 with I_M_ShipmentSchedule

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

the class PickingSlotViewRepositoryTests method testRetrievePickingSlotRows_No_HUs_show_PickingSlotsOnly.

/**
 * Verifies {@link PickingSlotViewRepository#retrieveRows(PickingSlotRepoQuery)}<br>
 * when there are no HUs (no picking candidates) assigned to a picking slot, but still the picking slot itself shall be shown.
 */
@Test
public void testRetrievePickingSlotRows_No_HUs_show_PickingSlotsOnly() {
    final I_M_ShipmentSchedule shipmentSchedule = newInstance(I_M_ShipmentSchedule.class);
    save(shipmentSchedule);
    final I_M_PickingSlot pickingSlot = newInstance(I_M_PickingSlot.class);
    pickingSlot.setIsPickingRackSystem(true);
    save(pickingSlot);
    final PickingSlotRepoQuery query = PickingSlotRepoQuery.of(shipmentSchedule.getM_ShipmentSchedule_ID());
    // @formatter:off return an empty list
    new Expectations() {

        {
            pickingHUsRepo.retrievePickedHUsIndexedByPickingSlotId(query);
            result = ImmutableListMultimap.of();
        }
    };
    // @formatter:on
    final NullLookupDataSource nullDS = NullLookupDataSource.instance;
    final PickingSlotViewRepository pickingSlotViewRepository = new PickingSlotViewRepository(pickingHUsRepo, () -> nullDS, () -> nullDS, () -> nullDS);
    final List<PickingSlotRow> pickingSlotRows = pickingSlotViewRepository.retrievePickingSlotRows(query);
    // even if there are no HUs, there shall still be a row for our picking slot.
    assertThat(pickingSlotRows.size(), is(1));
    final PickingSlotRow pickingSlotRow = pickingSlotRows.get(0);
    assertThat(pickingSlotRow.getType()).isEqualTo(PickingSlotRowType.forPickingSlotRow());
}
Also used : Expectations(mockit.Expectations) I_M_PickingSlot(de.metas.picking.model.I_M_PickingSlot) I_M_ShipmentSchedule(de.metas.handlingunits.model.I_M_ShipmentSchedule) NullLookupDataSource(de.metas.ui.web.window.model.lookup.NullLookupDataSource) Test(org.junit.Test)

Example 5 with I_M_ShipmentSchedule

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

the class WEBUI_Picking_PickQtyToExistingHU method getParameterDefaultValue.

/**
 * Returns the {@code qtyToDeliver} value of the currently selected shipment schedule, or {@code null}.
 */
@Override
public Object getParameterDefaultValue(@NonNull final IProcessDefaultParameter parameter) {
    if (!Objects.equals(PARAM_QTY_CU, parameter.getColumnName())) {
        return DEFAULT_VALUE_NOTAVAILABLE;
    }
    // can't be null
    final I_M_ShipmentSchedule shipmentSchedule = getView().getCurrentShipmentSchedule();
    final BigDecimal qtyPickedPlanned = Services.get(IPackagingDAO.class).retrieveQtyPickedPlannedOrNull(shipmentSchedule);
    if (qtyPickedPlanned == null) {
        return BigDecimal.ZERO;
    }
    final BigDecimal qtyToPick = shipmentSchedule.getQtyToDeliver().subtract(qtyPickedPlanned);
    return qtyToPick.signum() > 0 ? qtyToPick : BigDecimal.ZERO;
}
Also used : IPackagingDAO(de.metas.inoutcandidate.api.IPackagingDAO) I_M_ShipmentSchedule(de.metas.handlingunits.model.I_M_ShipmentSchedule) BigDecimal(java.math.BigDecimal)

Aggregations

I_M_ShipmentSchedule (de.metas.handlingunits.model.I_M_ShipmentSchedule)7 Test (org.junit.Test)3 IPackagingDAO (de.metas.inoutcandidate.api.IPackagingDAO)2 I_M_PickingSlot (de.metas.picking.model.I_M_PickingSlot)2 BigDecimal (java.math.BigDecimal)2 Expectations (mockit.Expectations)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 ListMultimap (com.google.common.collect.ListMultimap)1 I_M_Product (de.metas.adempiere.model.I_M_Product)1 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)1 I_M_Warehouse (de.metas.handlingunits.model.I_M_Warehouse)1 MatchingSourceHusQuery (de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery)1 MatchingSourceHusQueryBuilder (de.metas.handlingunits.sourcehu.SourceHUsService.MatchingSourceHusQuery.MatchingSourceHusQueryBuilder)1 IShipmentScheduleEffectiveBL (de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL)1 PickedHUEditorRow (de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)1 ProcessParamLookupValuesProvider (de.metas.ui.web.process.descriptor.ProcessParamLookupValuesProvider)1 NullLookupDataSource (de.metas.ui.web.window.model.lookup.NullLookupDataSource)1 Properties (java.util.Properties)1