如何通过 Dynamics GP 更改单价 API
How to change UnitPrice via Dynamics GP API
我想在通过 Dynamics GP 创建订单时更改单价 API,
所以我运行下一个代码:
// Create a sales order object
var salesOrder = new SalesOrder();
// Create a sales document type key for the sales order
var salesOrderType = new SalesDocumentTypeKey();
salesOrderType.Type = SalesDocumentType.Order;
// Populate the document type key of the sales order object
salesOrder.DocumentTypeKey = salesOrderType;
// Create a customer key
var customerKey = new CustomerKey();
customerKey.Id = customerSummary[0].Key.Id;
// Set the customer key property of the sales order object
salesOrder.CustomerKey = customerKey;
// Create a batch key
var batchKey = new BatchKey();
batchKey.Id = "01-INBOUND";
// Set the batch key property of the sales order object
salesOrder.BatchKey = batchKey;
// Create a sales order line to specify the ordered item
var salesOrderLine = new SalesOrderLine();
// Create an item key
var orderedItem = new ItemKey();
orderedItem.Id = "AA1111";
// Set the item key property of the sales order line object
salesOrderLine.ItemKey = orderedItem;
// Create a sales order quantity object
var orderedAmount = new Quantity();
orderedAmount.Value = 1;
// Set the quantity of the sales order line object
salesOrderLine.Quantity = orderedAmount;
// THIS DOESN'T WORK
salesOrderLine.UnitPrice = new MoneyAmount { Value = 1.11m, Currency = "USD" };
// Discount works ok
// salesOrderLine.Discount = new MoneyPercentChoice { Item = new MoneyAmount { Value = 1.25m } };
// Create an array of sales order lines
// Initialize the array with sales order line object
SalesOrderLine[] orders = { salesOrderLine };
// Add the sales order line array to the sales order
salesOrder.Lines = orders;
// Get the create policy for the sales order object
var salesOrderCreatePolicy = dynamicsGP.GetPolicyByOperation("CreateSalesOrder", context);
// Create the sales order
dynamicsGP.CreateSalesOrder(salesOrder, context, salesOrderCreatePolicy);
但是更改单价的行不起作用。
salesOrderLine.UnitPrice = new MoneyAmount { Value = 1.11m, Currency = "USD" };
我做错了什么?感谢任何帮助。
谢谢!
找到解决方案:
In Dynamics GP Web Service Policy Configuration for Update Sales
Invoice Policy, you need to update the “Calculate Unit Price Behavior”
to “Do Not Calculate”.
Also, make Sure that you have selected the right Company and assigned
proper roles for the policy. The role should not be Default.
来源:https://www.cloudfronts.com/dynamics-gp-sales-invoice-unit-price-always-0/
我想在通过 Dynamics GP 创建订单时更改单价 API,
所以我运行下一个代码:
// Create a sales order object
var salesOrder = new SalesOrder();
// Create a sales document type key for the sales order
var salesOrderType = new SalesDocumentTypeKey();
salesOrderType.Type = SalesDocumentType.Order;
// Populate the document type key of the sales order object
salesOrder.DocumentTypeKey = salesOrderType;
// Create a customer key
var customerKey = new CustomerKey();
customerKey.Id = customerSummary[0].Key.Id;
// Set the customer key property of the sales order object
salesOrder.CustomerKey = customerKey;
// Create a batch key
var batchKey = new BatchKey();
batchKey.Id = "01-INBOUND";
// Set the batch key property of the sales order object
salesOrder.BatchKey = batchKey;
// Create a sales order line to specify the ordered item
var salesOrderLine = new SalesOrderLine();
// Create an item key
var orderedItem = new ItemKey();
orderedItem.Id = "AA1111";
// Set the item key property of the sales order line object
salesOrderLine.ItemKey = orderedItem;
// Create a sales order quantity object
var orderedAmount = new Quantity();
orderedAmount.Value = 1;
// Set the quantity of the sales order line object
salesOrderLine.Quantity = orderedAmount;
// THIS DOESN'T WORK
salesOrderLine.UnitPrice = new MoneyAmount { Value = 1.11m, Currency = "USD" };
// Discount works ok
// salesOrderLine.Discount = new MoneyPercentChoice { Item = new MoneyAmount { Value = 1.25m } };
// Create an array of sales order lines
// Initialize the array with sales order line object
SalesOrderLine[] orders = { salesOrderLine };
// Add the sales order line array to the sales order
salesOrder.Lines = orders;
// Get the create policy for the sales order object
var salesOrderCreatePolicy = dynamicsGP.GetPolicyByOperation("CreateSalesOrder", context);
// Create the sales order
dynamicsGP.CreateSalesOrder(salesOrder, context, salesOrderCreatePolicy);
但是更改单价的行不起作用。
salesOrderLine.UnitPrice = new MoneyAmount { Value = 1.11m, Currency = "USD" };
我做错了什么?感谢任何帮助。
谢谢!
找到解决方案:
In Dynamics GP Web Service Policy Configuration for Update Sales Invoice Policy, you need to update the “Calculate Unit Price Behavior” to “Do Not Calculate”.
Also, make Sure that you have selected the right Company and assigned proper roles for the policy. The role should not be Default.
来源:https://www.cloudfronts.com/dynamics-gp-sales-invoice-unit-price-always-0/