我正在尝试创建Quickbooks Online(QBO)发票。我可以在QBO中创建发票,但金额和余额设置为0.00。我已经确认我传递给QBO的发票(QBOInvoice)包含正确的信息,但是,我收到的发票(resultInvoice)没有规定的金额和余额。
任何指导或建议?感谢。
Invoice QBOinvoice = new Invoice();
QBOinvoice.DocNumber = Guid.NewGuid().ToString("N").Substring(0, 10);
QBOinvoice.Deposit = new Decimal(0.00);
QBOinvoice.DepositSpecified = true;
QBOinvoice.AllowIPNPayment = false;
QBOinvoice.AllowIPNPaymentSpecified = true;
QBOinvoice.BillAddr = customer.BillAddr;
QBOinvoice.ShipAddr = customer.ShipAddr;
QBOinvoice.CustomerRef = new ReferenceType()
{
name = customer.DisplayName,
Value = customer.Id
};
QBOinvoice.DueDate = DateTime.UtcNow.Date;
QBOinvoice.DueDateSpecified = true;
QBOinvoice.PrintStatus = PrintStatusEnum.NotSet;
QBOinvoice.PrintStatusSpecified = true;
QBOinvoice.EmailStatus = EmailStatusEnum.NotSet;
QBOinvoice.EmailStatusSpecified = true;
var serviceRecord = db.t_CleaningRecords.Where(p => p.ID == MOSESInvoice.ServiceRecordID).Single();
QBOinvoice.ShipDate = serviceRecord.ServiceDate ?? DateTime.Parse("01/01/1900"); // Used to address the fact that the DB column allows for nulls;
QBOinvoice.ARAccountRef = new ReferenceType()
{
type = Enum.GetName(typeof(objectNameEnumType), objectNameEnumType.Account),
name = "Account Receivable",
Value = "QB:37"
};
QBOinvoice.Balance = MOSESInvoice.InvoiceAmount;
QBOinvoice.BalanceSpecified = true;
QBOinvoice.TotalAmt = MOSESInvoice.InvoiceAmount;
QBOinvoice.TotalAmtSpecified = true;
// Create Sales Line Item
Line invoiceline = new Line();
invoiceline.Id = "1";
//invoiceline.LineNum = "1";
invoiceline.Description = servloc.StreetAddress.ToString() + " :: " + MOSESInvoice.ServiceDescription;
//invoiceline.Description = servloc.StreetAddress.ToString() + " :: " + servdef.ServiceDefinitionName.ToString(); // This maps to Sales Definition Name & Street Address.
invoiceline.Amount = Convert.ToDecimal(MOSESInvoice.InvoiceAmount);
invoiceline.AmountSpecified = true;
invoiceline.DetailType = LineDetailTypeEnum.SalesItemLineDetail;
invoiceline.DetailTypeSpecified = true;
SalesItemLineDetail slidetails = new SalesItemLineDetail();
slidetails.ItemRef = new ReferenceType() { name = "B2C - Every 1 Week" }; // Product/Service column on Line Item Detail. 1 = Services. 2 = Hours.
slidetails.ServiceDate = serviceRecord.ServiceDate ?? DateTime.Parse("01/01/1900");
invoiceline.AnyIntuitObject = slidetails;
QBOinvoice.Line = new Line[] { invoiceline };
Invoice resultInvoice = serviceme.Add(QBOinvoice) as Invoice;
db.SaveChanges();
return QBOinvoice;
答案 0 :(得分:0)
我弄清楚问题是什么。我传递的是我的QBO公司中不存在的SalesItemLineDetail值。因此,如果不发送正确的值,我就失败了。但...
API简单而安静地更改了发票余额和总金额,然后接受了新发票。
在我看来,QBO API应该已经阻止了操作,发出警告,或者没有覆盖发票余额和提供的总金额。
我使用Intuit记录了支持票,并提供了此问题和解决方案。