use of de.metas.handlingunits.model.I_M_HU_PI_Item in project metasfresh-webui-api by metasfresh.
the class PackingInfoProcessParams method configureLUTUConfigLU.
private void configureLUTUConfigLU(@NonNull final I_M_HU_LUTU_Configuration lutuConfigNew, final int lu_PI_Item_ID) {
if (lu_PI_Item_ID > 0) {
final BigDecimal qtyLU = getQtyLU();
if (qtyLU == null || qtyLU.signum() <= 0) {
throw new FillMandatoryException(PARAM_QtyLU);
}
final I_M_HU_PI_Item luPI_Item = loadOutOfTrx(lu_PI_Item_ID, I_M_HU_PI_Item.class);
lutuConfigNew.setM_LU_HU_PI_Item(luPI_Item);
lutuConfigNew.setM_LU_HU_PI(luPI_Item.getM_HU_PI_Version().getM_HU_PI());
lutuConfigNew.setQtyLU(qtyLU);
lutuConfigNew.setIsInfiniteQtyLU(false);
} else {
lutuConfigNew.setM_LU_HU_PI(null);
lutuConfigNew.setM_LU_HU_PI_Item(null);
lutuConfigNew.setQtyLU(BigDecimal.ZERO);
}
}
use of de.metas.handlingunits.model.I_M_HU_PI_Item in project metasfresh-webui-api by metasfresh.
the class PackingInfoProcessParams method insertPhysicalFallbackTU.
private void insertPhysicalFallbackTU(@NonNull final I_M_HU_LUTU_Configuration defaultLUTUConfig) {
final List<I_M_HU_PI_Item_Product> availableHUPIItemProductRecords = WEBUI_ProcessHelper.retrieveHUPIItemProductRecords(Env.getCtx(), defaultLUTUConfig.getM_Product(), defaultLUTUConfig.getC_BPartner(), // includeVirtualItem == false
false);
Check.errorIf(availableHUPIItemProductRecords.isEmpty(), "There is no non-virtual M_HU_PI_Item_Product value for the given product and bPartner; product={}; bPartner={}", defaultLUTUConfig.getM_Product(), defaultLUTUConfig.getC_BPartner());
final I_M_HU_PI_Item_Product pip = availableHUPIItemProductRecords.get(0);
defaultLUTUConfig.setM_HU_PI_Item_Product(pip);
defaultLUTUConfig.setM_TU_HU_PI_ID(pip.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI_ID());
defaultLUTUConfig.setQtyCU(pip.getQty());
final List<I_M_HU_PI_Item> luPIItems = getAvailableLuPIItems(pip, defaultLUTUConfig.getC_BPartner());
if (luPIItems.isEmpty()) {
defaultLUTUConfig.setM_LU_HU_PI_Item(null);
defaultLUTUConfig.setM_LU_HU_PI(null);
} else {
final I_M_HU_PI_Item luPiItem = luPIItems.get(0);
defaultLUTUConfig.setM_LU_HU_PI_Item(luPiItem);
defaultLUTUConfig.setQtyTU(luPiItem.getQty());
defaultLUTUConfig.setM_LU_HU_PI_ID(luPiItem.getM_HU_PI_Version().getM_HU_PI_ID());
}
}
use of de.metas.handlingunits.model.I_M_HU_PI_Item in project metasfresh-webui-api by metasfresh.
the class PackingInfoProcessParams method getAvailableLuPIItems.
private List<I_M_HU_PI_Item> getAvailableLuPIItems(@NonNull final I_M_HU_PI_Item_Product pip, @Nullable final I_C_BPartner bPartner) {
final IHandlingUnitsDAO handlingUnitsDAO = Services.get(IHandlingUnitsDAO.class);
final I_M_HU_PI piOfCurrentPip = pip.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI();
final List<I_M_HU_PI_Item> luPIItems = handlingUnitsDAO.retrieveParentPIItemsForParentPI(piOfCurrentPip, // huUnitType
null, bPartner);
return luPIItems;
}
use of de.metas.handlingunits.model.I_M_HU_PI_Item in project metasfresh-webui-api by metasfresh.
the class WEBUIHUCreationWithSerialNumberService method createNonAggregatedTU.
private I_M_HU createNonAggregatedTU(final HUEditorRow tuRow, final HUEditorRow luRow) {
final I_M_HU newTU = newHUTransformation().tuToNewTUs(tuRow.getM_HU(), BigDecimal.ONE).get(0);
if (luRow != null) {
final I_M_HU oldLU = luRow.getM_HU();
if (handlingUnitsBL.isDestroyed(oldLU)) {
final I_M_HU_PI_Item luPIItem = oldLU.getM_HU_LUTU_Configuration().getM_LU_HU_PI_Item();
final List<I_M_HU> tuToNewLUs = newHUTransformation().tuToNewLUs(newTU, BigDecimal.ONE, luPIItem, false);
huIDsToRemove.add(oldLU.getM_HU_ID());
huIDsAdded.add(tuToNewLUs.get(0).getM_HU_ID());
} else {
moveTUToLU(newTU.getM_HU_ID(), luRow, tuRow);
}
}
return newTU;
}
use of de.metas.handlingunits.model.I_M_HU_PI_Item in project metasfresh-webui-api by metasfresh.
the class WEBUI_M_ReceiptSchedule_ReceiveHUs_UsingConfig method createM_HU_LUTU_Configuration.
@Override
protected I_M_HU_LUTU_Configuration createM_HU_LUTU_Configuration(final I_M_HU_LUTU_Configuration template) {
// Validate parameters
final int M_LU_HU_PI_ID = p_M_LU_HU_PI_ID;
final int M_HU_PI_Item_Product_ID = p_M_HU_PI_Item_Product_ID;
final BigDecimal qtyCU = p_QtyCU;
final BigDecimal qtyTU = p_QtyTU;
final BigDecimal qtyLU = p_QtyLU;
if (M_HU_PI_Item_Product_ID <= 0) {
throw new FillMandatoryException(PARAM_M_HU_PI_Item_Product_ID);
}
if (qtyCU == null || qtyCU.signum() <= 0) {
throw new FillMandatoryException(PARAM_QtyCU);
}
if (qtyTU == null || qtyTU.signum() <= 0) {
throw new FillMandatoryException(PARAM_QtyTU);
}
final I_M_HU_LUTU_Configuration lutuConfigurationNew = InterfaceWrapperHelper.copy().setFrom(template).copyToNew(I_M_HU_LUTU_Configuration.class);
//
// CU
lutuConfigurationNew.setQtyCU(qtyCU);
lutuConfigurationNew.setIsInfiniteQtyCU(false);
//
// TU
final I_M_HU_PI_Item_Product tuPIItemProduct = InterfaceWrapperHelper.create(getCtx(), M_HU_PI_Item_Product_ID, I_M_HU_PI_Item_Product.class, ITrx.TRXNAME_None);
final I_M_HU_PI tuPI = tuPIItemProduct.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI();
lutuConfigurationNew.setM_HU_PI_Item_Product(tuPIItemProduct);
lutuConfigurationNew.setM_TU_HU_PI(tuPI);
lutuConfigurationNew.setQtyTU(qtyTU);
lutuConfigurationNew.setIsInfiniteQtyTU(false);
// LU
if (M_LU_HU_PI_ID > 0) {
if (qtyLU == null || qtyLU.signum() <= 0) {
throw new FillMandatoryException(PARAM_QtyLU);
}
final I_M_HU_PI luPI = InterfaceWrapperHelper.create(getCtx(), M_LU_HU_PI_ID, I_M_HU_PI.class, ITrx.TRXNAME_None);
final IHandlingUnitsDAO handlingUnitsDAO = Services.get(IHandlingUnitsDAO.class);
final I_M_HU_PI_Version luPIV = handlingUnitsDAO.retrievePICurrentVersion(luPI);
final I_M_HU_PI_Item luPI_Item = handlingUnitsDAO.retrieveParentPIItemsForParentPI(tuPI, X_M_HU_PI_Version.HU_UNITTYPE_LoadLogistiqueUnit, lutuConfigurationNew.getC_BPartner()).stream().filter(piItem -> piItem.getM_HU_PI_Version_ID() == luPIV.getM_HU_PI_Version_ID()).findFirst().orElseThrow(() -> new AdempiereException(tuPI.getName() + " cannot be loaded to " + luPI.getName()));
lutuConfigurationNew.setM_LU_HU_PI(luPI);
lutuConfigurationNew.setM_LU_HU_PI_Item(luPI_Item);
lutuConfigurationNew.setQtyLU(qtyLU);
lutuConfigurationNew.setIsInfiniteQtyLU(false);
} else {
lutuConfigurationNew.setM_LU_HU_PI(null);
lutuConfigurationNew.setM_LU_HU_PI_Item(null);
lutuConfigurationNew.setQtyLU(BigDecimal.ZERO);
}
return lutuConfigurationNew;
}
Aggregations