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