Fixes Issue 30491: Return from Customer Pick&Edit Lines allows to enter more
authorAtul Gaware <atul.gaware@openbravo.com>
Mon, 03 Aug 2015 23:08:59 +0530
changeset 27608 b0fbae0ed40c
parent 27552 01405101d810
child 27609 14a82c0a34bd
Fixes Issue 30491: Return from Customer Pick&Edit Lines allows to enter more
quantity to return than the pending to be returned

Return document has negative movementqty so ReturnQtyOtherRM was negative.
It should be postive so unlike ReturnQty it is multiplied with -1 as in prev
Datasource prior to transforming it to HQL PE. Where clause which checks
MovementQty of shipment line with the ReturnQtyOtherRM was missing. Sum of
Shipmentline MovementQty and ReturnQtyOtherRM should not be zero. It is added
to fix the problem.
src-db/database/sourcedata/AD_TABLE.xml
--- a/src-db/database/sourcedata/AD_TABLE.xml	Tue Jul 28 05:58:57 2015 +0000
+++ b/src-db/database/sourcedata/AD_TABLE.xml	Mon Aug 03 23:08:59 2015 +0530
@@ -11788,14 +11788,9 @@
 iol.uOM as uOM, iol.id as goodsShipmentLine, iol.movementQuantity as movementQuantity,
 iol.shipmentReceipt.businessPartner as businessPartner, iol.shipmentReceipt.documentNo as shipmentNumber,
 iol.shipmentReceipt.movementDate as movementDate,  attributeSetValue as attributeSetValue,
-coalesce((select sum(ol.orderedQuantity)
-from OrderLine as ol
-left join ol.salesOrder as o
-where ol.goodsShipmentLine = iol
-and o.processed = true
-and o.documentStatus <> 'VO'), 0) as returnQtyOtherRM,
+(@returnedOthersLeftClause@)*(-1) as returnQtyOtherRM,
 (case when (select ('Y') from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol) is null then false else true end) as obSelected,
-coalesce((select ol.orderedQuantity from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol),0)*(-1) as returned,
+(@returnedLeftClause@)*(-1) as returned,
 (select ol.returnReason from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol) as returnReason,
 coalesce((select ol.tax from OrderLine as ol where ol.salesOrder.id = :salesOrderId and ol.goodsShipmentLine = iol) ,
 @taxSubQuery@) as tax,
@@ -11813,6 +11808,7 @@
 where io.businessPartner.id = :businessPartnerId 
 and io.processed = true and io.documentStatus <> 'VO' 
 and io.salesTransaction = @isSalesTransaction@ 
+and (iol.movementQuantity+(@returnedOthersLeftClause@) <> 0) 
 and @insertion_point_0@
 and @additional_filters@]]></HQLQUERY>
 <!--CDB9DC9655F24DF8AB41AA0ADBD04390-->  <ENTITY_ALIAS><![CDATA[iol]]></ENTITY_ALIAS>