首页 文章

“运行项目开票”屏幕上的拦截过程

提问于
浏览
0

我们正在使用“运行项目开票”屏幕在AR /发票和备忘录中创建记录 .

在Invoice&Memo屏幕中,我们需要填充 Headers Customer Ord的过程 . number,以及已添加到“文档详细信息”选项卡上的网格部分的用户字段 . 目前,这个过程并没有这样做 .

我想使用我熟悉的技术拦截屏幕上的处理操作,即使用'AddHandler':

[PXOverride]
protected virtual IEnumerable Items (PXAdapter adapter)
{
   PXGraph.InstanceCreated.AddHandler<BillingProcess>((graph) =>
   {
       graph.RowInserting.AddHandler<BillingProcess.ProjectsList>((sender, e) =>
       {

           //Custom logic goes here

       });
   });
   return Base.action.Press(adapter);
}

我看不到任何类似'Bill'或'Bill All'的Base.Actions .

这显然不是我需要的代码,但我认为这是一般的起点 .

在审查了源业务逻辑之后,我没有看到任何“Bill”或“Bill All”操作 - 或任何“操作”(令人费解) . 我看到一个名为'items'的IEnumerable方法,所以这就是我上面开始的 .

这是正确的方法吗?

更新:2017年2月14日

使用提供的答案re:重写的方法InsertTransaction(...)我试图使用以下逻辑设置我们的ARTran用户字段(这是必需的):

PMProject pmproj = PXSelect<PMProject, Where<PMProject.contractID, Equal<Required<PMProject.contractID>>>>.Select(Base, tran.ProjectID);
        if (pmproj == null) return;

        PMProjectExt pmprojext = PXCache<PMProject>.GetExtension<PMProjectExt>(pmproj);
        if (pmprojext == null) return;

        ARTranExt tranext = PXCache<ARTran>.GetExtension<ARTranExt>(tran);
        if (tranext == null) return;

        tranext.UsrContractID = pmprojext.UsrContractID;

即使这会将用户字段设置为正确的值,但仍会在进程完成时向我提供必填字段为空的错误 . 我有限的知识使我无法理解为什么 .

1 回答

  • 0

    在“运行项目开票”屏幕上, ProcessProcess All 按钮的 Headers 在BLC构造函数中分别更改为 BillBill All . 在BillingFilter_RowSelected处理程序中为 Items 数据视图设置了进程委托:

    public class BillingProcess : PXGraph<BillingProcess>
    {
        ...
    
        public BillingProcess()
        {
            Items.SetProcessCaption(PM.Messages.ProcBill);
            Items.SetProcessAllCaption(PM.Messages.ProcBillAll);
        }
    
        ...
    
        protected virtual void BillingFilter_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            BillingFilter filter = Filter.Current;
    
            Items.SetProcessDelegate<PMBillEngine>(
                delegate (PMBillEngine engine, ProjectsList item)
                {
                    if (!engine.Bill(item.ProjectID, filter.InvoiceDate, filter.InvFinPeriodID))
                    {
                        throw new PXSetPropertyException(Warnings.NothingToBill, PXErrorLevel.RowWarning);
                    }
                });
        }
    
        ...
    }
    

    如上面的代码片段所示, AR Invoice and Memos 屏幕中的所有记录都是由PMBillEngine类的实例创建的 . 以下是显示如何在PMBillEngine BLC扩展中覆盖 InsertNewInvoiceDocumentInsertTransaction 方法的代码段:

    public class PMBillEngineExt : PXGraphExtension<PMBillEngine>
    {
        public delegate ARInvoice InsertNewInvoiceDocumentDel(string finPeriod, string docType, Customer customer,
            PMProject project, DateTime billingDate, string docDesc);
    
        [PXOverride]
        public ARInvoice InsertNewInvoiceDocument(string finPeriod, string docType, Customer customer, PMProject project,
            DateTime billingDate, string docDesc, InsertNewInvoiceDocumentDel del)
        {
            var result = del(finPeriod, docType, customer, project, billingDate, docDesc);
            // custom logic goes here
            return result;
        }
    
        [PXOverride]
        public void InsertTransaction(ARTran tran, string subCD, string note, Guid[] files)
        {
            // the system will automatically invoke base method prior to the customized one
            // custom logic goes here
        }
    }
    

    Run Project Billing 进程调用 InsertNewInvoiceDocument 方法在 AR Invoice and Memos 屏幕上创建新记录,并使用 InsertTransaction 方法添加新发票交易 .

    当用户从处理 Run Project Billing 屏幕或数据条目 Projects 屏幕启动“运行项目开票”操作时,将调用 One important thing to mention: 重写 InsertNewInvoiceDocumentInsertTransaction 方法 .

    有关如何覆盖虚拟BLC方法的更多信息,请参阅每个Acumatica ERP 6.1网站中的 Help - > Customization - > Customizing Business Logic - > Graph - > To Override a Virtual Method

相关问题