付款未创建
我的付款未显示在QuickBooks中。
我可以成功创建和更新客户。 我还可以成功创建和更新发票。 我无法创建付款。 但是就是这样,当我在我的Payment对象上执行Update命令时,我确实得到了一个正确的Id和域(NG)。 我在运行Sync后检查了同步日志文件(IntuitSyncManagerLogger.log),但它没有错误消息。 一切看起来都不错,QuickBooks中没有与发票相关的付款。
我相信我正在设置所有必需的字段,但我不确定其中的两个。
1)PaymentLine有一个名为TxnId的字段。 我将它设置为InvoiceHeader的Id和Domain,但我不确定这是否正确。
2)还有另一个必填字段(根据文档)但我将其留空,因为我不知道要填充什么。 这是DiscountAccountId字段。 我不想要与发票相关的折扣。
这是我的代码……
SqlConnection connection = new SqlConnection(m_connectionString); connection.Open(); SqlCommand cmd = new SqlCommand("dbo.Intuit_GetPayment", connection); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@glmvSyncId", SqlDbType.Int).Value = glmvSyncId; SqlDataReader rdr = cmd.ExecuteReader(); rdr.Read(); Intuit.Ipp.Data.Qbd.PaymentHeader paymentHeader = new Intuit.Ipp.Data.Qbd.PaymentHeader(); paymentHeader.ARAccountId = new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB, Value = "37" }; paymentHeader.ARAccountName = "Accounts Receivable"; paymentHeader.DepositToAccountId = new Intuit.Ipp.Data.Qbd.IdType() { idDomain = Intuit.Ipp.Data.Qbd.idDomainEnum.QB, Value = "35" }; paymentHeader.DepositToAccountName = "Undeposited Funds"; paymentHeader.CustomerId = new Intuit.Ipp.Data.Qbd.IdType() { idDomain = (rdr["cust_iddomain"].ToString() == "QB" ? Intuit.Ipp.Data.Qbd.idDomainEnum.QB : Intuit.Ipp.Data.Qbd.idDomainEnum.NG), Value = rdr["cust_idvalue"].ToString() }; // cust_iddomain and cust_idvalue are from the Customer paymentHeader.DocNumber = rdr["invoicekey"].ToString(); paymentHeader.TxnDate = DateTime.Now; List listLine = new List(); var paymentLine = new Intuit.Ipp.Data.Qbd.PaymentLine(); paymentLine.Amount = Convert.ToDecimal(rdr["amount"]); paymentLine.TxnId = new Intuit.Ipp.Data.Qbd.IdType() { idDomain = (rdr["invc_iddomain"].ToString() == "QB" ? Intuit.Ipp.Data.Qbd.idDomainEnum.QB : Intuit.Ipp.Data.Qbd.idDomainEnum.NG), Value = rdr["invc_idvalue"].ToString() }; // invc_iddomain and invc_idvalue are from the InvoiceHeader listLine.Add(paymentLine); Intuit.Ipp.Data.Qbd.Payment syncPayment = new Intuit.Ipp.Data.Qbd.Payment(); syncPayment.Header = paymentHeader; syncPayment.Line = listLine.ToArray(); connection.Close(); Intuit.Ipp.Data.Qbd.Payment resultPayment = new Intuit.Ipp.Data.Qbd.Payment(); resultPayment = commonService.Add(syncPayment);
我怀疑问题出在TxnId上。
我正在做的就是创建一个客户,然后为客户创建一个发票,然后为发票创建一个付款。 我在某个地方错过了一个物体吗?
非常感谢任何和所有的帮助。
同步后,付款可能会进入错误状态。 您可以通过执行PaymentQuery并设置ErroredObjectsOnly = true来检查。
如果实体处于错误状态,您可以使用Status API查询特定原因:
SyncStatusRequest syncStatusRequest = new SyncStatusRequest(); syncStatusRequest.ErroredObjectsOnly = true; syncStatusRequest.NgIdSet = new NgIdSet[] { new NgIdSet { NgId = <>, NgObjectType = objectName.Payment } }; SyncStatusResponse[] response = dataServices.GetSyncStatus(syncStatusRequest);
如果付款处于错误状态,您可以从云中删除该实体,因为它从未与QuickBooks同步:
如果实体成功同步确实至少发生一次,但随后Update将其推入错误状态,则需要执行Revert:
一旦从Status API知道原因,您也可以尝试直接在处于错误状态的实体上执行更新,但是没有记录,因此它可能无法正常工作。
添加以下代码行似乎解决了这个问题。 付款现在正在QuickBooks中记录。
paymentHeader.TotalAmt = Convert.ToDecimal(rdr["amount"]); paymentHeader.TotalAmtSpecified = true;