在acumatica系统中使用webservices API导入屏幕账单和裁决中的已付金额 [英] Import Amount Paid in screen Bill And Adjusment using webservices API in acumatica system

查看:57
本文介绍了在acumatica系统中使用webservices API导入屏幕账单和裁决中的已付金额的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Web服务将已支付金额的值导入Acumatica ERP系统。请参考下面的屏幕截图。

I need to import value of Amount Paid using webservices to Acumatica ERP System. Please refer to this screenshot below.

I已经使用参考号= 1700000016,DocType = Bill,VendorRef = SV-889-JKT-2,VendorID = V000000030和已付款金额= 1,250,000创建了一些代码。

I have already create some codes using Reference Number = "1700000016", DocType = "Bill", VendorRef = "SV-889-JKT-2", VendorID = "V000000030" and Amount Paid = "1,250,000". Please refer to this codes below.

   sCon.getLogin(username, password, url, context);
            AP301000Content konten = context.AP301000GetSchema();
            //context.AP301000Clear();
            List<Command> oCmds = new List<Command>();

            //oCmds.Add(konten.Actions.Insert);
            //--------------- adding header transaction -----------------//
            konten.DocumentSummary.Type.Commit = false;
            konten.DocumentSummary.Type.LinkedCommand = null;
            oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.Type, Value = "Bill" });
            oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.ReferenceNbr, Value = "0000" });
            oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.Date, Value = dtDateSV.Text });
            oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.VendorRef, Value = "SV-889-JKT-2" });
            oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.Vendor, Value = "V000000030" });

            //-------------- adding detail transaction (Based on values in Data Grid )-------------
            int a = dgvDocDetailSV.Rows.Count;
            for (int x = 0; x < a; x++)
            {
                oCmds.Add(konten.DocumentDetails.ServiceCommands.NewRow);
                oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.Branch, Value = dgvDocDetailSV.Rows[x].Cells[1].Value.ToString() });
                oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.InventoryID, Value = dgvDocDetailSV.Rows[x].Cells[2].Value.ToString() });
                oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.JobOrderNbr, Value = dgvDocDetailSV.Rows[x].Cells[3].Value.ToString() });
                oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.Quantity, Value = dgvDocDetailSV.Rows[x].Cells[4].Value.ToString() });
                oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.UOM, Value = dgvDocDetailSV.Rows[x].Cells[5].Value.ToString() });
                oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.UnitCost, Value = dgvDocDetailSV.Rows[x].Cells[6].Value.ToString() });
            }
            //------ add document in Applications Tab Menu -------//
            string DocTypePrepayment = "Prepayment";
            string RefNbrPrepayment = "1700000015";
            oCmds.Add(new Key
            {
                ObjectName = konten.Applications.DocTypeDisplayDocType.ObjectName,
                FieldName = konten.Applications.DocTypeDisplayDocType.FieldName,
                Value = DocTypePrepayment
            });
            oCmds.Add(new Key
            {
                ObjectName = konten.Applications.ReferenceNbrDisplayRefNbr.ObjectName,
                FieldName = konten.Applications.ReferenceNbrDisplayRefNbr.FieldName,
                Value = RefNbrPrepayment
            });
            oCmds.Add(new Value { LinkedCommand = konten.Applications.AmountPaid, Value = "1250000" });

            //------ save transaction in acumatica -------//
            oCmds.Add(konten.Actions.Save);
            var result = context.AP301000Submit(oCmds.ToArray());

尝试导入此数据后出现错误消息。错误消息是 System.Web.Services.Protocols.SoapException:服务器无法处理请求。---> PX.Data.PXException:错误#111:处理字段CuryAdjdAmt时出错:对象引用未设置为---> System.NullReferenceException:对象引用未设置为对象的实例。

似乎CuryAdjdAmt字段为空,并且该字段映射到Acumatica System的应用程序菜单选项卡中的AmountPaid字段。

I have an error message after trying to import this data. The error message is "System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> PX.Data.PXException: Error #111: An error occurred while processing the field CuryAdjdAmt : Object reference not set to an instance of an object.. ---> System.NullReferenceException: Object reference not set to an instance of an object. ". It seems that field CuryAdjdAmt is null, and this field is mapped to AmountPaid field in Application Menu Tab of Acumatica System.

