0

我正在尝试通过 IPP 将发票插入空白的 Quickbooks 商店。插入将始终失败,因为发票行项目的项目 ID 不存在。我一直在尝试多种途径来解决这个问题,但没有成功。我以为我可以查询项目,如果它找不到我正在寻找的项目,它将创建它。我似乎无法让它发挥作用。我可以用我创建的新项目创建发票吗?

我目前这样构建发票:(问题是以“object [] invoiceItemValues”开头的行) Intuit.Ipp.Data.Qbd.InvoiceHeader invoiceHeader = new Intuit.Ipp.Data.Qbd.InvoiceHeader(); invoiceHeader.ARAccountName = "应收账款"; invoiceHeader.BillAddr = 物理地址;invoiceHeader.CustomerName = 客户名称;invoiceHeader.DocNumber = (invoiceMaxId).ToString().PadLeft(4, '0'); invoiceHeader.TaxAmt = 销售税;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 INVALID key = 30 domain=QB enum = Item”

这是尝试查询项目的内容,但也需要 ID。

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>();
4

1 回答 1

0

请参阅 QBO 中的示例,类似地您可以为 QBD- Intuit.Ipp.Data.Qbo.Invoice invoice = new 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;
于 2013-09-30T16:16:30.997 回答