我試圖通過IPP將發票插入空白的Quickbooks商店。插入將始終失敗,因爲「發票」訂單項的商品ID不存在。我一直在嘗試多種方式來編碼,但沒有成功。我以爲我可以查詢的項目,如果它不能找到我正在尋找它將創建它。我似乎無法得到這個工作。我可以用我創建的新項目創建發票嗎?Intuit合作伙伴平臺 - 無法添加發票,因爲商品ID未知
我目前建立這樣的發票:(問題是,用「對象[] invoiceItemValues」開頭的行) Intuit.Ipp.Data.Qbd.InvoiceHeader invoiceHeader =新Intuit.Ipp.Data.Qbd.InvoiceHeader (); invoiceHeader.ARAccountName =「Accounts Receivable」; invoiceHeader.BillAddr = physicalAddress; invoiceHeader.CustomerName = customer.Name; invoiceHeader.DocNumber =(invoiceMaxId).ToString()。PadLeft(4,'0'); invoiceHeader.TaxAmt = salesTax; invoiceHeader.TotalAmt =金額;
List<Intuit.Ipp.Data.Qbd.InvoiceLine> listLine = new List<Intuit.Ipp.Data.Qbd.InvoiceLine>();
Intuit.Ipp.Data.Qbd.ItemsChoiceType2[] invoiceItemAttributes = { Intuit.Ipp.Data.Qbd.ItemsChoiceType2.ItemId, Intuit.Ipp.Data.Qbd.ItemsChoiceType2.UnitPrice, Intuit.Ipp.Data.Qbd.ItemsChoiceType2.Qty };
object[] invoiceItemValues = { new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB, Value = "2" }, amount, new decimal(1) };
var invoiceLine = new Intuit.Ipp.Data.Qbd.InvoiceLine();
invoiceLine.Amount = amount;
invoiceLine.AmountSpecified = true;
invoiceLine.Desc = "test " + date.ToShortDateString(); // TODO: This will need to hold the additional fields
invoiceLine.ItemsElementName = invoiceItemAttributes;
invoiceLine.Items = invoiceItemValues;
invoiceLine.ServiceDate = date;
invoiceLine.ServiceDateSpecified = true;
listLine.Add(invoiceLine);
Intuit.Ipp.Data.Qbd.Invoice invoice = new Intuit.Ipp.Data.Qbd.Invoice();
invoice.Header = invoiceHeader;
invoice.Line = listLine.ToArray();
這是我的錯誤:「驗證的txn_line_rec.item_id無效鍵= 30 =域QB枚舉=項目」
這裏是試圖查詢項目,還需要標識。
ItemQuery qbdItemQuery = new ItemQuery();
qbdItemQuery.Items = new object[] { new IdSet() { Id = new IdType[] { new IdType() { idDomain = idDomainEnum.NG, Value = "79841" } } } };
qbdItemQuery.ItemsElementName = new ItemsChoiceType4[] { ItemsChoiceType4.ListIdSet };
List<Item> ItemQueryResult = qbdItemQuery.ExecuteQuery<Item>(context).ToList<Item>();
它看起來像你做同樣的事情。 「invoiceLine.Items = new object [] {new Intuit.Ipp.Data.Qbo.IdType(){idDomain = Intuit.Ipp.Data.Qbo.idDomainEnum.QBO,Value =」30「},100m,1m};」 。這是一個ID爲30. –
這是我得到的錯誤:「驗證txn_line_rec.item_id INVALID鍵= 30域= QB枚舉=項目」 –
我在這裏傳遞一個現有項目的ID。有關創建和檢索項目的信息,請參閱文檔https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/0600_object_reference/item您是否正在這樣做? –