如果我的条件得到满足并且引发了自定义错误,我已经覆盖了“发票”屏幕,以限制发票的发布,但是即使引发了错误,并且在关闭该错误之后,发票仍会被释放,但是我想限制发票如果引发错误,则释放。
[PXOverride]
public virtual IEnumerable Release(PXAdapter adapter)
{
if (Base.Document.Current != null)
{
var paymentSetup = PaySetup.SelectSingle(Base.Document.Current.PaymentMethodID);
var paymentSettings = PaySettingDetails.SelectSingle(Base.Document.Current.PaymentMethodID);
if (paymentSettings != null && paymentSetup != null && paymentSetup.IsActive == true)
{
if (this.PayCurrentInvoice.Current != null && this.PayCurrentInvoice.Current.PayStatus.ToUpper() != KNPIConstants.PAID)
{
throw new PXException(KNPIMessages.NotPaid);
}
}
else
{
return Base.release.Press(adapter);
}
}
return null;
}
如果引发了错误,则不应释放发票,但是即使引发了错误,在关闭该错误后仍会释放发票。
答案 0 :(得分:0)
您的替代错误!
public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
[PXOverride]
public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
{
var paymentSetup = PaySetup.SelectSingle(Base.Document.Current.PaymentMethodID);
var paymentSettings = PaySettingDetails.SelectSingle(Base.Document.Current.PaymentMethodID);
if (paymentSettings != null && paymentSetup != null && paymentSetup.IsActive == true)
{
if (this.PayCurrentInvoice.Current != null && this.PayCurrentInvoice.Current.PayStatus.ToUpper() != KNPIConstants.PAID)
{
throw new PXException(KNPIMessages.NotPaid);
}
}
return baseMethod(adapter);
}