Acumatica 如何使用API包含多个事务
我有一个例子,创建销售订单。我尝试用两行SO创建订单。但我注意到一些意想不到的结果。单价和折扣百分比金额不正确。我想我的命令设置不正确。请告知Acumatica 如何使用API包含多个事务,acumatica,Acumatica,我有一个例子,创建销售订单。我尝试用两行SO创建订单。但我注意到一些意想不到的结果。单价和折扣百分比金额不正确。我想我的命令设置不正确。请告知 context.SetSchema(SO301000); List cmds=新列表(); cmds.AddRange(新命令[]{ //SO头 新值{Value=“SO”,LinkedCommand=SO301000.OrderSummary.OrderType}, 新值{Value=”“,LinkedCommand=SO301000.OrderS
context.SetSchema(SO301000);
List cmds=新列表();
cmds.AddRange(新命令[]{
//SO头
新值{Value=“SO”,LinkedCommand=SO301000.OrderSummary.OrderType},
新值{Value=”“,LinkedCommand=SO301000.OrderSummary.OrderNbr},
新值{Value=“01/10/2015”,LinkedCommand=SO301000.OrderSummary.Date},
新值{Value=“01/12/2015”,LinkedCommand=SO301000.OrderSummary.RequestedOn},
新值{Value=“09952”,LinkedCommand=SO301000.OrderSummary.CustomerOrder},//外部客户参考编号
新值{Value=“ABARTENDE”,LinkedCommand=SO301000.OrderSummary.Customer},
新值{Value=“new SALES ORDER”,LinkedCommand=SO301000.OrderSummary.Description},
//设置一些装运信息
新值{Value=“01/21/2015”,LinkedCommand=SO301000.ShippingSettingsShippingInformation.SchedShipping},
新值{Value=“允许延期订单”,LinkedCommand=SO301000.ShippingSettingsShippingInformation.ShippingRule},
//将Acumatica库存项目添加到SO事务处理
SO301000.DocumentDetails.ServiceCommands.NewRow,
新值{Value=“MAIN”,LinkedCommand=SO301000.DocumentDetails.Branch},
新值{Value=“d00000000”,LinkedCommand=SO301000.DocumentDetails.InventoryID},
新值{Value=“RETAIL”,LinkedCommand=SO301000.DocumentDetails.Warehouse},
新值{Value=“5”,LinkedCommand=SO301000.DocumentDetails.Quantity},
新值{Value=“100”,LinkedCommand=SO301000.DocumentDetails.UnitPrice},
//将3%的折扣百分比添加到行项目的单价中
新值{Value=“3”,LinkedCommand=SO301000.DocumentDetails.DiscountPercent},
//将Acumatica非库存项目添加到SO事务处理
SO301000.DocumentDetails.ServiceCommands.NewRow,
新值{Value=“MAIN”,LinkedCommand=SO301000.DocumentDetails.Branch},
新值{Value=“ACCOMODATION”,LinkedCommand=SO301000.DocumentDetails.InventoryID},
//有意在下面的左注释行中创建异常
新值{Value=“RETAIL”,LinkedCommand=SO301000.DocumentDetails.Warehouse},
新值{Value=“支持团队的酒店”,LinkedCommand=SO301000.DocumentDetails.LineDescription},//覆盖与非库存项目关联的项目描述
新值{Value=“1”,LinkedCommand=SO301000.DocumentDetails.Quantity},
新值{Value=“300”,LinkedCommand=SO301000.DocumentDetails.UnitPrice},//这是一家不错的酒店
SO301000.Actions.Save,
//下一行允许Acumatica SO订单编号的自动编号顺序,该顺序在SO首选项屏幕中设置
SO301000.OrderSummary.OrderNbr});
string orderNumber=string.Empty;
var contentReturned=context.Submit(cmds.ToArray());
orderNumber=contentReturned[0]。OrderSummary.OrderNbr.Value;
}
catch(SoapException ex){}
下面是我如何添加多行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;
}
cmds.Clear();
//创建销售订单标题
尝试
{
cmds.AddRange(
新的SO301000_509.命令[]
{
so301000.Actions.Insert,
新的SO301000_509.Value{Value=“SO”,LinkedCommand=SO301000.OrderSummary.OrderType},
新建SO301000_509.Value{Value=“='new'”,LinkedCommand=SO301000.OrderSummary.OrderNbr},
新的SO301000_509.Value{Value=DealOrder.accountCode,LinkedCommand=SO301000.OrderSummary.Customer},
新的SO301000_509.Value{Value=(DealOrder.orderDateTime),LinkedCommand=SO301000.OrderSummary.Date},
新的SO301000_509.Value{Value=“Hubsoft Order Nbr:“+DealOrder.hubsoftOrderNumber,LinkedCommand=SO301000.OrderSummary.Description},
新的SO301000_509.Value{Value=DealOrder.hubsoftOrderNumber,LinkedCommand=SO301000.OrderSummary.CustomerRef},
新的SO301000_509.Value{Value=“HS-”+DealOrder.purchaseOrderNumber,LinkedCommand=SO301000.OrderSummary.CustomerOrder},
新的SO301000_509.Value{Value=dealerOrder.notes,LinkedCommand=SO301000.OrderSummary.NoteText},
新的SO301000_509.Value{Value=“true”,LinkedCommand=SO301000.ShippingSettingsShipToInfo.OverrideAddress},
新的SO301000_509.Value{Value=shipStreet1,LinkedCommand=SO301000.ShippingSettingsShipToInfo.AddressLine1},
新的SO301000_509.Value{Value=shipStreet2,LinkedCommand=SO301000.ShippingSettingsShipToInfo.AddressLine2},
新的SO301000_509.Value{Value=shipCity,LinkedCommand=SO301000.ShippingSettingsShipToInfo.City},
新的SO301000_509.Value{Value=shipState,LinkedCommand=SO301000.ShippingSettingsShipToInfo.State},
新的SO301000_509.Value{Value=shipCountry,LinkedCommand=SO301000.ShippingSettingsShipToInfo.Country},