Dynamics GP Web 服务:使用批次分配创建销售发票

发布于 2024-11-17 05:25:27 字数 2257 浏览 5 评论 0原文

我正在尝试使用以下代码基于现有的 SalesOrder 创建新的 SalesInvoice:

SalesInvoice invoice = new SalesInvoice();

invoice.DocumentTypeKey = new SalesDocumentTypeKey { Type = SalesDocumentType.Invoice };
invoice.CustomerKey = originalOrder.CustomerKey;
invoice.BatchKey = originalOrder.BatchKey;
invoice.Terms = new SalesTerms { DiscountTakenAmount = new MoneyAmount { Value = 0, Currency = "USD", DecimalDigits = 2 }, DiscountAvailableAmount = new MoneyAmount { Value = 0, Currency = "USD", DecimalDigits = 0 } };
invoice.OriginalSalesDocumentKey = originalOrder.Key;

List<SalesInvoiceLine> lineList = new List<SalesInvoiceLine>();
for (int i = 0; i < originalOrder.Lines.Length; i++)
{
    SalesInvoiceLine line = new SalesInvoiceLine();
    line.ItemKey = originalOrder.Lines[i].ItemKey;
    line.Key = new SalesLineKey { LineSequenceNumber = originalOrder.Lines[i].Key.LineSequenceNumber; }

    SalesLineLot lot = new SalesLineLot();
    lot.LotNumber = originalOrder.Lines[i].Lots[0].LotNumber;
    lot.Quantity = new Quantity { Value = 2200 };
    lot.Key = new SalesLineLotKey { SequenceNumber = originalOrder.Lines[i].Lots[0].Key.SequenceNumber };
    line.Lots = new SalesLineLot[] { lot };
    line.Quantity = new Quantity { Value = 2200 };
    lineList.Add(line);
}
invoice.Lines = lineList.ToArray();

DynamicsWS.CreateSalesInvoice(invoice, DynamicsContext, DynamicsWS.GetPolicyByOperation("CreateSalesInvoice", DynamicsContext));

执行时,我收到以下错误:

SQL Server Exception: Operation expects a parameter which was not supplied.

以及来自 Dynamics 中的异常控制台的更详细的异常:

Procedure or function 'taSopLotAuto' expects parameter '@I_vLNITMSEQ',
which was not supplied.

经过 Google 大量挖掘后,我发现了一些事情。

  1. “taSopLotAuto”是销售订单处理组件中的一个 eConnect 过程,尝试自动填充批次。我不希望自动填充批次,这就是为什么我尝试在代码中手动填充它们。我还针对 GP Web 服务用户将 CreateSalesInvoice 策略从自动批次履行修改为手动批次履行,但这并没有改变调用的 eConnect 过程。
  2. “@I_vLNITMSEQ”指的是 LineSequenceNumber。 LineSequenceNumber 和 SequenceNumber(批次本身)必须匹配。在我的例子中,它们都是默认值:16384。这个参数不仅在上面的代码中设置,而且还出现在服务器尝试处理的 SOAP 消息中 - 几乎“未提供”。

我可以顺利创建无行项目的发票,但如果添加行项目,则会失败。我不明白为什么我收到明显存在的缺失参数的错误。

关于如何通过 Dynamics GP 10.0 Web 服务成功创建 SalesInvoice 有什么想法吗?

I'm trying to use the following code to create a new SalesInvoice based on an existing SalesOrder:

SalesInvoice invoice = new SalesInvoice();

invoice.DocumentTypeKey = new SalesDocumentTypeKey { Type = SalesDocumentType.Invoice };
invoice.CustomerKey = originalOrder.CustomerKey;
invoice.BatchKey = originalOrder.BatchKey;
invoice.Terms = new SalesTerms { DiscountTakenAmount = new MoneyAmount { Value = 0, Currency = "USD", DecimalDigits = 2 }, DiscountAvailableAmount = new MoneyAmount { Value = 0, Currency = "USD", DecimalDigits = 0 } };
invoice.OriginalSalesDocumentKey = originalOrder.Key;

List<SalesInvoiceLine> lineList = new List<SalesInvoiceLine>();
for (int i = 0; i < originalOrder.Lines.Length; i++)
{
    SalesInvoiceLine line = new SalesInvoiceLine();
    line.ItemKey = originalOrder.Lines[i].ItemKey;
    line.Key = new SalesLineKey { LineSequenceNumber = originalOrder.Lines[i].Key.LineSequenceNumber; }

    SalesLineLot lot = new SalesLineLot();
    lot.LotNumber = originalOrder.Lines[i].Lots[0].LotNumber;
    lot.Quantity = new Quantity { Value = 2200 };
    lot.Key = new SalesLineLotKey { SequenceNumber = originalOrder.Lines[i].Lots[0].Key.SequenceNumber };
    line.Lots = new SalesLineLot[] { lot };
    line.Quantity = new Quantity { Value = 2200 };
    lineList.Add(line);
}
invoice.Lines = lineList.ToArray();

DynamicsWS.CreateSalesInvoice(invoice, DynamicsContext, DynamicsWS.GetPolicyByOperation("CreateSalesInvoice", DynamicsContext));

When executed, I receive the following error:

SQL Server Exception: Operation expects a parameter which was not supplied.

And the more detailed exception from the Exception Console in Dynamics:

Procedure or function 'taSopLotAuto' expects parameter '@I_vLNITMSEQ',
which was not supplied.

After a considerable amount of digging through Google, I discovered a few things.

  1. 'taSopLotAuto' is an eConnect procedure within the Sales Order Processing component that attempts to automatically fill lots. I do not want the lots automatically filled, which is why I try to fill them manually in the code. I've also modified the CreateSalesInvoice policy from Automatic lot fulfillment to Manual lot fulfillment for the GP web services user, but that didn't change which eConnect procedure was called.
  2. '@I_vLNITMSEQ' refers to the LineSequenceNumber. The LineSequenceNumber and SequenceNumber (of the Lot itself) must match. In my case they are both the default: 16384. Not only is this parameter set in the code above, but it also appears in the SOAP message that the server attempted to process - hardly "not supplied."

I can create an invoice sans line items without a hitch, but if I add line items it fails. I do not understand why I am receiving an error for a missing parameter that is clearly present.

Any ideas on how to successfully create a SalesInvoice through Dynamics GP 10.0 Web Services?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦言归人 2024-11-24 05:25:27

也许你把线路键添加到了地段上:

lot.Key = new SalesLineKey(); 
lot.Key.SalesDocumentKey = new SalesDocumentKey(); 
lot.Key.SalesDocumentKey.Id = seq.ToString();

Maybe you mess to add the line key to the lot:

lot.Key = new SalesLineKey(); 
lot.Key.SalesDocumentKey = new SalesDocumentKey(); 
lot.Key.SalesDocumentKey.Id = seq.ToString();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文