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);
}
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));
}
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());
}
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());
}
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;
}
Aggregations