製品を QuickBooks に追加しようとしていますが、次のエラーが発生します。
エラー:
{System.InvalidOperationException: XML ドキュメントにエラーがあります (1、2)。---> System.InvalidOperationException: は予期されていませんでした。Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderFaultInfo.Read3_FaultInfo() で --- 内部例外スタック トレースの終わり --- System.Xml.Serialization.XmlSerializer.Deserialize (XmlReader xmlReader、文字列 encodingStyle、XmlDeserializationEvents イベント) で System.Xml .Serialization.XmlSerializer.Deserialize(TextReader textReader) at Intuit.Ipp.Utility.XmlObjectSerializer.Deserialize[T](文字列メッセージ)}
これが私のコードです:
private Item BuildInventoryItemAddRq(JMAOrderDetail _OrderItem)
{
// Make sure we have a SKU value
if (string.IsNullOrEmpty(_OrderItem.Sku))
{
ErrorMessageDataSource.Insert(new ErrorMessage(MessageSeverity.Info, "QBO", "OrderItemId " + _OrderItem.OrderId.ToString() + " has no SKU. Using default QuickBooks Item Name of 'Unknown Item'"));
_OrderItem.Sku = "Unknown Item";
}
// create the item as an inventoryitem in Quickbooks
Item QBItem = new Item();
QBItem.Active = true;
QBItem.Name = _OrderItem.Sku;
string _ItemName = IsProductVariantNamed(_OrderItem);
//if (!string.IsNullOrEmpty(_ItemName))
//{ // its a variant product
// _ItemName += "(" + _ItemName + ")";
// if (_OrderItem != null)
// QBItem.QtyOnHand = _OrderItem.StockQuantity;
// else
// QBItem.QtyOnHand = 0;
//}
//else
//{ // regular product
// if (_OrderItem != null)
// QBItem.QtyOnHand = _OrderItem.StockQuantity;
// else
// QBItem.QtyOnHand = 0;
//}
QBItem.PurchaseDesc = _ItemName;
//QBItem.SalesDesc = _ItemName;
QBItem.PurchaseCost = new Money() { Amount = _OrderItem.Product.PurchaseCost };
//QBItem.SalesPrice = (Double)_OrderItem.UnitPriceExclTax;
QBItem.IncomeAccountRef = new AccountRef { AccountName = _qboSettings.ItemIncomeAcct };
QBItem.COGSAccountRef = new AccountRef() { AccountName = _qboSettings.ItemCOGSAcct };
QBItem.AssetAccountRef = new AccountRef() { AccountName = _qboSettings.ItemAssetAcct };
try
{
Item it = dataServices.Add(QBItem);
return it;
}
catch (Exception ex)
{
ErrorMessageDataSource.Insert(new ErrorMessage(MessageSeverity.Error, "QBO", String.Format("Error adding item : {0}", ex.ToString())));
return new Item();
}
}