use of de.metas.ui.web.handlingunits.process.WebuiHUTransformCommandResult.WebuiHUTransformCommandResultBuilder in project metasfresh-webui-api by metasfresh.
the class WebuiHUTransformCommand method action_SplitTU_To_NewTUs.
/**
* Split a given number of TUs from current selected TU line to new TUs.
*
* @param tuRow
* @param qtyTU
* @param tuPI
* @return
*/
private WebuiHUTransformCommandResult action_SplitTU_To_NewTUs(final HUEditorRow tuRow, final BigDecimal qtyTU) {
final IHandlingUnitsBL handlingUnitsBL = Services.get(IHandlingUnitsBL.class);
// TODO: if qtyTU is the "maximum", then don't do anything, but show a user message
final I_M_HU fromTU = tuRow.getM_HU();
final I_M_HU fromTopLevelHU = handlingUnitsBL.getTopLevelParent(fromTU);
final List<I_M_HU> createdHUs = newHUTransformation().tuToNewTUs(fromTU, qtyTU);
final WebuiHUTransformCommandResultBuilder resultBuilder = WebuiHUTransformCommandResult.builder().huIdsToAddToView(createdHUs.stream().map(I_M_HU::getM_HU_ID).collect(ImmutableSet.toImmutableSet()));
if (handlingUnitsBL.isDestroyedRefreshFirst(fromTopLevelHU)) {
resultBuilder.huIdToRemoveFromView(fromTopLevelHU.getM_HU_ID());
} else {
resultBuilder.huIdChanged(fromTopLevelHU.getM_HU_ID());
}
return resultBuilder.build();
}
Aggregations