Search in sources :

Example 1 with PlainHUPackingAware

use of de.metas.adempiere.gui.search.impl.PlainHUPackingAware in project metasfresh-webui-api by metasfresh.

the class OrderLineQuickInputProcessor method createQuickInputPackingAware.

private IHUPackingAware createQuickInputPackingAware(@NonNull final I_C_Order order, @NonNull final IOrderLineQuickInput quickInput) {
    final PlainHUPackingAware huPackingAware = createAndInitHuPackingAware(order, quickInput);
    // Get quickInput's Qty
    final BigDecimal quickInputQty = quickInput.getQty();
    if (quickInputQty == null || quickInputQty.signum() <= 0) {
        logger.warn("Invalid Qty={} for {}", quickInputQty, quickInput);
        // TODO trl
        throw new AdempiereException("Qty shall be greather than zero");
    }
    huPackingAwareBL.computeAndSetQtysForNewHuPackingAware(huPackingAware, quickInputQty);
    return validateNewHuPackingAware(huPackingAware);
}
Also used : PlainHUPackingAware(de.metas.adempiere.gui.search.impl.PlainHUPackingAware) AdempiereException(org.adempiere.exceptions.AdempiereException) BigDecimal(java.math.BigDecimal)

Example 2 with PlainHUPackingAware

use of de.metas.adempiere.gui.search.impl.PlainHUPackingAware 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;
}
Also used : PlainHUPackingAware(de.metas.adempiere.gui.search.impl.PlainHUPackingAware) I_M_Product(org.compiere.model.I_M_Product) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) ProductAndAttributes(de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes)

Example 3 with PlainHUPackingAware

use of de.metas.adempiere.gui.search.impl.PlainHUPackingAware in project metasfresh-webui-api by metasfresh.

the class ForecastLineQuickInputProcessor method createQuickInputPackingAware.

private IHUPackingAware createQuickInputPackingAware(@NonNull final I_M_Forecast forecast, @NonNull final IForecastLineQuickInput quickInput) {
    final PlainHUPackingAware huPackingAware = createAndInitHuPackingAware(forecast, quickInput);
    final BigDecimal quickInputQty = quickInput.getQty();
    if (quickInputQty == null || quickInputQty.signum() <= 0) {
        throw new AdempiereException("Qty shall be greather than zero");
    }
    huPackingAwareBL.computeAndSetQtysForNewHuPackingAware(huPackingAware, quickInputQty);
    return validateNewHuPackingAware(huPackingAware);
}
Also used : PlainHUPackingAware(de.metas.adempiere.gui.search.impl.PlainHUPackingAware) AdempiereException(org.adempiere.exceptions.AdempiereException) BigDecimal(java.math.BigDecimal)

Example 4 with PlainHUPackingAware

use of de.metas.adempiere.gui.search.impl.PlainHUPackingAware in project metasfresh-webui-api by metasfresh.

the class ForecastLineQuickInputProcessor method createAndInitHuPackingAware.

private PlainHUPackingAware createAndInitHuPackingAware(@NonNull final I_M_Forecast forecast, @NonNull final IForecastLineQuickInput quickInput) {
    final PlainHUPackingAware huPackingAware = new PlainHUPackingAware();
    huPackingAware.setC_BPartner(forecast.getC_BPartner());
    huPackingAware.setDateOrdered(forecast.getDatePromised());
    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;
}
Also used : PlainHUPackingAware(de.metas.adempiere.gui.search.impl.PlainHUPackingAware) I_M_Product(org.compiere.model.I_M_Product) I_M_HU_PI_Item_Product(de.metas.handlingunits.model.I_M_HU_PI_Item_Product) ProductAndAttributes(de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes)

Aggregations

PlainHUPackingAware (de.metas.adempiere.gui.search.impl.PlainHUPackingAware)4 I_M_HU_PI_Item_Product (de.metas.handlingunits.model.I_M_HU_PI_Item_Product)2 ProductAndAttributes (de.metas.ui.web.window.descriptor.sql.ProductLookupDescriptor.ProductAndAttributes)2 BigDecimal (java.math.BigDecimal)2 AdempiereException (org.adempiere.exceptions.AdempiereException)2 I_M_Product (org.compiere.model.I_M_Product)2