IDEMPIERE-493 Add validation for matching. Need to do invoice-shipment matching first because MatchPO.create will auto create matchinv record if it doesn't found one.

This commit is contained in:
Heng Sin Low 2012-11-08 11:01:28 +08:00
parent 614a431e0b
commit 5d253c71e5
1 changed files with 27 additions and 27 deletions

View File

@ -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(" ");