diff --git a/base/src/org/compiere/model/MMatchInv.java b/base/src/org/compiere/model/MMatchInv.java index a5281c7304..6d144f5d9e 100644 --- a/base/src/org/compiere/model/MMatchInv.java +++ b/base/src/org/compiere/model/MMatchInv.java @@ -40,6 +40,10 @@ import org.compiere.util.Env; * * @author Teo Sarca, SC ARHIPAC SERVICE SRL *
  • BF [ 1926113 ] MMatchInv.getNewerDateAcct() should work in trx + * + * @author Bayu Cahya, Sistematika + *
  • BF [ 2240484 ] Re MatchingPO, MMatchPO doesn't contains Invoice info + * */ public class MMatchInv extends X_M_MatchInv { @@ -541,4 +545,47 @@ public class MMatchInv extends X_M_MatchInv return ""; } + // Bayu, Sistematika + /** + * Get Inv Matches for InOutLine + * @param ctx context + * @param M_InOutLine_ID shipment + * @param trxName transaction + * @return array of matches + */ + public static MMatchInv[] getInOutLine (Properties ctx, + int M_InOutLine_ID, String trxName) + { + if (M_InOutLine_ID == 0) + return new MMatchInv[]{}; + // + String sql = "SELECT * FROM M_MatchInv m " + + "WHERE m.M_InOutLine_ID=?"; + ArrayList list = new ArrayList(); + PreparedStatement pstmt = null; + ResultSet rs = null; + try + { + pstmt = DB.prepareStatement (sql, trxName); + pstmt.setInt (1, M_InOutLine_ID); + rs = pstmt.executeQuery (); + while (rs.next ()) + list.add (new MMatchInv (ctx, rs, trxName)); + } + catch (Exception e) + { + s_log.log(Level.SEVERE, sql, e); + } + finally + { + DB.close(rs, pstmt); + rs = null; pstmt = null; + } + MMatchInv[] retValue = new MMatchInv[list.size()]; + list.toArray (retValue); + return retValue; + } // getInOutLine + // end Bayu + + } // MMatchInv diff --git a/base/src/org/compiere/model/MMatchPO.java b/base/src/org/compiere/model/MMatchPO.java index e1d7486989..1e800fc151 100644 --- a/base/src/org/compiere/model/MMatchPO.java +++ b/base/src/org/compiere/model/MMatchPO.java @@ -37,6 +37,9 @@ import org.compiere.util.Env; * * @author Jorg Janke * @version $Id: MMatchPO.java,v 1.3 2006/07/30 00:51:03 jjanke Exp $ + * + * @author Bayu Cahya, Sistematika + *
  • BF [ 2240484 ] Re MatchingPO, MMatchPO doesn't contains Invoice info */ public class MMatchPO extends X_M_MatchPO { @@ -506,6 +509,24 @@ public class MMatchPO extends X_M_MatchPO setM_AttributeSetInstance_ID(iol.getM_AttributeSetInstance_ID()); } + // Bayu, Sistematika + // BF [ 2240484 ] Re MatchingPO, MMatchPO doesn't contains Invoice info + // If newRecord, set c_invoiceline_id while null + if (newRecord && getC_InvoiceLine_ID() == 0) + { + MMatchInv[] mpi = MMatchInv.getInOutLine(getCtx(), getM_InOutLine_ID(), get_TrxName()); + for (int i = 0; i < mpi.length; i++) + { + if (mpi[i].getC_InvoiceLine_ID() != 0 && + mpi[i].getM_AttributeSetInstance_ID() == getM_AttributeSetInstance_ID()) + { + setC_InvoiceLine_ID(mpi[i].getC_InvoiceLine_ID()); + break; + } + } + } + // end Bayu + // Find OrderLine if (getC_OrderLine_ID() == 0) {