IDEMPIERE-365 Review credit limit check on Invoice, especially for Credit Memos
This commit is contained in:
parent
0625cd9fd9
commit
2f6dedf643
|
@ -1422,15 +1422,22 @@ public class MInvoice extends X_C_Invoice implements DocAction
|
|||
}
|
||||
|
||||
// Credit Status
|
||||
if (isSOTrx() && !isReversal())
|
||||
if (isSOTrx())
|
||||
{
|
||||
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null);
|
||||
if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
|
||||
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 )
|
||||
)
|
||||
{
|
||||
m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
|
||||
+ bp.getTotalOpenBalance()
|
||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||
return DocAction.STATUS_Invalid;
|
||||
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null);
|
||||
if ( MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()) )
|
||||
{
|
||||
m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
|
||||
+ bp.getTotalOpenBalance()
|
||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1333,29 +1333,33 @@ 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 (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
|
||||
if (getGrandTotal().signum() > 0) // IDEMPIERE-365 - just check credit if is going to increase the debt
|
||||
{
|
||||
m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
|
||||
+ bp.getTotalOpenBalance()
|
||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus()))
|
||||
{
|
||||
m_processMsg = "@BPartnerCreditHold@ - @TotalOpenBalance@="
|
||||
+ bp.getTotalOpenBalance()
|
||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
BigDecimal grandTotal = MConversionRate.convertBase(getCtx(),
|
||||
getGrandTotal(), getC_Currency_ID(), getDateOrdered(),
|
||||
getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
|
||||
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus(grandTotal)))
|
||||
{
|
||||
m_processMsg = "@BPartnerOverOCreditHold@ - @TotalOpenBalance@="
|
||||
+ bp.getTotalOpenBalance() + ", @GrandTotal@=" + grandTotal
|
||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||
return DocAction.STATUS_Invalid;
|
||||
|
||||
if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
|
||||
{
|
||||
m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
|
||||
+ bp.getTotalOpenBalance()
|
||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus()))
|
||||
{
|
||||
m_processMsg = "@BPartnerCreditHold@ - @TotalOpenBalance@="
|
||||
+ bp.getTotalOpenBalance()
|
||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
BigDecimal grandTotal = MConversionRate.convertBase(getCtx(),
|
||||
getGrandTotal(), getC_Currency_ID(), getDateOrdered(),
|
||||
getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
|
||||
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus(grandTotal)))
|
||||
{
|
||||
m_processMsg = "@BPartnerOverOCreditHold@ - @TotalOpenBalance@="
|
||||
+ bp.getTotalOpenBalance() + ", @GrandTotal@=" + grandTotal
|
||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||
return DocAction.STATUS_Invalid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue