From 67d8427774df66cd892a67ddbd7be97077c6e6dc Mon Sep 17 00:00:00 2001 From: teo_sarca Date: Tue, 13 Jan 2009 13:08:46 +0000 Subject: [PATCH] Libero QA: LiberoValidator - fix intendation MPPMRP.C_OrderLine - fix SQL boolean logic; Victor, please ALWAYS use brackets when write boolean logic --- .../org/eevolution/model/LiberoValidator.java | 83 +++++++++---------- base/src/org/eevolution/model/MPPMRP.java | 11 +-- 2 files changed, 45 insertions(+), 49 deletions(-) diff --git a/base/src/org/eevolution/model/LiberoValidator.java b/base/src/org/eevolution/model/LiberoValidator.java index 1a543e2490..63d6d92655 100644 --- a/base/src/org/eevolution/model/LiberoValidator.java +++ b/base/src/org/eevolution/model/LiberoValidator.java @@ -181,55 +181,54 @@ public class LiberoValidator implements ModelValidator MInOut inout = (MInOut)po; if(inout.isSOTrx()) { - final String whereClause = "C_OrderLine_ID IS NOT NULL AND EXISTS ( SELECT 1 FROM C_OrderLine ol , M_InOutLine iol WHERE ol.C_OrderLine_ID=iol.C_OrderLine_ID AND iol.M_InOut_ID=? )"; - Collection orders = new Query(po.getCtx(), MPPOrder.Table_Name, whereClause, po.get_TrxName()) - .setParameters(new Object[]{inout.getM_InOut_ID()}) - .list(); - for(MPPOrder order : orders) - { - String description = order.getDescription() != null ? order.getDescription() : "" - + Msg.translate(inout.getCtx(), MInOut.COLUMNNAME_M_InOut_ID) - + " : " - + Msg.translate(inout.getCtx(), MInOut.COLUMNNAME_DocumentNo); - - order.setDescription(description); - order.closeIt(); - order.setDocStatus(MPPOrder.DOCACTION_Close); - order.setDocAction(MPPOrder.DOCACTION_None); - order.saveEx(); - } - } - } - else - { + final String whereClause = "C_OrderLine_ID IS NOT NULL" + +" AND EXISTS (SELECT 1 FROM C_OrderLine ol , M_InOutLine iol" + +" WHERE ol.C_OrderLine_ID=iol.C_OrderLine_ID AND iol.M_InOut_ID=? )"; + Collection orders = new Query(po.getCtx(), MPPOrder.Table_Name, whereClause, po.get_TrxName()) + .setParameters(new Object[]{inout.getM_InOut_ID()}) + .list(); + for(MPPOrder order : orders) + { + String description = order.getDescription() != null ? order.getDescription() : "" + + Msg.translate(inout.getCtx(), MInOut.COLUMNNAME_M_InOut_ID) + + " : " + + Msg.translate(inout.getCtx(), MInOut.COLUMNNAME_DocumentNo); + + order.setDescription(description); + order.closeIt(); + order.setDocStatus(MPPOrder.DOCACTION_Close); + order.setDocAction(MPPOrder.DOCACTION_None); + order.saveEx(); + } + } } - if (po instanceof MInOut && timing == TIMING_AFTER_COMPLETE) + else if (po instanceof MInOut && timing == TIMING_AFTER_COMPLETE) { MInOut inout = (MInOut)po; - - for (MInOutLine line : inout.getLines()) + + for (MInOutLine line : inout.getLines()) + { + final String whereClause = "C_OrderLine_ID=? AND PP_Cost_Collector_ID IS NOT NULL"; + Collection olines = new Query(po.getCtx(), MOrderLine.Table_Name, whereClause, po.get_TrxName()) + .setParameters(new Object[]{line.getC_OrderLine_ID()}) + .list(); + for (MOrderLine oline : olines) { - final String whereClause = "C_OrderLine_ID=? AND PP_Cost_Collector_ID IS NOT NULL"; - Collection olines = new Query(po.getCtx(), MOrderLine.Table_Name, whereClause, po.get_TrxName()) - .setParameters(new Object[]{line.getC_OrderLine_ID()}) - .list(); - for (MOrderLine oline : olines) - { - if(oline.getQtyOrdered().compareTo(oline.getQtyDelivered()) >= 0) - { - MPPCostCollector cc = new MPPCostCollector(po.getCtx(), oline.getPP_Cost_Collector_ID(), po.get_TrxName()); - String docStatus = cc.completeIt(); - cc.setDocStatus(docStatus); - cc.setDocAction(MPPCostCollector.DOCACTION_Close); - cc.saveEx(); - return Msg.translate(po.getCtx(), "PP_Order_ID") - +":"+cc.getPP_Order().getDocumentNo() - +Msg.translate(po.getCtx(),"PP_Order_Node_ID") - +":"+cc.getPP_Order_Node().getValue(); - } + if(oline.getQtyOrdered().compareTo(oline.getQtyDelivered()) >= 0) + { + MPPCostCollector cc = new MPPCostCollector(po.getCtx(), oline.getPP_Cost_Collector_ID(), po.get_TrxName()); + String docStatus = cc.completeIt(); + cc.setDocStatus(docStatus); + cc.setDocAction(MPPCostCollector.DOCACTION_Close); + cc.saveEx(); + return Msg.translate(po.getCtx(), "PP_Order_ID") + +":"+cc.getPP_Order().getDocumentNo() + +Msg.translate(po.getCtx(),"PP_Order_Node_ID") + +":"+cc.getPP_Order_Node().getValue(); } } } + } return null; } // docValidate diff --git a/base/src/org/eevolution/model/MPPMRP.java b/base/src/org/eevolution/model/MPPMRP.java index da2786acbb..c690f52b82 100644 --- a/base/src/org/eevolution/model/MPPMRP.java +++ b/base/src/org/eevolution/model/MPPMRP.java @@ -369,8 +369,7 @@ public class MPPMRP extends X_PP_MRP MPPOrder order = MPPOrder.forC_OrderLine_ID(ol.getCtx(), ol.get_ID(), ol.get_TrxName()); if (order == null) { - final String whereClause = MPPProductBOM.COLUMNNAME_BOMType+"=? " - +" OR "+MPPProductBOM.COLUMNNAME_BOMType+"=? " + final String whereClause = MPPProductBOM.COLUMNNAME_BOMType+" IN (?,?)" +" AND "+MPPProductBOM.COLUMNNAME_BOMUse+"=?" +" AND "+MPPProductBOM.COLUMNNAME_M_Product_ID+"=?"; MPPProductBOM bom = new Query(ol.getCtx(), MPPProductBOM.Table_Name, whereClause, null) @@ -389,11 +388,9 @@ public class MPPMRP extends X_PP_MRP if(pp != null) { bom = (MPPProductBOM) pp.getPP_Product_BOM(); - if(bom != null && !MPPProductBOM.BOMTYPE_Make_To_Order.equals(bom.getBOMType())) - { - bom = null; - } - if(bom != null && !MPPProductBOM.BOMTYPE_Make_To_Kit.equals(bom.getBOMType())) + if( bom != null + && !MPPProductBOM.BOMTYPE_Make_To_Order.equals(bom.getBOMType()) + && !MPPProductBOM.BOMTYPE_Make_To_Kit.equals(bom.getBOMType()) ) { bom = null; }