我正在尝试通过 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>();