Applied fix from trunk for revision: 1531848 
===

Fixed bug reported by Simon Maskell in OFBIZ-5344 with a slightly different patch than the one provided by Simon.
 Also added a TODO comment to warn that the current logic doesn't work well for LIFO/FIFO.



git-svn-id: https://svn.apache.org/repos/asf/ofbiz/branches/release13.07@1531849 13f79535-47bb-0310-9956-ffa450edef68