【问题标题】:Acumatica Update Revenue Budget Fields from Tasks on Project levelAcumatica 从项目级别的任务更新收入预算字段
【发布时间】:2021-05-25 12:02:30
【问题描述】:

在 Acumatica(Build 2020.5.2.368)中,我们对项目任务(DAC:PMTask)进行了广泛的自定义,当我们点击“保存”按钮时,它会正确保存。当我们想要将一些更改推送到“收入预算”选项卡(DAC:PMRevenueBudget)时 - 我们使用以下代码:

// Task updated
    protected void PMTask_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
    {
        var row = (PMTask)e.Row;
        PMTaskExt TaskExt = row.GetExtension<PMTaskExt>();
                        // Check Qty
        if (TaskExt.UsrQuantity == 0)
        {
            TaskExt.UsrQuantity = 1;
        }

        if (TaskExt.UsrCostPrice != 0 && TaskExt.UsrMarginPerc != 0)
        {
            // do custom calculations here -- I removed the part of the code as it was useless for the purpose of posting here.
            // Set custom fields
            // These fields all have values greater than 0 --> Double Checked this
            TaskExt.UsrMarkupPerc = TaskExt.UsrCostPrice * TaskExt.UsrQuantity / 100;
            TaskExt.UsrLineCost = TaskExt.UsrCostPrice * TaskExt.UsrQuantity;
            TaskExt.UsrSellPrice = TaskExt.UsrUnitPrice * TaskExt.UsrQuantity;
            TaskExt.UsrTotalRevenue = TaskExt.UsrSellPrice - TaskExt.UsrLineCost;
            TaskExt.UsrCostPriceCalculation = Convert.ToDecimal(12.00);
            TaskExt.UsrUnitPriceCalculation = Convert.ToDecimal(88.99);               
        }
        else 
        {
            // More calculations
        }                     
        

        int revAccountID = 0;
        int costAccountID = 0;
        foreach (PMAccountGroup pmag in AccountInfo.Select())
        {
            if (pmag.GroupCD.Trim().Equals("INCOME"))
            {
                revAccountID = (int)pmag.GroupID; // 898
            }

            if (pmag.GroupCD.Trim().Equals("EXPENSES"))
            {
                costAccountID = (int)pmag.GroupID;
            }
        }

        // Find the Inventory Type
        InventoryItem inventory = InvetoryInfo.Search<InventoryItem.inventoryID>(TaskExt.UsrInventoryID);
        string invUOM = "";
        if (inventory != null)
        {
            invUOM = inventory.BaseUnit;
        }

        // Task --> Revenue Budget
        PMRevenueBudget revbudgetItem = Base.RevenueBudget.Search<PMRevenueBudget.projectTaskID>(thisTask.TaskID);
        if (revbudgetItem != null)
        {
            revbudgetItem.AccountGroupID = revAccountID;
            revbudgetItem.InventoryID = thiskExt.UsrInventoryID;
            revbudgetItem.CuryUnitRate = thiskExt.UsrUnitPrice;
            revbudgetItem.Qty = thiskExt.UsrQuantity;
            revbudgetItem.CuryAmount = thiskExt.UsrSellPrice;
            revbudgetItem.UOM = invUOM;
            revbudgetItem.RevisedQty = revbudgetItem.Qty;
            revbudgetItem.CuryRevisedAmount = revbudgetItem.CuryAmount;
            // --> Base.RevenueBudget.Update(revbudgetItem); <-- This works to update the cahce, but as soon as the user hits save, it reverts the changes back to 0.
        }
    }

我已经在行持久化和持久化事件中尝试过,但随后得到了

“另一个进程已添加/更新记录”

恢复一切的错误。当我点击“保存”按钮时,如何获取这些值并将其保存到表格中?

任何帮助将不胜感激。

【问题讨论】:

    标签: c# acumatica


    【解决方案1】:

    因此,到目前为止,我们发现的最佳解决方案是更新持久化行中的图表。

    protected void PMProject_RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
        {
            var row = (PMProject)e.Row;
            if (e.TranStatus == PXTranStatus.Completed)
            {
                var target = PXGraph.CreateInstance<ProjectTaskEntry>();
                var target2 = PXGraph.CreateInstance<ProjectEntry>();
    
                //var target = PXGraph.CreateInstance<ProjectEntry>();
                foreach (PMTask taskitem in Base.Tasks.Select())
                {
                    PMTaskExt TaskExt = taskitem.GetExtension<PMTaskExt>();                    
                    target.Task.Update(taskitem);
                    
                    foreach (PMRevenueBudget revbudgetItem in Base.RevenueBudget.Search<PMRevenueBudget.projectTaskID>(taskitem.TaskID))
                    {
                        revbudgetItem.Qty = TaskExt.UsrQuantity;
                        target2.RevenueBudget.Update(revbudgetItem);
                    }
                }              
    
                target2.Save.PressButton();
    
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多