Skip to content

Commit

Permalink
#236 adjust available TUs in WEBUI_M_ReceiptSchedule_GeneratePlanning…
Browse files Browse the repository at this point in the history
…HUs_UsingConfig params
  • Loading branch information
teosarca committed Mar 8, 2017
1 parent 56db333 commit 5ad5a3e
Showing 1 changed file with 25 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

import de.metas.handlingunits.IHandlingUnitsDAO;
import de.metas.handlingunits.allocation.ILUTUConfigurationFactory;
import de.metas.handlingunits.model.I_C_OrderLine;
import de.metas.handlingunits.model.I_M_HU_LUTU_Configuration;
import de.metas.handlingunits.model.I_M_HU_PI;
import de.metas.handlingunits.model.I_M_HU_PI_Item;
import de.metas.handlingunits.model.I_M_HU_PI_Item_Product;
import de.metas.handlingunits.model.I_M_HU_PI_Version;
import de.metas.handlingunits.model.I_M_ReceiptSchedule;
import de.metas.handlingunits.model.X_M_HU_PI_Version;
import de.metas.handlingunits.receiptschedule.IHUReceiptScheduleBL;
import de.metas.process.IProcessDefaultParameter;
import de.metas.process.IProcessDefaultParametersProvider;
import de.metas.process.Param;
Expand Down Expand Up @@ -74,30 +74,40 @@ private I_M_HU_LUTU_Configuration getDefaultLUTUConfiguration()
{
final I_M_ReceiptSchedule receiptSchedule = getM_ReceiptSchedule();
final I_M_HU_LUTU_Configuration defaultLUTUConfiguration = getCurrentLUTUConfiguration(receiptSchedule);
adjustLUs(defaultLUTUConfiguration, receiptSchedule);
adjustLUTUConfiguration(defaultLUTUConfiguration, receiptSchedule);
_defaultLUTUConfiguration = defaultLUTUConfiguration;
}
return _defaultLUTUConfiguration;
}

private static void adjustLUs(final I_M_HU_LUTU_Configuration lutuConfiguration, final I_M_ReceiptSchedule fromReceiptSchedule)
private static void adjustLUTUConfiguration(final I_M_HU_LUTU_Configuration lutuConfig, final I_M_ReceiptSchedule fromReceiptSchedule)
{
final BigDecimal totalQtyTU = InterfaceWrapperHelper.create(fromReceiptSchedule.getC_OrderLine(), I_C_OrderLine.class).getQtyEnteredTU();
final BigDecimal receivedQtyTU = fromReceiptSchedule.getQtyMovedTU();
final BigDecimal toReceiveQtyTU = totalQtyTU.subtract(receivedQtyTU);

final int qtyLU;
if(toReceiveQtyTU.signum() <= 0)
//
// TU
final BigDecimal qtyToReceiveTU = Services.get(IHUReceiptScheduleBL.class).getQtyToMoveTU(fromReceiptSchedule);
{
qtyLU = 0;
if (qtyToReceiveTU.signum() > 0 && qtyToReceiveTU.compareTo(lutuConfig.getQtyTU()) < 0)
{
lutuConfig.setQtyTU(qtyToReceiveTU);
}
}
else

//
// LU
{
final ILUTUConfigurationFactory lutuConfigurationFactory = Services.get(ILUTUConfigurationFactory.class);
qtyLU = lutuConfigurationFactory.calculateQtyLUForTotalQtyTUs(lutuConfiguration, toReceiveQtyTU);
final int qtyLU;
if (qtyToReceiveTU.signum() <= 0)
{
qtyLU = 0;
}
else
{
final ILUTUConfigurationFactory lutuConfigurationFactory = Services.get(ILUTUConfigurationFactory.class);
qtyLU = lutuConfigurationFactory.calculateQtyLUForTotalQtyTUs(lutuConfig, qtyToReceiveTU);
}

lutuConfig.setQtyLU(BigDecimal.valueOf(qtyLU));
}

lutuConfiguration.setQtyLU(BigDecimal.valueOf(qtyLU));
}

private static final String PARAM_IsSaveLUTUConfiguration = "IsSaveLUTUConfiguration";
Expand Down

0 comments on commit 5ad5a3e

Please sign in to comment.