1

我可以在 Quickbook 上在线创建发票,但是当我在线查看 quickbook 发票时,它会创建项目列表,但缺少价格和描述。我做错了什么。

          invoice.AlternateId = new NameValue[] { new NameValue() { Name = "InvoiceID", Value = service.InvoiceId } };

                InvoiceHeader Header = new InvoiceHeader();
                Header.DocNumber = service.InvoiceId;
                Header.TxnDate = service.ServiceDate;
                Header.TxnDateSpecified = true;
                Header.Msg = service.Note.ToString();
                Header.Note = service.Note.ToString();

                Header.CustomerId = new IdType() { idDomain = idDomainEnum.QBO, Value = service.CustomerNumberOnline };
                Header.Currency = currencyCode.USD;
                Header.ShipDate = service.ServiceDate;
                Header.ShipDateSpecified = true;


                //Print and Email Option fields
                if (EmailPrintOption == "Both")
                {
                    Header.ToBeEmailed = true;
                    Header.ToBeEmailedSpecified = true;
                    Header.ToBePrinted = true;
                    Header.ToBePrintedSpecified = true;
                }
                else if (EmailPrintOption == "print")
                {
                    Header.ToBePrinted = true;
                    Header.ToBePrintedSpecified = true;
                }
                else if (EmailPrintOption == "email")
                {
                    Header.ToBeEmailed = true;
                    Header.ToBeEmailedSpecified = true;
                }
                else
                {
                    Header.ToBeEmailed = false;
                    Header.ToBeEmailedSpecified = false;
                    Header.ToBePrinted = false;
                    Header.ToBePrintedSpecified = false;

                }

                PhysicalAddress BillAddress = new PhysicalAddress();
                BillAddress.Line1 = service.SoldToAddress;
                BillAddress.City = service.SoldToCity;
                BillAddress.CountrySubDivisionCode = service.SoldToState;
                BillAddress.PostalCode = service.SoldToZip;
                BillAddress.Tag = new string[] { "Billing" };
                Header.BillAddr = BillAddress;

                PhysicalAddress ShipAddress = new PhysicalAddress();
                ShipAddress.Line1 = service.JobJocationAddress;
                ShipAddress.City = service.JobLocationCity;
                ShipAddress.CountrySubDivisionCode = service.JobLocationState;
                ShipAddress.PostalCode = service.JobLocationZip;
                BillAddress.Tag = new string[] { "Shipping" };
                Header.ShipAddr = ShipAddress;

                decimal discount;
                if (decimal.TryParse(service.Discount, out discount))
                {
                    Header.ItemElementName = ItemChoiceType2.DiscountAmt;
                    Header.Item = -1 * discount;  //discount must be negative
                }

                InvoiceLine[] InvoiceLines = new InvoiceLine[TaskOnlineIDs.Count];
                object[] intuitItems = new object[TaskOnlineIDs.Count];
                for (int i = 0; i < InvoiceLines.Length; i++)
                {
                    InvoiceLines[i] = new InvoiceLine();
                    InvoiceLines[i].ItemsElementName = new Intuit.Ipp.Data.Qbo.ItemsChoiceType2[]
                            {
                                Intuit.Ipp.Data.Qbo.ItemsChoiceType2.ItemId
                            };
                    InvoiceLines[i].Items = new object[] {
                        new IdType(){idDomain=idDomainEnum.QBO, Value=TaskOnlineIDs[i]}   
                    };
                }
                invoice.Line = InvoiceLines; 

                Header.SalesTermName = service.PaymentType;
                Header.SalesRepName = service.TechName;
                Header.PONumber = service.PurchaseOrder;
                invoice.Header = Header;

我在这里想念什么?? 这里发生的情况是,当我将发票行添加到发票时,它默认将每个项目的金额设置为“0”,所以当我尝试务实地添加折扣时,它给我的折扣大于小计的错误是正确的。但我的问题是,为什么在我之前已经定义它们时,我需要明确地为每个项目添加成本。我们应该只添加 itemId 和 rest QB 应该计算。

4

0 回答 0