[ 1885417 ] Validate BP on Payment Prepare or BeforeSave
This commit is contained in:
parent
91a394aaaf
commit
b2865c6d2f
|
@ -595,6 +595,25 @@ public final class MPayment extends X_C_Payment
|
||||||
setAD_Org_ID(ba.getAD_Org_ID());
|
setAD_Org_ID(ba.getAD_Org_ID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// [ adempiere-Bugs-1885417 ] Validate BP on Payment Prepare or BeforeSave
|
||||||
|
// there is bp and (invoice or order)
|
||||||
|
if (getC_BPartner_ID() != 0 && (getC_Invoice_ID() != 0 || getC_Order_ID() != 0)) {
|
||||||
|
if (getC_Invoice_ID() != 0) {
|
||||||
|
MInvoice inv = new MInvoice(getCtx(), getC_Invoice_ID(), get_TrxName());
|
||||||
|
if (inv.getC_BPartner_ID() != getC_BPartner_ID()) {
|
||||||
|
log.saveError("Error", Msg.parseTranslation(getCtx(), "BP different from BP Invoice"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getC_Order_ID() != 0) {
|
||||||
|
MOrder ord = new MOrder(getCtx(), getC_Order_ID(), get_TrxName());
|
||||||
|
if (ord.getC_BPartner_ID() != getC_BPartner_ID()) {
|
||||||
|
log.saveError("Error", Msg.parseTranslation(getCtx(), "BP different from BP Order"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} // beforeSave
|
} // beforeSave
|
||||||
|
|
||||||
|
|
|
@ -1132,10 +1132,11 @@ public class VPayment extends CDialog
|
||||||
}
|
}
|
||||||
m_mPayment.setDateTrx(m_DateAcct);
|
m_mPayment.setDateTrx(m_DateAcct);
|
||||||
m_mPayment.setDateAcct(m_DateAcct);
|
m_mPayment.setDateAcct(m_DateAcct);
|
||||||
m_mPayment.save();
|
if (!m_mPayment.save())
|
||||||
|
ADialog.error(m_WindowNo, this, "PaymentError", "PaymentNotCreated");;
|
||||||
|
|
||||||
// Save/Post
|
// Save/Post
|
||||||
if (MPayment.DOCSTATUS_Drafted.equals(m_mPayment.getDocStatus()))
|
if (m_mPayment.get_ID() > 0 && MPayment.DOCSTATUS_Drafted.equals(m_mPayment.getDocStatus()))
|
||||||
{
|
{
|
||||||
boolean ok = m_mPayment.processIt(DocAction.ACTION_Complete);
|
boolean ok = m_mPayment.processIt(DocAction.ACTION_Complete);
|
||||||
m_mPayment.save();
|
m_mPayment.save();
|
||||||
|
@ -1390,11 +1391,13 @@ public class VPayment extends CDialog
|
||||||
m_mPayment.setDateTrx(m_DateAcct);
|
m_mPayment.setDateTrx(m_DateAcct);
|
||||||
// Set Amount
|
// Set Amount
|
||||||
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
|
m_mPayment.setAmount(m_C_Currency_ID, m_Amount);
|
||||||
|
if (!m_mPayment.save()) {
|
||||||
|
ADialog.error(m_WindowNo, this, "PaymentError", "PaymentNotCreated");
|
||||||
|
} else {
|
||||||
approved = m_mPayment.processOnline();
|
approved = m_mPayment.processOnline();
|
||||||
info = m_mPayment.getR_RespMsg() + " (" + m_mPayment.getR_AuthCode()
|
info = m_mPayment.getR_RespMsg() + " (" + m_mPayment.getR_AuthCode()
|
||||||
+ ") ID=" + m_mPayment.getR_PnRef();
|
+ ") ID=" + m_mPayment.getR_PnRef();
|
||||||
boolean saved = m_mPayment.save();
|
m_mPayment.save();
|
||||||
|
|
||||||
if (approved)
|
if (approved)
|
||||||
{
|
{
|
||||||
|
@ -1412,6 +1415,7 @@ public class VPayment extends CDialog
|
||||||
ADialog.error(m_WindowNo, this, "PaymentNotProcessed", info);
|
ADialog.error(m_WindowNo, this, "PaymentNotProcessed", info);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
ADialog.error(m_WindowNo, this, "PaymentNoProcessor");
|
ADialog.error(m_WindowNo, this, "PaymentNoProcessor");
|
||||||
} // online
|
} // online
|
||||||
|
|
Loading…
Reference in New Issue