From 8a6f3709b03fd9319aabe7e1a39f79870074ccbe Mon Sep 17 00:00:00 2001 From: Elaine Tan Date: Tue, 24 Dec 2013 16:31:49 +0800 Subject: [PATCH] IDEMPIERE-1632 When match 1 receipt linked 1 PO with two invoice. 2 new matchPO is create with error post - set invoice info for match po when the quantity is the same else create match po record for po-invoice --- .../src/org/compiere/model/MMatchPO.java | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/org.adempiere.base/src/org/compiere/model/MMatchPO.java b/org.adempiere.base/src/org/compiere/model/MMatchPO.java index 0cd62f966e..b912ab2852 100644 --- a/org.adempiere.base/src/org/compiere/model/MMatchPO.java +++ b/org.adempiere.base/src/org/compiere/model/MMatchPO.java @@ -791,8 +791,25 @@ public class MMatchPO extends X_M_MatchPO if (mpi[i].getC_InvoiceLine_ID() != 0 && mpi[i].getM_AttributeSetInstance_ID() == getM_AttributeSetInstance_ID()) { - setC_InvoiceLine_ID(mpi[i].getC_InvoiceLine_ID()); - break; + if (mpi[i].getQty().compareTo(getQty()) == 0) // same quantity + { + setC_InvoiceLine_ID(mpi[i].getC_InvoiceLine_ID()); + break; + } + else // create MatchPO record for PO-Invoice if different quantity + { + MInvoiceLine il = new MInvoiceLine(getCtx(), mpi[i].getC_InvoiceLine_ID(), get_TrxName()); + MMatchPO match = new MMatchPO(il, getDateTrx(), mpi[i].getQty()); + match.setC_OrderLine_ID(getC_OrderLine_ID()); + if (!match.save()) + { + String msg = "Failed to create match po"; + ValueNamePair error = CLogger.retrieveError(); + if (error != null) + msg = msg + " " + error.getName(); + throw new RuntimeException(msg); + } + } } } }