请给我参考以解决此问题问题。
谢谢

Please give me reference to solve this issue. Thanks

推荐答案

好像是由于我们为法案所做的性能改进而导致的调整数据视图委托存在问题和调整屏幕大约一年前。我已将所有详细信息转发给Acumatica工程团队以进行进一步调查。

Looks like there is an issue with Adjustments data view delegate caused by performance improvements we made for the Bills and Adjustments screen about a year ago. I've forwarded all details to Acumatica engineering team for further investigation.

作为一种临时解决方法,您可以实现APInvoiceEntry BLC的扩展,并稍稍更改Adjustments数据的委托视图:

As a temporary workaround you can implement an extension for the APInvoiceEntry BLC and slightly change delegate of the Adjustments data view:

public class APInvoiceEntryExt : PXGraphExtension<APInvoiceEntry>
{
    [PXCopyPasteHiddenView]
    public PXSelectJoin<APAdjust,
        InnerJoin<APPayment, On<APPayment.docType, Equal<APAdjust.adjgDocType>,
            And<APPayment.refNbr, Equal<APAdjust.adjgRefNbr>>>>> Adjustments;

    public IEnumerable adjustments()
    {
        IEnumerable result;

        bool origIsImport = Base.IsImport;
        Base.IsImport = false;
        try
        {
            result = Base.Adjustments.Select();
        }
        finally
        {
            Base.IsImport = origIsImport;
        }

        return result;
    }
}

应用了临时解决方法后,我得以更新带有以下命令集的AmountPaid字段。给定调整数据视图中的复杂程度(因为它必须同时处理从数据库检索到的记录和在运行时创建的记录),如果应用程序选项卡中有1个以上的文档,则必须使用RowNumber服务命令。不幸的是,密钥类型的基于API的命令将无法在应用程序选项卡中找到记录。

With the temporary workaround applied, I was able to update AmountPaid field with following set of commands. Given the level of complexity put into the Adjustments data view (as it has to work with both records retrieved from database and created at runtime), you have to use RowNumber service command when there are more than 1 document in the Applications tab (Screen-Based API commands of the Key type unfortunately will not work to locate record in the Applications tab).

以下示例将向Acumatica API发送2个请求:
-第一个调用,从应用程序选项卡
中导出所有记录-通过循环返回数组,可以确定需要为AmountPaid
设置新值的记录的行数-通过第二次调用,传递RowNumber并将新值分配给AmountPaid字段

The sample below will send 2 requests to Acumatica API: - 1st call to export all records from the Applications tab - by looping though returned array, you can determine what are RowNumbers of records, that require new value set for AmountPaid - with your 2nd call, you pass RowNumber and assign new value to the AmountPaid field

Screen context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AP301000/Soap/AP301000.asmx";
context.Login("admin", "123");

Content billSchema = context.GetSchema();

// 1st call to export all records from the Applications tab
billSchema.DocumentSummary.Type.Commit = false;
billSchema.DocumentSummary.Type.LinkedCommand = null;

var commands = new Command[]
{
    new Value
    {
        Value = "Bill",
        LinkedCommand = billSchema.DocumentSummary.Type
    },
    new Value
    {
        Value = "000927",
        LinkedCommand = billSchema.DocumentSummary.ReferenceNbr
    },
    billSchema.Applications.DocTypeDisplayDocType,
    billSchema.Applications.ReferenceNbrDisplayRefNbr,
    billSchema.Applications.Balance
};
var applications = context.Submit(commands).ToList();
// end of 1st call to export all records from the Applications tab

// 2nd call to set AmountPaid in the Applications tab
var cmds = new List<Command>();
foreach (var application in applications)
{
    cmds.Add(
        new Value
        {
            Value = applications.IndexOf(application).ToString(),
            LinkedCommand = billSchema.Applications.ServiceCommands.RowNumber
        });
    cmds.Add(
        new Value
        {
            Value = application.Applications.Balance.Value,
            LinkedCommand = billSchema.Applications.AmountPaid
        });
}
cmds.Add(billSchema.Actions.Save);
context.Submit(cmds.ToArray());
// end of 2nd call to set AmountPaid in the Applications tab

这篇关于在acumatica系统中使用webservices API导入屏幕账单和裁决中的已付金额的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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