IDEMPIERE-365 Review credit limit check on Invoice, especially for Credit Memos

This commit is contained in:
Juliana Corredor 2012-08-14 16:02:30 -05:00
parent 0625cd9fd9
commit 2f6dedf643
2 changed files with 44 additions and 33 deletions

View File

@ -1422,7 +1422,13 @@ public class MInvoice extends X_C_Invoice implements DocAction
}
// Credit Status
if (isSOTrx() && !isReversal())
if (isSOTrx())
{
MDocType doc = (MDocType) getC_DocTypeTarget();
// IDEMPIERE-365 - just check credit if is going to increase the debt
if ( (doc.getDocBaseType().equals(MDocType.DOCBASETYPE_ARCreditMemo) && getGrandTotal().signum() < 0 ) ||
(doc.getDocBaseType().equals(MDocType.DOCBASETYPE_ARInvoice) && getGrandTotal().signum() > 0 )
)
{
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null);
if ( MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()) )
@ -1433,6 +1439,7 @@ public class MInvoice extends X_C_Invoice implements DocAction
return DocAction.STATUS_Invalid;
}
}
}
// Landed Costs
if (!isSOTrx())

View File

@ -1333,6 +1333,9 @@ public class MOrder extends X_C_Order implements DocAction
} else {
MBPartner bp = new MBPartner (getCtx(), getBill_BPartner_ID(), get_TrxName()); // bill bp is guaranteed on beforeSave
if (getGrandTotal().signum() > 0) // IDEMPIERE-365 - just check credit if is going to increase the debt
{
if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
{
m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
@ -1359,6 +1362,7 @@ public class MOrder extends X_C_Order implements DocAction
}
}
}
}
m_processMsg = ModelValidationEngine.get().fireDocValidate(this, ModelValidator.TIMING_AFTER_PREPARE);
if (m_processMsg != null)