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
|
// Credit Status
|
||||||
if (isSOTrx() && !isReversal())
|
if (isSOTrx())
|
||||||
{
|
{
|
||||||
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null);
|
MDocType doc = (MDocType) getC_DocTypeTarget();
|
||||||
if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
|
// 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@="
|
MBPartner bp = new MBPartner (getCtx(), getC_BPartner_ID(), null);
|
||||||
+ bp.getTotalOpenBalance()
|
if ( MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()) )
|
||||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
{
|
||||||
return DocAction.STATUS_Invalid;
|
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 {
|
} else {
|
||||||
MBPartner bp = new MBPartner (getCtx(), getBill_BPartner_ID(), get_TrxName()); // bill bp is guaranteed on beforeSave
|
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()
|
if (MBPartner.SOCREDITSTATUS_CreditStop.equals(bp.getSOCreditStatus()))
|
||||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
{
|
||||||
return DocAction.STATUS_Invalid;
|
m_processMsg = "@BPartnerCreditStop@ - @TotalOpenBalance@="
|
||||||
}
|
+ bp.getTotalOpenBalance()
|
||||||
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus()))
|
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||||
{
|
return DocAction.STATUS_Invalid;
|
||||||
m_processMsg = "@BPartnerCreditHold@ - @TotalOpenBalance@="
|
}
|
||||||
+ bp.getTotalOpenBalance()
|
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus()))
|
||||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
{
|
||||||
return DocAction.STATUS_Invalid;
|
m_processMsg = "@BPartnerCreditHold@ - @TotalOpenBalance@="
|
||||||
}
|
+ bp.getTotalOpenBalance()
|
||||||
BigDecimal grandTotal = MConversionRate.convertBase(getCtx(),
|
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||||
getGrandTotal(), getC_Currency_ID(), getDateOrdered(),
|
return DocAction.STATUS_Invalid;
|
||||||
getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
|
}
|
||||||
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus(grandTotal)))
|
BigDecimal grandTotal = MConversionRate.convertBase(getCtx(),
|
||||||
{
|
getGrandTotal(), getC_Currency_ID(), getDateOrdered(),
|
||||||
m_processMsg = "@BPartnerOverOCreditHold@ - @TotalOpenBalance@="
|
getC_ConversionType_ID(), getAD_Client_ID(), getAD_Org_ID());
|
||||||
+ bp.getTotalOpenBalance() + ", @GrandTotal@=" + grandTotal
|
if (MBPartner.SOCREDITSTATUS_CreditHold.equals(bp.getSOCreditStatus(grandTotal)))
|
||||||
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
{
|
||||||
return DocAction.STATUS_Invalid;
|
m_processMsg = "@BPartnerOverOCreditHold@ - @TotalOpenBalance@="
|
||||||
|
+ bp.getTotalOpenBalance() + ", @GrandTotal@=" + grandTotal
|
||||||
|
+ ", @SO_CreditLimit@=" + bp.getSO_CreditLimit();
|
||||||
|
return DocAction.STATUS_Invalid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue