diff --git a/org.adempiere.base/src/org/compiere/model/MInvoice.java b/org.adempiere.base/src/org/compiere/model/MInvoice.java index aa98ddc104..795d1fbb74 100644 --- a/org.adempiere.base/src/org/compiere/model/MInvoice.java +++ b/org.adempiere.base/src/org/compiere/model/MInvoice.java @@ -1773,6 +1773,32 @@ public class MInvoice extends X_C_Invoice implements DocAction { MInvoiceLine line = lines[i]; + // Matching - Inv-Shipment + if (!isSOTrx() + && line.getM_InOutLine_ID() != 0 + && line.getM_Product_ID() != 0 + && !isReversal()) + { + MInOutLine receiptLine = new MInOutLine (getCtx(),line.getM_InOutLine_ID(), get_TrxName()); + BigDecimal matchQty = line.getQtyInvoiced(); + + if (receiptLine.getMovementQty().compareTo(matchQty) < 0) + matchQty = receiptLine.getMovementQty(); + + MMatchInv inv = new MMatchInv(line, getDateInvoiced(), matchQty); + boolean isNewMatchInv = false; + if (inv.get_ID() == 0) + isNewMatchInv = true; + if (!inv.save(get_TrxName())) + { + m_processMsg = CLogger.retrieveErrorString("Could not create Invoice Matching"); + return DocAction.STATUS_Invalid; + } + matchInv++; + if (isNewMatchInv) + addDocsPostProcess(inv); + } + // Update Order Line MOrderLine ol = null; if (line.getC_OrderLine_ID() != 0) @@ -1826,33 +1852,7 @@ public class MInvoice extends X_C_Invoice implements DocAction return DocAction.STATUS_Invalid; } } - // - - // Matching - Inv-Shipment - if (!isSOTrx() - && line.getM_InOutLine_ID() != 0 - && line.getM_Product_ID() != 0 - && !isReversal()) - { - MInOutLine receiptLine = new MInOutLine (getCtx(),line.getM_InOutLine_ID(), get_TrxName()); - BigDecimal matchQty = line.getQtyInvoiced(); - - if (receiptLine.getMovementQty().compareTo(matchQty) < 0) - matchQty = receiptLine.getMovementQty(); - - MMatchInv inv = new MMatchInv(line, getDateInvoiced(), matchQty); - boolean isNewMatchInv = false; - if (inv.get_ID() == 0) - isNewMatchInv = true; - if (!inv.save(get_TrxName())) - { - m_processMsg = CLogger.retrieveErrorString("Could not create Invoice Matching"); - return DocAction.STATUS_Invalid; - } - matchInv++; - if (isNewMatchInv) - addDocsPostProcess(inv); - } + // } // for all lines if (matchInv > 0) info.append(" @M_MatchInv_ID@#").append(matchInv).append(" ");