Search in sources :

Example 11 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.

the class PickingSlotViewRepositoryTests method testCreateSourceHURow.

@Test
public void testCreateSourceHURow() {
    final HUEditorRow huEditorRow = HUEditorRow.builder(WindowId.of(423)).setRowId(HUEditorRowId.ofTopLevelHU(100)).setType(HUEditorRowType.TU).setTopLevel(true).build();
    final PickingSlotRow sourceHURow = PickingSlotViewRepository.createSourceHURow(huEditorRow);
    assertThat(sourceHURow).isNotNull();
    assertThat(sourceHURow.isPickingSlotRow()).isFalse();
    assertThat(sourceHURow.isPickedHURow()).isFalse();
    assertThat(sourceHURow.isPickingSourceHURow()).isTrue();
    assertThat(sourceHURow.getId()).isEqualTo(DocumentId.of("0-100"));
    assertThat(sourceHURow.isTopLevelHU()).isTrue();
}
Also used : HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) PickedHUEditorRow(de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow) Test(org.junit.Test)

Example 12 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_Add_Batch_SerialNo_To_CUs method processCURow.

private void processCURow(final HUEditorRow selectedCuRow) {
    final ArrayList<String> availableSerialNumbers = getSerialNumbers();
    if (availableSerialNumbers.isEmpty()) {
        return;
    }
    final HUEditorRow parentRow = getParentHURowOrNull(selectedCuRow);
    final HUEditorRow topLevelRow = parentRow == null ? null : getParentHURowOrNull(parentRow);
    final HUEditorRow.HUEditorRowHierarchy huEditorRowHierarchy = HUEditorRow.HUEditorRowHierarchy.builder().cuRow(selectedCuRow).parentRow(parentRow).topLevelRow(topLevelRow).build();
    final WebuiHUTransformCommandResult result = WEBUIHUCreationWithSerialNumberService.builder().documentCollections(documentsCollection).view(getView()).build().action_CreateCUs_With_SerialNumbers(huEditorRowHierarchy, availableSerialNumbers);
    updateViewFromResult(result);
}
Also used : HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 13 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.

the class WEBUIHUCreationWithSerialNumberService method createCUsBatch.

private Set<Integer> createCUsBatch(final HUEditorRow.HUEditorRowHierarchy huEditorRowHierarchy, final int maxCUsAllowedPerBatch) {
    final Set<Integer> splitCUIDs = new HashSet<>();
    final IHandlingUnitsDAO handlingUnitsDAO = Services.get(IHandlingUnitsDAO.class);
    final HUEditorRow cuRow = huEditorRowHierarchy.getCuRow();
    final HUEditorRow parentRow = huEditorRowHierarchy.getParentRow();
    final int initialQtyCU = cuRow.getQtyCU().intValueExact();
    I_M_HU huToSplit = cuRow.getM_HU();
    int numberOfCUsToCreate;
    if (parentRow == null) {
        // The CU will not be split when its qty gets to 1. So make sure the selected CU gets in the list of split CUs
        final int selectedCUID = huToSplit.getM_HU_ID();
        splitCUIDs.add(selectedCUID);
        numberOfCUsToCreate = maxCUsAllowedPerBatch < initialQtyCU ? maxCUsAllowedPerBatch : initialQtyCU;
        for (int i = 0; i < numberOfCUsToCreate; i++) {
            final List<I_M_HU> createdCUs = newHUTransformation().cuToNewCU(huToSplit, BigDecimal.ONE);
            splitCUIDs.addAll(createdCUs.stream().map(I_M_HU::getM_HU_ID).collect(ImmutableSet.toImmutableSet()));
        }
    } else {
        Check.assume(parentRow.isTU(), " Parent row must be TU: " + parentRow);
        I_M_HU parentHU = parentRow.getM_HU();
        if (isAggregateHU(parentRow)) {
            final HUEditorRow luRow = huEditorRowHierarchy.getTopLevelRow();
            parentHU = createNonAggregatedTU(parentRow, luRow);
            huToSplit = handlingUnitsDAO.retrieveIncludedHUs(parentHU).get(0);
        }
        final int tuCapacity = calculateTUCapacity(parentHU);
        numberOfCUsToCreate = Util.getMinimumOfThree(tuCapacity, maxCUsAllowedPerBatch, initialQtyCU);
        for (int i = 0; i < numberOfCUsToCreate; i++) {
            final List<I_M_HU> createdCUs = newHUTransformation().cuToExistingTU(huToSplit, BigDecimal.ONE, parentHU);
            splitCUIDs.addAll(createdCUs.stream().map(I_M_HU::getM_HU_ID).collect(ImmutableSet.toImmutableSet()));
        }
    }
    return splitCUIDs;
}
Also used : IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) I_M_HU(de.metas.handlingunits.model.I_M_HU) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow) HashSet(java.util.HashSet)

Example 14 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.

the class WEBUI_M_HU_MoveTUsToDirectWarehouse method checkPreconditionsApplicable.

