use of de.metas.handlingunits.model.I_M_HU_PI_Item_Product in project metasfresh-webui-api by metasfresh.
the class OrderLineQuickInputProcessor method createAndInitHuPackingAware.
private PlainHUPackingAware createAndInitHuPackingAware(@NonNull final I_C_Order order, @NonNull final IOrderLineQuickInput quickInput) {
final PlainHUPackingAware huPackingAware = new PlainHUPackingAware();
huPackingAware.setC_BPartner(order.getC_BPartner());
huPackingAware.setDateOrdered(order.getDateOrdered());
huPackingAware.setInDispute(false);
final ProductAndAttributes productAndAttributes = ProductLookupDescriptor.toProductAndAttributes(quickInput.getM_Product_ID());
final I_M_Product product = load(productAndAttributes.getProductId(), I_M_Product.class);
huPackingAware.setM_Product_ID(product.getM_Product_ID());
huPackingAware.setC_UOM(product.getC_UOM());
huPackingAware.setM_AttributeSetInstance_ID(createASI(productAndAttributes));
final I_M_HU_PI_Item_Product piItemProduct = quickInput.getM_HU_PI_Item_Product();
huPackingAware.setM_HU_PI_Item_Product(piItemProduct);
return huPackingAware;
}
use of de.metas.handlingunits.model.I_M_HU_PI_Item_Product in project metasfresh-webui-api by metasfresh.
the class PackingInfoProcessParams method configureLUTUConfigTU.
private void configureLUTUConfigTU(@NonNull final I_M_HU_LUTU_Configuration lutuConfigNew, final int M_HU_PI_Item_Product_ID, @NonNull final BigDecimal qtyTU) {
final I_M_HU_PI_Item_Product tuPIItemProduct = loadOutOfTrx(M_HU_PI_Item_Product_ID, I_M_HU_PI_Item_Product.class);
final I_M_HU_PI tuPI = tuPIItemProduct.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI();
lutuConfigNew.setM_HU_PI_Item_Product(tuPIItemProduct);
lutuConfigNew.setM_TU_HU_PI(tuPI);
lutuConfigNew.setQtyTU(qtyTU);
lutuConfigNew.setIsInfiniteQtyTU(false);
}
use of de.metas.handlingunits.model.I_M_HU_PI_Item_Product 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_Product 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;
}
use of de.metas.handlingunits.model.I_M_HU_PI_Item_Product in project metasfresh-webui-api by metasfresh.
the class WEBUI_ProcessHelper method retrieveHUPIItemProductRecords.
public List<I_M_HU_PI_Item_Product> retrieveHUPIItemProductRecords(@NonNull final Properties ctx, @NonNull final I_M_Product product, @Nullable final I_C_BPartner bPartner, final boolean includeVirtualItem) {
final IHUPIItemProductDAO hupiItemProductDAO = Services.get(IHUPIItemProductDAO.class);
final ISysConfigBL sysConfigBL = Services.get(ISysConfigBL.class);
final boolean allowInfiniteCapacity = sysConfigBL.getBooleanValue(SYSCONFIG_ALLOW_INFINIT_CAPACITY_TUS, true, Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));
final List<I_M_HU_PI_Item_Product> list = hupiItemProductDAO.retrieveTUs(ctx, product, bPartner, allowInfiniteCapacity);
if (includeVirtualItem) {
list.add(hupiItemProductDAO.retrieveVirtualPIMaterialItemProduct(ctx));
}
return list;
}
Aggregations