2013-09-30 69 views
0

我試圖通過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>(); 

回答

0

請參閱QBO樣品,同樣可以爲QBD- Intuit.Ipp.Data.Qbo.Invoice發票=新Intuit.Ipp.Data.Qbo.Invoice碼();

Intuit.Ipp.Data.Qbo.InvoiceHeader invoiceHeader = new  Intuit.Ipp.Data.Qbo.InvoiceHeader(); 
invoiceHeader.DocNumber = "AUTO_GENERATE"; 
invoiceHeader.TxnDate = new DateTime(2013, 09, 04); 
invoiceHeader.TxnDateSpecified = true; 
invoiceHeader.CustomerId = new Intuit.Ipp.Data.Qbo.IdType() { idDomain =  Intuit.Ipp.Data.Qbo.idDomainEnum.QBO, Value = "12" }; 
invoiceHeader.SubTotalAmt = 100; 
invoiceHeader.SubTotalAmtSpecified = true; 
invoiceHeader.TotalAmt = 100; 
invoiceHeader.TotalAmtSpecified = true; 

invoice.Header = invoiceHeader; 

Intuit.Ipp.Data.Qbo.InvoiceLine invoiceLine = new Intuit.Ipp.Data.Qbo.InvoiceLine(); 
invoiceLine.Desc = "Description"; 
invoiceLine.Amount = 100; 
invoiceLine.AmountSpecified = true; 
invoiceLine.Taxable = false; 
invoiceLine.TaxableSpecified = true; 
invoiceLine.ItemsElementName = new Intuit.Ipp.Data.Qbo.ItemsChoiceType2[] {  Intuit.Ipp.Data.Qbo.ItemsChoiceType2.ItemId,  Intuit.Ipp.Data.Qbo.ItemsChoiceType2.UnitPrice, Intuit.Ipp.Data.Qbo.ItemsChoiceType2.Qty }; 
invoiceLine.Items = new object[] { new Intuit.Ipp.Data.Qbo.IdType() { idDomain = Intuit.Ipp.Data.Qbo.idDomainEnum.QBO, Value = "30" }, 100m, 1m }; 

invoice.Line = new Intuit.Ipp.Data.Qbo.InvoiceLine[] { invoiceLine }; 

Intuit.Ipp.Data.Qbo.Invoice addedInvoice = dataService.Add<Intuit.Ipp.Data.Qbo.Invoice>(invoice); 

編輯: 要創建本期特價貨品

Intuit.Ipp.Data.Qbo.Item qboItem = new Intuit.Ipp.Data.Qbo.Item();       
         qboItem.Name = "nemoitem11"; 
         qboItem.Desc = "Itemdesc"; 
         qboItem.UnitPrice = new Money() ; 
         qboItem.UnitPrice.Amount = 20; 
         qboItem.IncomeAccountRef = new AccountRef(); 
         qboItem.IncomeAccountRef.AccountId = new IdType() { idDomain = idDomainEnum.QBO, Value = "1" }; 
         Item resultItem = commonService.Add(qboItem) as Item; 
+0

它看起來像你做同樣的事情。 「invoiceLine.Items = new object [] {new Intuit.Ipp.Data.Qbo.IdType(){idDomain = Intuit.Ipp.Data.Qbo.idDomainEnum.QBO,Value =」30「},100m,1m};」 。這是一個ID爲30. –

+0

這是我得到的錯誤:「驗證txn_line_rec.item_id INVALID鍵= 30域= QB枚舉=項目」 –

+0

我在這裏傳遞一個現有項目的ID。有關創建和檢索項目的信息,請參閱文檔https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/v2/0500_quickbooks_windows/0600_object_reference/item您是否正在這樣做? –

相關問題