Search in sources :

Example 1 with PickedHUEditorRow

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();
}
Also used : Iterables(com.google.common.collect.Iterables) LookupDataSourceFactory(de.metas.ui.web.window.model.lookup.LookupDataSourceFactory) ListMultimap(com.google.common.collect.ListMultimap) InterfaceWrapperHelper.loadOutOfTrx(org.adempiere.model.InterfaceWrapperHelper.loadOutOfTrx) Supplier(com.google.common.base.Supplier) Autowired(org.springframework.beans.factory.annotation.Autowired) I_M_ShipmentSchedule(de.metas.inoutcandidate.model.I_M_ShipmentSchedule) SqlLookupDescriptor(de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor) ImmutableList(com.google.common.collect.ImmutableList) DisplayType(org.compiere.util.DisplayType) Suppliers(com.google.common.base.Suppliers) I_M_PickingSlot(de.metas.picking.model.I_M_PickingSlot) IPickingSlotDAO(de.metas.picking.api.IPickingSlotDAO) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) IShipmentScheduleEffectiveBL(de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL) LookupDataSource(de.metas.ui.web.window.model.lookup.LookupDataSource) NonNull(lombok.NonNull) Collectors(java.util.stream.Collectors) Services(org.adempiere.util.Services) List(java.util.List) Component(org.springframework.stereotype.Component) Check(de.metas.printing.esb.base.util.Check) LookupScope(de.metas.ui.web.window.descriptor.LookupDescriptorProvider.LookupScope) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow) PickingSlotQuery(de.metas.picking.api.IPickingSlotDAO.PickingSlotQuery) VisibleForTesting(com.google.common.annotations.VisibleForTesting) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)

Example 2 with PickedHUEditorRow

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));
}
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 PickedHUEditorRow

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);
    }
}
Also used : I_M_HU(de.metas.handlingunits.model.I_M_HU) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow) I_M_Picking_Candidate(de.metas.handlingunits.model.I_M_Picking_Candidate) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)

Aggregations

PickedHUEditorRow (de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)3 ListMultimap (com.google.common.collect.ListMultimap)2 I_M_PickingSlot (de.metas.picking.model.I_M_PickingSlot)2 HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Supplier (com.google.common.base.Supplier)1 Suppliers (com.google.common.base.Suppliers)1 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableListMultimap (com.google.common.collect.ImmutableListMultimap)1 Iterables (com.google.common.collect.Iterables)1 I_M_HU (de.metas.handlingunits.model.I_M_HU)1 I_M_Picking_Candidate (de.metas.handlingunits.model.I_M_Picking_Candidate)1 I_M_ShipmentSchedule (de.metas.handlingunits.model.I_M_ShipmentSchedule)1 IShipmentScheduleEffectiveBL (de.metas.inoutcandidate.api.IShipmentScheduleEffectiveBL)1 I_M_ShipmentSchedule (de.metas.inoutcandidate.model.I_M_ShipmentSchedule)1 IPickingSlotDAO (de.metas.picking.api.IPickingSlotDAO)1 PickingSlotQuery (de.metas.picking.api.IPickingSlotDAO.PickingSlotQuery)1 Check (de.metas.printing.esb.base.util.Check)1 DocumentFieldWidgetType (de.metas.ui.web.window.descriptor.DocumentFieldWidgetType)1 LookupScope (de.metas.ui.web.window.descriptor.LookupDescriptorProvider.LookupScope)1