![](/img/trans.png)
[英]Fill value of selector field into another field in Acumatica ERP System
[英]How to override action when field curyOrigDiscAmt value changes Acumatica ERP
我正在自定义 APInvoiceEntry 图表,当它在账单和调整屏幕 (ID=AP301000) 中进行修改时。
当项目添加到图形的 POItem 部分时,会设置字段curyOrigDiscAmt 。 有一种逻辑可以根据付款类型(例如现金预付款)和供应商 class 上的设置来计算折扣。
这是默认行为。 但是,在运行之后,我想运行调整这个数字的逻辑。
我想我可以简单地将我的逻辑放在“字段更改”方法中。 但是当对curyOrigDiscAmt的更改发生时,我能找到的所有操作都没有被激活。
到目前为止,我已经尝试过:
protected virtual void _(Events.FieldVerifying<APInvoice, APInvoice.curyOrigDiscAmt> e)
protected virtual void _(Events.FieldUpdated<APInvoice, APInvoice.curyOrigDiscAmt> e)
protected void APInvoice_CuryOrigDiscAmt_FieldUpdating(PXCache cache, PXFieldUpdatingEventArgs e)
protected virtual void _(Events.RowSelecting<APInvoice> e)
当场发生变化时,它们都不会触发。 我需要反映在 UI 中供用户查看,因此在保存记录时更改它没有任何好处。 我需要它在执行计算的基本代码运行后立即发生。
哪里是? 我如何找到它?
[编辑——以下 Hugues Beauséjour 回答的后续行动]
有没有办法只引发事件而无需更改 CalcDisc() 方法? 我所需要的只是要调用的事件。
换句话说,有点像:
protected override void CalcDisc(PXCache sender, PXFieldUpdatedEventArgs e)
{
base.CalcDisc(sender, e);
base.RaiseEvents(EVENTLIST_TO_RAISE);
}
如果我可以帮助它使其对未来的更改更加防弹,我宁愿根本不更改代码......
该值在装饰APInvoice.TermsID
字段的Terms
属性中计算:
#region TermsID
public abstract class termsID : PX.Data.BQL.BqlString.Field<termsID> { }
/// <summary>
/// The <see cref="PX.Objects.CS.Terms">credit terms</see> associated with the document (unavailable for prepayments and debit adjustments).\
/// Defaults to the <see cref="Vendor.TermsID">credit terms of the vendor</see>.
/// </summary>
[PXDBString(10, IsUnicode = true)]
[PXDefault(typeof(Search<Vendor.termsID,
Where<Vendor.bAccountID, Equal<Current<APInvoice.vendorID>>,
And<Current<APInvoice.docType>, NotEqual<APDocType.debitAdj>>>>),
PersistingCheck = PXPersistingCheck.Nothing)]
[PXUIField(DisplayName = "Terms", Visibility = PXUIVisibility.Visible)]
[APTermsSelector]
[Terms(typeof(APInvoice.docDate), typeof(APInvoice.dueDate), typeof(APInvoice.discDate),
typeof(APInvoice.curyOrigDocAmt), typeof(APInvoice.curyOrigDiscAmt))]
public virtual string TermsID
{
get;
set;
}
#endregion
它是TermsAttribute
class 构造函数的最后一个参数: CuryDiscBal
public TermsAttribute(Type DocDate, Type DueDate, Type DiscDate, Type CuryDocBal, Type CuryDiscBal)
{
_DocDate = DocDate;
_DueDate = DueDate;
_DiscDate = DiscDate;
_CuryDiscBal = CuryDiscBal;
_CuryDocBal = CuryDocBal;
}
最终值在Terms
属性的CalcDisc
方法中计算。 它分配有不引发事件的SetValue
方法:
protected virtual void CalcDisc(PXCache sender, PXFieldUpdatedEventArgs e)
{
if (_CuryDocBal != null && _CuryDiscBal != null &&
sender.GetValue(e.Row, _FieldName) != null &&
sender.GetValue(e.Row, _CuryDocBal.Name) != null && !sender.Graph.IsCopyPasteContext)
{
string TermsID = (string)sender.GetValue(e.Row, _FieldName);
decimal CuryDocBal = (decimal)sender.GetValue(e.Row, _CuryDocBal.Name);
decimal CuryDiscBal = 0m;
Terms terms = SelectTerms(sender.Graph, TermsID);
if (terms != null && terms.InstallmentType == TermsInstallmentType.Single && CuryDocBal > 0m)
{
CuryDiscBal = PXDBCurrencyAttribute.Round(sender, e.Row, CuryDocBal * (decimal)terms.DiscPercent / 100, CMPrecision.TRANCURY);
}
sender.SetValue(e.Row, _CuryDiscBal.Name, CuryDiscBal);
PXUIFieldAttribute.SetEnabled(sender, e.Row, _CuryDiscBal.Name, (terms.InstallmentType == TermsInstallmentType.Single));
}
}
要覆盖它,您可以将条款属性替换为基于原始条款属性TermsAttribute
的自定义属性。 然后覆盖字段APInvoice.TermsID
并使用自定义属性装饰它以替换原始条款。 更改SetValue
分配以使用SetValueExt
应该引发字段更新/更新事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.