在 ARInvoiceEntry 中自定义 SendARInvoiceMemo 操作

Customizing SendARInvoiceMemo action in ARInvoiceEntry

我已经使用复制 SendARInvoiceMemo 的自定义操作为 ARInvoiceEntry 创建了一个扩展,但在发票通知电子邮件中添加了一个附加附件。

使用额外的按钮可以按预期工作,但我需要它来替换原来的操作。我已经使用相同的名称来重载现有的名称,但它似乎不起作用。

如何强制 Acumatica 在 GraphExtension 中使用我的操作而不是原始操作?

这是我的扩展操作代码:

public PXAction<ARInvoice> sendARInvoiceMemo;

[PXUIField(DisplayName = "+Send AR Invoice/Memo+", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
[PXLookupButton]
public virtual IEnumerable SendARInvoiceMemo(PXAdapter adapter,
    [PXString]
    string reportID)
{
    var cfdi = ARInvoiceXmlDownload.GetXmlAttachment(this.Base, this.Base.Document.Current);

    if (cfdi == null)
    {
        return Base.SendARInvoiceMemo(adapter, reportID);
    }

    ARInvoice invoice = this.Base.Document.Current;
    if (reportID == null) reportID = "AR641000";
    if (invoice != null)
    {
        Dictionary<string, string> mailParams = new Dictionary<string, string>();
        mailParams["DocType"] = invoice.DocType;
        mailParams["RefNbr"] = invoice.RefNbr;

        var sent = false;
        var activities = PX.Objects.EP.ReportNotificationGenerator.Send(reportID, mailParams);
        var updatedActivities = new List<EPActivity>();
        foreach (var act in activities)
        {
            AddCfdi(act, cfdi.UID);
            sent = true;
        }

        if (sent)
        {
            this.Base.Caches<NoteDoc>().Persist(PXDBOperation.Insert);
        }
        else
        {
            throw new PXException(ErrorMessages.MailSendFailed);
        }

        this.Base.Clear();
        this.Base.Document.Current = this.Base.Document.Search<ARInvoice.refNbr>(invoice.RefNbr, invoice.DocType);
    }
    return adapter.Get();
}

根据要求编辑澄清

这适用于 Acumatica v5.30.2741

这是我需要替换的发票和备忘录 (AR301000) 中的操作:

它也用于打印发票和备忘录 (AR508000),以在一个流程中发送多张发票:

使用可扩展性框架,来自基本 BLC 的操作始终完全替换为在 BLC 扩展中声明的同名操作。有关如何使用 Acumatica 扩展框架修改操作的更多信息,请查看 BLC 扩展模型 文章 Help -> Customization.

要修改电子邮件Invoice/Memo按钮,在ARInvoiceEntry BLC扩展中你应该自定义notification 动作:

public PXAction<ARInvoice> notification;
[PXUIField(DisplayName = "Notifications", Visible = false)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
protected virtual IEnumerable Notification(PXAdapter adapter,
    [PXString]
    string notificationCD)
{
    foreach (ARInvoice doc in adapter.Get())
    {
        Dictionary<string, string> parameters = new Dictionary<string, string>();
        parameters.Add("DocType", doc.DocType);
        parameters.Add("RefNbr", doc.RefNbr);

        using (var ts = new PXTransactionScope())
        {
            Base.Activity.SendNotification(ARNotificationSource.Customer, notificationCD, doc.BranchID, parameters);
            Base.Save.Press();

            ts.Complete();
        }

        yield return doc;
    }
}

在此特定情况下,确定自定义操作的正确方法是探索为发票和备忘录屏幕 (AR301000) 设置的自动化步骤,如下面的 2 个屏幕截图所示:

说到 sendARInvoiceMemo 操作,它看起来像是发票和备忘录屏幕 (AR301000) 上不再使用的剩余部分。尽管它仍在现金销售屏幕 (AR304000) 的自动化步骤中使用,如下面的屏幕截图所示: