From 98d49aa171bf5b719c0541ce1e339762b3229fa1 Mon Sep 17 00:00:00 2001 From: Teo Sarca Date: Tue, 7 Mar 2017 18:26:48 +0200 Subject: [PATCH] #228 Remaining TU Qty in Quickaction and HU Config --- ...ule_GeneratePlanningHUs_UsingDefaults.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/metasfresh-webui-api/src/main/java/de/metas/ui/web/handlingunits/process/WEBUI_M_ReceiptSchedule_GeneratePlanningHUs_UsingDefaults.java b/metasfresh-webui-api/src/main/java/de/metas/ui/web/handlingunits/process/WEBUI_M_ReceiptSchedule_GeneratePlanningHUs_UsingDefaults.java index d88067a8a..f95b7e558 100644 --- a/metasfresh-webui-api/src/main/java/de/metas/ui/web/handlingunits/process/WEBUI_M_ReceiptSchedule_GeneratePlanningHUs_UsingDefaults.java +++ b/metasfresh-webui-api/src/main/java/de/metas/ui/web/handlingunits/process/WEBUI_M_ReceiptSchedule_GeneratePlanningHUs_UsingDefaults.java @@ -12,6 +12,7 @@ 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_ReceiptSchedule; +import de.metas.handlingunits.receiptschedule.IHUReceiptScheduleBL; import de.metas.process.IProcessPreconditionsContext; import de.metas.process.ProcessPreconditionsResolution; @@ -55,6 +56,7 @@ private String buildDefaultPackingInfo(final IProcessPreconditionsContext contex } final I_M_HU_LUTU_Configuration lutuConfig = getCurrentLUTUConfiguration(receiptSchedule); + adjustLUTUConfiguration(lutuConfig, receiptSchedule); final StringBuilder packingInfo = new StringBuilder(); @@ -128,9 +130,32 @@ protected I_M_HU_LUTU_Configuration createM_HU_LUTU_Configuration(final I_M_HU_L .setFrom(template) .copyToNew(I_M_HU_LUTU_Configuration.class); + adjustLUTUConfiguration(lutuConfigurationNew, getM_ReceiptSchedule()); lutuConfigurationNew.setQtyLU(BigDecimal.ONE); + // NOTE: don't save it return lutuConfigurationNew; } + private static final void adjustLUTUConfiguration(final I_M_HU_LUTU_Configuration lutuConfig, final I_M_ReceiptSchedule receiptSchedule) + { + // + // Adjust LU + lutuConfig.setQtyLU(BigDecimal.ONE); + + // + // Adjust TU + // * if the standard QtyTU is less than how much is available to be received => enforce the available Qty + // * else always take the standard QtyTU + // see https://github.com/metasfresh/metasfresh-webui/issues/228 + { + final BigDecimal qtyToMoveTU = Services.get(IHUReceiptScheduleBL.class).getQtyToMoveTU(receiptSchedule); + + if (qtyToMoveTU.signum() > 0 && qtyToMoveTU.compareTo(lutuConfig.getQtyTU()) < 0) + { + lutuConfig.setQtyTU(qtyToMoveTU); + } + } + } + }