当字段 curyOrigDiscAmt 值更改时如何覆盖操作 Acumatica ERP [英] How to override action when field curyOrigDiscAmt value changes Acumatica ERP

查看:65
本文介绍了当字段 curyOrigDiscAmt 值更改时如何覆盖操作 Acumatica ERP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在自定义 APInvoiceEntry 图表,当它在 账单和调整 屏幕 (ID=AP301000) 中被修改时.

I am customizing APInvoiceEntry graph, when it is modified in the Bills and Adjustments Screen (ID=AP301000).

字段 curyOrigDiscAmt 在图表的 POItem 部分中添加项目时设置.存在根据付款类型(例如现金预付款)和供应商类别设置的计算折扣的逻辑.

The field curyOrigDiscAmt is set when items are added in the POItem portion of the graph. There is logic that calculates the discount based on payment type (eg Cash Prepayment) and what is set on the vendor class.

这是默认行为.但是,在运行之后,我想运行调整这个数字的逻辑.

This is the default behavior. However, after that runs, I have logic I want to run that adjusts this figure.

我以为我可以简单地将我的逻辑放在领域变化"中;方法.但是当更改为 curyOrigDiscAmt 时,我能找到的所有操作都不会被激活.

I thought I could simply put my logic in a "field changing" method. But none of the actions I can find are activated when the change to curyOrigDiscAmt happens.

到目前为止,我已经尝试过:

So far, I have tried:

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)

当字段更改时,它们都不会触发.我需要反映在用户界面中让用户看到,所以在保存记录时更改它没有任何好处.我需要它在执行计算的基本代码运行后立即发生.

None of them fire when the field is changed. I need to reflected in the UI for the user to see, so it doesn't do any good to change it when the record is saved. I need it to happen right after the base code runs that does the calculation.

那是哪里?我如何找到它?

Where is that? How do I find it?

有没有办法只引发事件而根本不必更改 CalcDisc() 方法?我所需要的只是要调用的事件.

Is there a way to just raise the events without having to change the CalcDisc() method at all? All I need are the events to be called.

换句话说,有点像:

protected override void CalcDisc(PXCache sender, PXFieldUpdatedEventArgs e)
 {
     base.CalcDisc(sender, e);
     base.RaiseEvents(EVENTLIST_TO_RAISE);
 }

如果我可以帮助它使其对未来的更改更加防弹,我宁愿根本不更改代码...

I would rather not change the code at all if I could help it to keep it more bulletproof to future changes...

推荐答案

该值在装饰 APInvoice.TermsID 字段的 Terms 属性中计算:

The value is computed in the Terms attribute decorating APInvoice.TermsID field:

#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类构造函数的最后一个参数:CuryDiscBal

It is the last parameter of the TermsAttribute class constructor: 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 方法分配:

The final value is computed in the CalcDisc method of Terms attribute. It is assigned with SetValue method which does not raise events:

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 应该会引发字段更新/更新事件.

To override it you could substitute the Terms attribute with a custom attribute based on the original TermsAttribute class. Then you override field APInvoice.TermsID and decorate it with the custom attribute to replace the original Terms. Changing the SetValue assignment to use SetValueExt should raise the field updating/updated events.

这篇关于当字段 curyOrigDiscAmt 值更改时如何覆盖操作 Acumatica ERP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