我有一个例子,用于创建销售订单。我尝试用两条SO线创建一个订单。但我发现一些意想不到的结果。单价和折扣百分比金额不正确。我想我的命令设置不正确。请指教。
context.SetSchema(SO301000);
List<Command> cmds = new List<Command>();
cmds.AddRange(new Command[]{
//SO header
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "<NEW>", LinkedCommand = SO301000.OrderSummary.OrderNbr },
new Value { Value = "01/10/2015", LinkedCommand = SO301000.OrderSummary.Date },
new Value { Value = "01/12/2015", LinkedCommand = SO301000.OrderSummary.RequestedOn },
new Value { Value = "09952", LinkedCommand = SO301000.OrderSummary.CustomerOrder }, //external customer reference nbr
new Value { Value = "ABARTENDE", LinkedCommand = SO301000.OrderSummary.Customer },
new Value { Value = "NEW SALES ORDER", LinkedCommand = SO301000.OrderSummary.Description },
//set some shipping information
new Value { Value = "01/21/2015", LinkedCommand = SO301000.ShippingSettingsShippingInformation.SchedShipment },
new Value { Value = "Back Order Allowed", LinkedCommand = SO301000.ShippingSettingsShippingInformation.ShippingRule },
//add an Acumatica Stock Item to the SO transaction
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value { Value = "MAIN", LinkedCommand = SO301000.DocumentDetails.Branch },
new Value { Value = "D000000000", LinkedCommand = SO301000.DocumentDetails.InventoryID },
new Value { Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse },
new Value { Value = "5", LinkedCommand = SO301000.DocumentDetails.Quantity },
new Value { Value = "100", LinkedCommand = SO301000.DocumentDetails.UnitPrice },
//add a 3% discount percentage to the unit price of the line item
new Value { Value = "3", LinkedCommand = SO301000.DocumentDetails.DiscountPercent },
//add an Acumatica non-stock Item to the SO transaction
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value { Value = "MAIN", LinkedCommand = SO301000.DocumentDetails.Branch },
new Value { Value = "ACCOMODATION", LinkedCommand = SO301000.DocumentDetails.InventoryID },
//intentially left comment line below to create an exception
new Value { Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse },
new Value { Value = "Hotel for the support team", LinkedCommand = SO301000.DocumentDetails.LineDescription }, //override the item description that is associated to the non-stock item
new Value { Value = "1", LinkedCommand = SO301000.DocumentDetails.Quantity },
new Value { Value = "300", LinkedCommand = SO301000.DocumentDetails.UnitPrice }, //its a nice hotel
SO301000.Actions.Save,
//line below allows the autonumbering sequence of the Acumatica SO order numbers, which is set up in the SO preferences screen
SO301000.OrderSummary.OrderNbr});
string orderNumber = string.Empty;
var contentReturned = context.Submit(cmds.ToArray());
orderNumber = contentReturned[0].OrderSummary.OrderNbr.Value;
}
catch (SoapException ex) { }
答案 0 :(得分:2)
在UnitPrice字段
下设置Commit = true答案 1 :(得分:0)
以下是我添加多行SO的方法。你可能会看到一些有用的东西。
cmds.Clear();
// create the Sales Order header
try
{
cmds.AddRange(
new SO301000_509.Command[]
{
so301000.Actions.Insert,
new SO301000_509.Value { Value = "SO", LinkedCommand = so301000.OrderSummary.OrderType },
new SO301000_509.Value { Value = "='new'", LinkedCommand = so301000.OrderSummary.OrderNbr },
new SO301000_509.Value { Value = dealerOrder.accountCode, LinkedCommand = so301000.OrderSummary.Customer },
new SO301000_509.Value { Value = (dealerOrder.orderDateTime), LinkedCommand = so301000.OrderSummary.Date },
new SO301000_509.Value { Value = "Hubsoft Order Nbr: " + dealerOrder.hubsoftOrderNumber, LinkedCommand = so301000.OrderSummary.Description },
new SO301000_509.Value { Value = dealerOrder.hubsoftOrderNumber, LinkedCommand = so301000.OrderSummary.CustomerRef },
new SO301000_509.Value { Value = "HS-" + dealerOrder.purchaseOrderNumber, LinkedCommand = so301000.OrderSummary.CustomerOrder },
new SO301000_509.Value { Value = dealerOrder.notes, LinkedCommand = so301000.OrderSummary.NoteText},
new SO301000_509.Value { Value = "true", LinkedCommand = so301000.ShippingSettingsShipToInfo.OverrideAddress },
new SO301000_509.Value { Value = shipStreet1, LinkedCommand = so301000.ShippingSettingsShipToInfo.AddressLine1 },
new SO301000_509.Value { Value = shipStreet2, LinkedCommand = so301000.ShippingSettingsShipToInfo.AddressLine2 },
new SO301000_509.Value { Value = shipCity, LinkedCommand = so301000.ShippingSettingsShipToInfo.City },
new SO301000_509.Value { Value = shipState, LinkedCommand = so301000.ShippingSettingsShipToInfo.State },
new SO301000_509.Value { Value = shipCountry, LinkedCommand = so301000.ShippingSettingsShipToInfo.Country },
new SO301000_509.Value { Value = shipPostal, LinkedCommand = so301000.ShippingSettingsShipToInfo.PostalCode },
}
);
//create the sales order lines in loop
for (var idx = 0; idx < SalesOrderLine.Length; idx++)
{
cmds.AddRange(
new SO301000_509.Command[]
{
so301000.DocumentDetails.ServiceCommands.NewRow,
//simple line adding
so301000.DocumentDetails.ServiceCommands.NewRow,
new SO301000_509.Value { Value = SalesOrderLine[idx].inventoryCD, LinkedCommand = so301000.DocumentDetails.InventoryID },
new SO301000_509.Value { Value = SalesOrderLine[idx].UOM, LinkedCommand = so301000.DocumentDetails.UOM },
new SO301000_509.Value { Value = SalesOrderLine[idx].Qty, LinkedCommand = so301000.DocumentDetails.Quantity },
new SO301000_509.Value { Value = "MAIN", LinkedCommand = so301000.DocumentDetails.Warehouse},
new SO301000_509.Value { Value = SalesOrderLine[idx].UnitPrice, LinkedCommand = so301000.DocumentDetails.UnitPrice, Commit = true },
}
);
}
cmds.Add(so301000.Actions.Save); //save all
cmds.Add(so301000.OrderSummary.OrderNbr); //return Order #
// Submit the SalesOrder to save it
SO301000_509.Content[] SO301000Content = context.Submit(cmds.ToArray()); //submit
PXTrace.WriteInformation(SO301000Content[0].OrderSummary.OrderNbr.Value);
// Retrieve the new Sales Order #
acumaticaSONbr = SO301000Content[0].OrderSummary.OrderNbr.Value;
}
catch (Exception ex)
{
PXTrace.WriteError("Error adding Sales Order - " + ex.Message);
}
return acumaticaSONbr;
}