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:
parent
614a431e0b
commit
5d253c71e5
|
@ -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(" ");
|
||||
|
|
Loading…
Reference in New Issue