use of de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow in project metasfresh-webui-api by metasfresh.
the class PickingSlotViewRepository method createPickedHURow.
/**
* Creates a HU related picking slot row for the given HU editor row and the given {@code pickingSlotId}.
*
* @param from the hu editor row to create a picking slot row for. If it has included HU editor rows, then the method creates an included picking slot line accordingly.
* @param pickingSlotId
* @return
*/
private static final PickingSlotRow createPickedHURow(@NonNull final PickedHUEditorRow from, final int pickingSlotId) {
final HUEditorRow huEditorRow = from.getHuEditorRow();
final List<PickingSlotRow> includedHURows = huEditorRow.getIncludedRows().stream().map(includedHUEditorRow -> createPickedHURow(// create PickingSlotRows for the included HU rows which shall inherit the parent's processed flag
new PickedHUEditorRow(includedHUEditorRow, from.isProcessed()), pickingSlotId)).collect(ImmutableList.toImmutableList());
return PickingSlotRow.fromPickedHUBuilder().pickingSlotId(pickingSlotId).huId(huEditorRow.getHURowId().getHuId()).huStorageProductId(huEditorRow.getHURowId().getStorageProductId()).huEditorRowType(huEditorRow.getType()).processed(from.isProcessed()).huCode(huEditorRow.getValue()).product(huEditorRow.getProduct()).packingInfo(huEditorRow.getPackingInfo()).qtyCU(huEditorRow.getQtyCU()).topLevelHU(huEditorRow.isTopLevel()).includedHURows(includedHURows).build();
}
use of de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow 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.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow in project metasfresh-webui-api by metasfresh.
the class PickingHUsRepositoryTests method test_retrieveHUsIndexedByPickingSlotId.
private void test_retrieveHUsIndexedByPickingSlotId(@NonNull final String pickingCandidateStatus, final boolean pickingRackSystem) {
final int pickingSlotId = createPickingSlot(pickingRackSystem).getM_PickingSlot_ID();
final I_M_HU hu = newInstance(I_M_HU.class);
hu.setHUStatus(X_M_HU.HUSTATUS_Active);
save(hu);
final int huId = hu.getM_HU_ID();
final I_M_Picking_Candidate pickingCandidate = newInstance(I_M_Picking_Candidate.class);
pickingCandidate.setM_ShipmentSchedule_ID(M_SHIPMENT_SCHEDULE_ID);
pickingCandidate.setM_HU_ID(huId);
pickingCandidate.setM_PickingSlot_ID(pickingSlotId);
pickingCandidate.setStatus(pickingCandidateStatus);
save(pickingCandidate);
final HUEditorRow huEditorRow = HUEditorRow.builder(WindowId.of(423)).setRowId(HUEditorRowId.ofTopLevelHU(huId)).setType(HUEditorRowType.LU).setTopLevel(true).build();
final boolean expectNoRows = X_M_Picking_Candidate.STATUS_CL.equals(pickingCandidateStatus) && pickingRackSystem;
final MockedHUEditorViewRepository huEditorViewRepository = new MockedHUEditorViewRepository();
if (!expectNoRows) {
huEditorViewRepository.addRow(huEditorRow);
}
final PickingHURowsRepository pickingHUsRepository = new PickingHURowsRepository(huEditorViewRepository);
final ListMultimap<Integer, PickedHUEditorRow> result = pickingHUsRepository.retrievePickedHUsIndexedByPickingSlotId(PickingSlotRepoQuery.of(M_SHIPMENT_SCHEDULE_ID));
if (expectNoRows) {
// if 'pickingCandidate' is "closed", then nothing shall be returned
assertThat(result.isEmpty()).isTrue();
} else {
assertThat(result.size()).isEqualTo(1);
assertThat(result.get(pickingSlotId)).hasSize(1);
final boolean expectedProcessed = !X_M_Picking_Candidate.STATUS_IP.equals(pickingCandidateStatus);
final PickedHUEditorRow resultRow = result.get(pickingSlotId).get(0);
final PickedHUEditorRow expectedRow = new PickedHUEditorRow(huEditorRow, expectedProcessed);
assertThat(resultRow).isEqualTo(expectedRow);
}
}
Aggregations