Search in sources :

Example 1 with I_M_HU_PI

use of de.metas.handlingunits.model.I_M_HU_PI 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);
}
Also used : I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) I_M_HU_PI(de.metas.handlingunits.model.I_M_HU_PI)

Example 2 with I_M_HU_PI

use of de.metas.handlingunits.model.I_M_HU_PI 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;
}
Also used : IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) I_M_HU_PI(de.metas.handlingunits.model.I_M_HU_PI)

Example 3 with I_M_HU_PI

use of de.metas.handlingunits.model.I_M_HU_PI 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;
}
Also used : IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) I_M_HU_PI_Item(de.metas.handlingunits.model.I_M_HU_PI_Item) I_M_HU_LUTU_Configuration(de.metas.handlingunits.model.I_M_HU_LUTU_Configuration) AdempiereException(org.adempiere.exceptions.AdempiereException) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) I_M_HU_PI_Version(de.metas.handlingunits.model.I_M_HU_PI_Version) FillMandatoryException(org.adempiere.exceptions.FillMandatoryException) I_M_HU_PI(de.metas.handlingunits.model.I_M_HU_PI) BigDecimal(java.math.BigDecimal)

Example 4 with I_M_HU_PI

use of de.metas.handlingunits.model.I_M_HU_PI in project metasfresh-webui-api by metasfresh.

the class HUPackingInfoFormatter method format.

/**
 * Format given packing info.
 *
 * If you want to quickly create some {@link IHUPackingInfo} instances from other objects, please check the {@link HUPackingInfos} facade.
 *
 * @param huPackingInfo
 * @return formatted packing info string
 */
public String format(final IHUPackingInfo huPackingInfo) {
    final StringBuilder packingInfo = new StringBuilder();
    // LU
    if (isShowLU()) {
        final I_M_HU_PI luPI = huPackingInfo.getM_LU_HU_PI();
        if (luPI != null) {
            packingInfo.append(luPI.getName());
        }
    }
    // 
    // TU
    final I_M_HU_PI tuPI = huPackingInfo.getM_TU_HU_PI();
    if (tuPI != null && !Services.get(IHandlingUnitsBL.class).isVirtual(tuPI)) {
        if (packingInfo.length() > 0) {
            packingInfo.append(" x ");
        }
        final BigDecimal qtyTU = huPackingInfo.getQtyTUsPerLU();
        if (!huPackingInfo.isInfiniteQtyTUsPerLU() && qtyTU != null && qtyTU.signum() > 0) {
            packingInfo.append(qtyTU.intValue()).append(" ");
        }
        packingInfo.append(tuPI.getName());
    }
    // 
    // CU
    final BigDecimal qtyCU = huPackingInfo.getQtyCUsPerTU();
    if (!huPackingInfo.isInfiniteQtyCUsPerTU() && qtyCU != null && qtyCU.signum() > 0) {
        if (packingInfo.length() > 0) {
            packingInfo.append(" x ");
        }
        final DecimalFormat qtyFormat = DisplayType.getNumberFormat(DisplayType.Quantity);
        packingInfo.append(qtyFormat.format(qtyCU));
        final I_C_UOM uom = huPackingInfo.getQtyCUsPerTU_UOM();
        final String uomSymbol = uom == null ? null : uom.getUOMSymbol();
        if (uomSymbol != null) {
            packingInfo.append(" ").append(uomSymbol);
        }
    }
    if (packingInfo.length() == 0) {
        // no override
        return null;
    }
    return packingInfo.toString();
}
Also used : IHandlingUnitsBL(de.metas.handlingunits.IHandlingUnitsBL) DecimalFormat(java.text.DecimalFormat) I_M_HU_PI(de.metas.handlingunits.model.I_M_HU_PI) BigDecimal(java.math.BigDecimal) I_C_UOM(org.compiere.model.I_C_UOM)

Example 5 with I_M_HU_PI

use of de.metas.handlingunits.model.I_M_HU_PI in project metasfresh-webui-api by metasfresh.

the class WEBUI_Picking_PickQtyToNewHU method createTU.

/**
 * Creates a new M_HU within the processe's interited trx.
 *
 * @param itemProduct
 * @param locator
 * @return
 */
private static final I_M_HU createTU(@NonNull final I_M_HU_PI_Item_Product itemProduct, @NonNull final I_M_Locator locator) {
    final IHandlingUnitsDAO handlingUnitsDAO = Services.get(IHandlingUnitsDAO.class);
    final IHUTrxBL huTrxBL = Services.get(IHUTrxBL.class);
    final I_M_HU_PI huPI = itemProduct.getM_HU_PI_Item().getM_HU_PI_Version().getM_HU_PI();
    return huTrxBL.createHUContextProcessorExecutor().call(huContext -> handlingUnitsDAO.createHUBuilder(huContext).setM_HU_Item_Parent(// no parent
    null).setM_HU_PI_Item_Product(itemProduct).setM_Locator(locator).setHUStatus(X_M_HU.HUSTATUS_Active).create(huPI));
}
Also used : IHandlingUnitsDAO(de.metas.handlingunits.IHandlingUnitsDAO) IHUTrxBL(de.metas.handlingunits.hutransaction.IHUTrxBL) I_M_HU_PI(de.metas.handlingunits.model.I_M_HU_PI)

Aggregations

I_M_HU_PI (de.metas.handlingunits.model.I_M_HU_PI)5 IHandlingUnitsDAO (de.metas.handlingunits.IHandlingUnitsDAO)3 I_M_HU_PI_Item (de.metas.handlingunits.model.I_M_HU_PI_Item)2 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)2 BigDecimal (java.math.BigDecimal)2 IHandlingUnitsBL (de.metas.handlingunits.IHandlingUnitsBL)1 IHUTrxBL (de.metas.handlingunits.hutransaction.IHUTrxBL)1 I_M_HU_LUTU_Configuration (de.metas.handlingunits.model.I_M_HU_LUTU_Configuration)1 I_M_HU_PI_Version (de.metas.handlingunits.model.I_M_HU_PI_Version)1 DecimalFormat (java.text.DecimalFormat)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 FillMandatoryException (org.adempiere.exceptions.FillMandatoryException)1 I_C_UOM (org.compiere.model.I_C_UOM)1