Skip to content

Commit

Permalink
#699 Add callouts
Browse files Browse the repository at this point in the history
#699 Implement Batch entry in Forecast Window
metasfresh/metasfresh-webui-api-legacy#699
  • Loading branch information
cristinamghita committed Nov 29, 2017
1 parent 4becf99 commit 7560dfe
Showing 1 changed file with 40 additions and 1 deletion.
@@ -1,5 +1,12 @@
package de.metas.handlingunits.model.validator;

import java.math.BigDecimal;

import org.adempiere.ad.callout.annotations.Callout;
import org.adempiere.ad.callout.annotations.CalloutMethod;
import org.adempiere.ad.callout.spi.IProgramaticCalloutProvider;
import org.adempiere.ad.modelvalidator.annotations.Init;

/*
* #%L
* de.metas.handlingunits.base
Expand Down Expand Up @@ -35,8 +42,15 @@
import de.metas.handlingunits.model.I_M_ForecastLine;

@Validator(I_M_ForecastLine.class)
@Callout(I_M_ForecastLine.class)
public class M_ForecastLine
{
@Init
public void registerCallout()
{
Services.get(IProgramaticCalloutProvider.class).registerAnnotatedCallout(this);
}

@ModelChange(timings = {
ModelValidator.TYPE_BEFORE_NEW,
ModelValidator.TYPE_BEFORE_CHANGE
Expand All @@ -48,18 +62,43 @@ public class M_ForecastLine
})
public void add_M_HU_PI_Item_Product(final I_M_ForecastLine forecastLine)
{
final IHUDocumentHandlerFactory huDocumentHandlerFactory = Services.get(IHUDocumentHandlerFactory.class);
final IHUDocumentHandlerFactory huDocumentHandlerFactory = Services.get(IHUDocumentHandlerFactory.class);
final IHUDocumentHandler handler = huDocumentHandlerFactory.createHandler(I_M_ForecastLine.Table_Name);
if (null != handler)
{
handler.applyChangesFor(forecastLine);
updateQtyPacks(forecastLine);
updateQtyCalculated(forecastLine);
}
}

@CalloutMethod(columnNames = { I_M_ForecastLine.COLUMNNAME_Qty })
public void updateQtyTU(final I_M_ForecastLine forecastLine)
{
updateQtyPacks(forecastLine);
updateQtyCalculated(forecastLine);
}

@CalloutMethod(columnNames = { I_M_ForecastLine.COLUMNNAME_QtyEnteredTU, I_M_ForecastLine.COLUMNNAME_M_HU_PI_Item_Product_ID })
public void updateQtyCU(final I_M_ForecastLine forecastLine)
{
final IHUPackingAware packingAware = new ForecastLineHUPackingAware(forecastLine);
final Integer qtyPacks = packingAware.getQtyPacks().intValue();
Services.get(IHUPackingAwareBL.class).setQty(packingAware, qtyPacks);
}


private void updateQtyPacks(final I_M_ForecastLine forecastLine)
{
final IHUPackingAware packingAware = new ForecastLineHUPackingAware(forecastLine);
Services.get(IHUPackingAwareBL.class).setQtyPacks(packingAware);
}

private void updateQtyCalculated(final I_M_ForecastLine forecastLine)
{
final IHUPackingAware packingAware = new ForecastLineHUPackingAware(forecastLine);
final BigDecimal qty = packingAware.getQty();
packingAware.setQty(qty);
}

}

0 comments on commit 7560dfe

Please sign in to comment.