@Override
protected ProcessPreconditionsResolution checkPreconditionsApplicable() {
    if (!isHUEditorView()) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("not the HU view");
    }
    final DocumentIdsSelection selectedRowIds = getSelectedRowIds();
    if (!selectedRowIds.isSingleDocumentId()) {
        return ProcessPreconditionsResolution.rejectBecauseNotSingleSelection();
    }
    final DocumentId rowId = selectedRowIds.getSingleDocumentId();
    final HUEditorRow huRow = getView().getById(rowId);
    if (huRow.isLU()) {
        if (!huRow.hasIncludedTUs()) {
            return ProcessPreconditionsResolution.rejectWithInternalReason("no TUs");
        }
    } else if (huRow.isTU()) {
    // OK
    } else {
        return ProcessPreconditionsResolution.rejectWithInternalReason("not a LU or TU");
    }
    if (!huRow.isHUStatusActive()) {
        return ProcessPreconditionsResolution.rejectWithInternalReason("HUStatus is not Active");
    }
    return ProcessPreconditionsResolution.accept();
}
Also used : DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Example 15 with HUEditorRow

use of de.metas.ui.web.handlingunits.HUEditorRow in project metasfresh-webui-api by metasfresh.

the class WebuiHUTransformCommand method execute.

public final WebuiHUTransformCommandResult execute() {
    final HUEditorRow row = getSelectedRow();
    final ActionType action = getActionType();
    final WebuiHUTransformParameters parameters = getParameters();
    switch(action) {
        case CU_To_NewCU:
            {
                return action_SplitCU_To_NewCU(row, parameters.getQtyCU());
            }
        case CU_To_ExistingTU:
            {
                return action_SplitCU_To_ExistingTU(row, parameters.getTuHU(), parameters.getQtyCU());
            }
        case CU_To_NewTUs:
            {
                if (parameters.getHuPIItemProduct() == null) {
                    throw new FillMandatoryException(WEBUI_M_HU_Transform.PARAM_M_HU_PI_Item_Product_ID);
                }
                return action_SplitCU_To_NewTUs(row, parameters.getHuPIItemProduct(), parameters.getQtyCU(), parameters.isHuPlanningReceiptOwnerPM_TU());
            }
        case TU_Set_Ownership:
            {
                return action_updatePlanningReceiptOwnerPM(row, parameters.isHuPlanningReceiptOwnerPM_TU());
            }
        case TU_To_NewTUs:
            {
                return action_SplitTU_To_NewTUs(row, parameters.getQtyTU());
            }
        case TU_To_NewLUs:
            {
                if (parameters.getHuPIItem() == null) {
                    throw new FillMandatoryException(WEBUI_M_HU_Transform.PARAM_M_HU_PI_Item_ID);
                }
                return action_SplitTU_To_NewLU(row, parameters.getHuPIItem(), parameters.getQtyTU(), parameters.isHuPlanningReceiptOwnerPM_LU());
            }
        case LU_Set_Ownership:
            {
                return action_updatePlanningReceiptOwnerPM(row, parameters.isHuPlanningReceiptOwnerPM_LU());
            }
        case TU_To_ExistingLU:
            {
                return action_SplitTU_To_ExistingLU(row, parameters.getLuHU(), parameters.getQtyTU());
            }
        // 
        default:
            {
                throw new AdempiereException("@Unknown@ @Action@ " + action);
            }
    }
}
Also used : AdempiereException(org.adempiere.exceptions.AdempiereException) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) HUEditorRow(de.metas.ui.web.handlingunits.HUEditorRow)

Aggregations

HUEditorRow (de.metas.ui.web.handlingunits.HUEditorRow)28 I_M_HU (de.metas.handlingunits.model.I_M_HU)8 HUEditorView (de.metas.ui.web.handlingunits.HUEditorView)6 List (java.util.List)5 NonNull (lombok.NonNull)5 Services (org.adempiere.util.Services)5 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)3 HUTransformService (de.metas.handlingunits.allocation.transfer.HUTransformService)3 IHUPPOrderBL (de.metas.handlingunits.pporder.api.IHUPPOrderBL)3 ITranslatableString (de.metas.i18n.ITranslatableString)3 Check (de.metas.printing.esb.base.util.Check)3 PickedHUEditorRow (de.metas.ui.web.picking.pickingslot.PickingHURowsRepository.PickedHUEditorRow)3 PickingSlotRow (de.metas.ui.web.picking.pickingslot.PickingSlotRow)3 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)3 SqlLookupDescriptor (de.metas.ui.web.window.descriptor.sql.SqlLookupDescriptor)3 LookupDataSource (de.metas.ui.web.window.model.lookup.LookupDataSource)3 LookupDataSourceFactory (de.metas.ui.web.window.model.lookup.LookupDataSourceFactory)3 Comparator (java.util.Comparator)3 HashSet (java.util.HashSet)3 Nullable (javax.annotation.Nullable)3