将预付款添加到销售订单

时间:2014-10-17 19:40:47

标签: erp acumatica

我需要在销售订单中添加预付款。会计已在Acumatica中设置所需的类和付款方式。我可以通过GUI执行此操作,但是当我尝试使用Web服务在销售订单上输入付款信息时,我收到错误回复。错误响应是:PX.Data.PXException:错误#14:插入' SOAdjust'记录引发一个或多个错误。请查阅。错误:'参考Nbr。'可能不是空的。

`SO301000Content SO301000 = context.SO301000GetSchema();             context.SO301000Clear();

        List<Command> cmds = new List<Command>();
        cmds.AddRange(new Command[]{

            new Value {Value = "C3", LinkedCommand = SO301000.OrderSummary.OrderType},
            new Value { Value = orderNbr, LinkedCommand = SO301000.OrderSummary.OrderNbr, Commit = true},

            SO301000.Payments.ServiceCommands.NewRow,

            new Value { Value = "Prepayment", LinkedCommand = SO301000.Payments.DocType},
            new Value { Value = paymentNbr, LinkedCommand = SO301000.Payments.ReferenceNbr, Commit = true },
           // new Value { Value = "3.00" , LinkedCommand = SO301000.Payments.AppliedToOrder, Commit = true},

            SO301000.Actions.Save,
            SO301000.OrderSummary.OrderNbr
        });

        string orderNumber = string.Empty;

        try
        {
            var SO301000ContentReturned = context.SO301000Submit(cmds.ToArray());
            orderNumber = SO301000ContentReturned[0].OrderSummary.OrderNbr.Value;
            Console.WriteLine(orderNumber);
        }
        catch (Exception exception)
        {
            orderNumber = exception.Message;
            Console.WriteLine(exception);
        }


        return orderNumber;`

有什么建议吗?我也尝试使用AR302000屏幕将付款应用到付款界面的订单,并收到相同的错误消息。

1 个答案:

答案 0 :(得分:1)

由两个关键字段驱动的网格存在已知限制(在本例中为:DocType + ReferenceNbr)。在这种情况下,只有第二个键应该具有Commit = true set,因此您需要在DocType字段上设置Commit = false。但是,您需要在架构内容对象上执行此操作,而不是从Value对象执行此操作。

另一个Commit = true,NewRow命令是不必要的。我在下面编辑了您的原始代码,这应该是它的样子:

    SO301000.Payments.DocType.Commit = false; //This is the line that I added
    List<Command> cmds = new List<Command>();
    cmds.AddRange(new Command[]{
        new Value {Value = "C3", LinkedCommand = SO301000.OrderSummary.OrderType},
        new Value { Value = orderNbr, LinkedCommand = SO301000.OrderSummary.OrderNbr},

        new Value { Value = "Prepayment", LinkedCommand = SO301000.Payments.DocType},
        new Value { Value = paymentNbr, LinkedCommand = SO301000.Payments.ReferenceNbr},
        //new Value { Value = "3.00" , LinkedCommand = SO301000.Payments.AppliedToOrder},

        SO301000.Actions.Save,
        SO301000.OrderSummary.OrderNbr
    });

    string orderNumber = string.Empty;

    try
    {
        var SO301000ContentReturned = context.SO301000Submit(cmds.ToArray());
        orderNumber = SO301000ContentReturned[0].OrderSummary.OrderNbr.Value;
        Console.WriteLine(orderNumber);
    }
    catch (Exception exception)
    {
        orderNumber = exception.Message;
        Console.WriteLine(exception);
    }


    return orderNumber;