Skip to content

Commit

Permalink
fix the pp-order-issue parameters
Browse files Browse the repository at this point in the history
LookupValue: IntegerLookupValue.of (constant!) values are declared as
"translated" see javadoc

WEBUI_PP_Order_Receipt etc
* changed parameters to allow specifying a TU and LU if there is none
given from the PP_Order

JSONViewRow: if no attributes are supported, then set that value to
false

528: Exception when opening PP Order issue / receipt 

Task-Url: #528
  • Loading branch information
metas-ts committed Aug 3, 2017
1 parent 443ff49 commit 7e1dfb3
Show file tree
Hide file tree
Showing 11 changed files with 256 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private LookupValuesList getLULookupValues(final LookupDataSourceContext context
*
* @return a list of HU PI items that link the currently selected TU with a TUperLU-qty and a LU packing instruction.
*/
@ProcessParamLookupValuesProvider(parameterName = PARAM_M_HU_PI_Item_ID, dependsOn = { PARAM_Action }, numericKey = true, lookupTableName = I_M_HU_PI_Item.Table_Name)
@ProcessParamLookupValuesProvider(parameterName = PARAM_M_HU_PI_Item_ID, dependsOn = PARAM_Action , numericKey = true, lookupTableName = I_M_HU_PI_Item.Table_Name)
private LookupValuesList getM_HU_PI_Item_ID()
{
return newParametersFiller().getM_HU_PI_Item_IDs();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public class WebuiHUTransformCommand
public static enum ActionType
{
/**
* Invokes {@link HUTransferService#cuToNewCU(I_M_HU, BigDecimal)}.
* Invokes {@link HUTransformService#cuToNewCU(I_M_HU, BigDecimal)}.
*/
CU_To_NewCU,

/**
* Invokes {@link HUTransferService#cuToNewTUs(I_M_HU, BigDecimal, I_M_HU_PI_Item_Product, boolean)}.
* Invokes {@link HUTransformService#cuToNewTUs(I_M_HU, BigDecimal, I_M_HU_PI_Item_Product, boolean)}.
*/
CU_To_NewTUs,

Expand All @@ -92,22 +92,22 @@ public static enum ActionType
TU_Set_Ownership,

/**
* Invokes {@link HUTransferService#cuToExistingTU(I_M_HU, BigDecimal, I_M_HU)}.
* Invokes {@link HUTransformService#cuToExistingTU(I_M_HU, BigDecimal, I_M_HU)}.
*/
CU_To_ExistingTU,

/**
* Invokes {@link HUTransferService#tuToNewTUs(I_M_HU, BigDecimal, boolean)}.
* Invokes {@link HUTransformService#tuToNewTUs(I_M_HU, BigDecimal, boolean)}.
*/
TU_To_NewTUs,

/**
* Invokes {@link HUTransferService#tuToNewLUs(I_M_HU, BigDecimal, I_M_HU_PI_Item, boolean)}.
* Invokes {@link HUTransformService#tuToNewLUs(I_M_HU, BigDecimal, I_M_HU_PI_Item, boolean)}.
*/
TU_To_NewLUs,

/**
* Invokes {@link HUTransferService#tuToExistingLU(I_M_HU, BigDecimal, I_M_HU).
* Invokes {@link HUTransformService#tuToExistingLU(I_M_HU, BigDecimal, I_M_HU).
*/
TU_To_ExistingLU,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package de.metas.ui.web.handlingunits.process;

import java.math.RoundingMode;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
Expand All @@ -12,7 +11,6 @@
import org.adempiere.ad.service.IADReferenceDAO;
import org.adempiere.ad.service.IADReferenceDAO.ADRefListItem;
import org.adempiere.util.Services;
import org.adempiere.util.StringUtils;
import org.compiere.model.I_AD_Process_Para;
import org.compiere.model.I_C_BPartner;
import org.compiere.util.DisplayType;
Expand Down Expand Up @@ -237,7 +235,6 @@ public LookupValuesList getM_HU_PI_Item_Products()

private static LookupValuesList retrieveHUPItemProductsForNewTU(final HUEditorRow cuRow)
{
// final HUEditorRow cuRow = getSingleSelectedRow();
final I_M_Product product = cuRow.getM_Product();
final I_C_BPartner bPartner = cuRow.getM_HU().getC_BPartner();

Expand Down Expand Up @@ -380,16 +377,8 @@ public LookupValuesList getM_HU_PI_Item_IDs()

return luPIItems.stream()
.filter(luPIItem -> luPIItem.getM_HU_PI_Version().isCurrent() && luPIItem.getM_HU_PI_Version().isActive() && luPIItem.getM_HU_PI_Version().getM_HU_PI().isActive())
.map(luPIItem -> IntegerLookupValue.of(luPIItem.getM_HU_PI_Item_ID(), buildHUPIItemString(luPIItem)))
.map(luPIItem -> IntegerLookupValue.of(luPIItem.getM_HU_PI_Item_ID(), WEBUI_ProcessHelper.buildHUPIItemString(luPIItem)))
.sorted(Comparator.comparing(IntegerLookupValue::getDisplayName))
.collect(LookupValuesList.collect());
}

private static String buildHUPIItemString(final I_M_HU_PI_Item huPIItem)
{
return StringUtils.formatMessage("{} ({} x {})",
huPIItem.getM_HU_PI_Version().getName(),
huPIItem.getQty().setScale(0, RoundingMode.HALF_UP), // it's always integer quantities
huPIItem.getIncluded_HU_PI().getName());
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package de.metas.ui.web.handlingunits.util;

import java.math.RoundingMode;
import java.util.Comparator;
import java.util.List;
import java.util.Properties;
import java.util.stream.Stream;

import javax.annotation.Nullable;

import org.adempiere.service.ISysConfigBL;
import org.adempiere.util.Services;
import org.adempiere.util.StringUtils;
import org.compiere.model.I_C_BPartner;
import org.compiere.model.I_M_Product;
import org.compiere.util.Env;

import de.metas.handlingunits.IHUPIItemProductDAO;
import de.metas.handlingunits.model.I_M_HU_PI_Item;
import de.metas.handlingunits.model.I_M_HU_PI_Item_Product;
import de.metas.ui.web.window.datatypes.LookupValue.IntegerLookupValue;
import de.metas.ui.web.window.datatypes.LookupValuesList;
Expand Down Expand Up @@ -53,23 +58,40 @@ public class WEBUI_ProcessHelper
* @param bPartner optional, may be null
* @return
*/
public LookupValuesList retrieveHUPIItemProducts(final Properties ctx,
@NonNull final I_M_Product product,
final I_C_BPartner bPartner)
public LookupValuesList retrieveHUPIItemProducts(
@NonNull final Properties ctx,
@NonNull final I_M_Product product,
@Nullable final I_C_BPartner bPartner)
{
final List<I_M_HU_PI_Item_Product> list = retrieveHUPIItemProductRecords(ctx, product, bPartner);

return list.stream()
.sorted(Comparator.comparing(I_M_HU_PI_Item_Product::getName))
.map(huPIItemProduct -> IntegerLookupValue.of(huPIItemProduct.getM_HU_PI_Item_Product_ID(), huPIItemProduct.getName()))
.collect(LookupValuesList.collect());
}

public List<I_M_HU_PI_Item_Product> retrieveHUPIItemProductRecords(
@NonNull final Properties ctx,
@NonNull final I_M_Product product,
@Nullable final I_C_BPartner bPartner)
{
final IHUPIItemProductDAO hupiItemProductDAO = Services.get(IHUPIItemProductDAO.class);
final ISysConfigBL sysConfigBL = Services.get(ISysConfigBL.class);

final boolean allowInfiniteCapacity = sysConfigBL.getBooleanValue(SYSCONFIG_ALLOW_INFINIT_CAPACITY_TUS, true,
Env.getAD_Client_ID(ctx), Env.getAD_Org_ID(ctx));

final Stream<I_M_HU_PI_Item_Product> stream = hupiItemProductDAO
.retrieveTUs(ctx, product, bPartner, allowInfiniteCapacity)
.stream();

return stream
.sorted(Comparator.comparing(I_M_HU_PI_Item_Product::getName))
.map(huPIItemProduct -> IntegerLookupValue.of(huPIItemProduct.getM_HU_PI_Item_Product_ID(), huPIItemProduct.getName()))
.collect(LookupValuesList.collect());
final List<I_M_HU_PI_Item_Product> list = hupiItemProductDAO
.retrieveTUs(ctx, product, bPartner, allowInfiniteCapacity);
return list;
}

public String buildHUPIItemString(final I_M_HU_PI_Item huPIItem)
{
return StringUtils.formatMessage("{} ({} x {})",
huPIItem.getM_HU_PI_Version().getName(),
huPIItem.getQty().setScale(0, RoundingMode.HALF_UP), // it's always integer quantities
huPIItem.getIncluded_HU_PI().getName());
}
}
4 changes: 2 additions & 2 deletions src/main/java/de/metas/ui/web/pporder/PPOrderLineRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,13 @@ public IViewRowAttributes getAttributes() throws EntityNotFoundException
{
if (attributesSupplier == null)
{
throw new EntityNotFoundException("Document does not support attributes");
throw new EntityNotFoundException("This PPOrderLineRow does not support attributes; this=" + this);
}

final IViewRowAttributes attributes = attributesSupplier.get();
if (attributes == null)
{
throw new EntityNotFoundException("Document does not support attributes");
throw new EntityNotFoundException("This PPOrderLineRow does not support attributes; this=" + this);
}
return attributes;
}
Expand Down
Loading

0 comments on commit 7e1dfb3

Please sign in to comment.