付款未创建

时间:2013-02-13 21:19:59

标签: c# asp.net intuit-partner-platform

我的付款未显示在QuickBooks中。

我可以成功创建和更新客户。我也可以成功创建和更新发票。我无法创建付款。但是就是这样,当我在我的Payment对象上执行Update命令时,我确实得到了一个正确的Id和Domain(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<Intuit.Ipp.Data.Qbd.PaymentLine> listLine = new List<Intuit.Ipp.Data.Qbd.PaymentLine>();

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上。

我正在做的就是创建一个客户,然后为客户创建一个发票,然后为发票创建一个付款。我在某个地方错过了一个物体吗?

非常感谢任何和所有帮助。

2 个答案:

答案 0 :(得分:1)

付款可能会在同步后进入错误状态。您可以通过执行PaymentQuery并设置ErroredObjectsOnly = true进行检查。

https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0100_Calling_Data_Services/0015_Retrieving_Objects#Objects_in_Error_State

如果实体处于错误状态,您可以使用Status API查询具体原因:

https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0600_Object_Reference/SyncStatus

SyncStatusRequest syncStatusRequest = new SyncStatusRequest();
syncStatusRequest.ErroredObjectsOnly = true;
syncStatusRequest.NgIdSet = new NgIdSet[] { new NgIdSet { NgId = <<EnterYourNgIdHere>>, NgObjectType = objectName.Payment } };
SyncStatusResponse[] response = dataServices.GetSyncStatus(syncStatusRequest);

如果付款处于错误状态,您可以从云中删除该实体,因为它从未与QuickBooks同步:

https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0100_Calling_Data_Services/Deleting_an_Object

如果实体成功同步确实至少发生一次,但随后Update将其推入错误状态,则需要进行恢复:

https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0100_Calling_Data_Services/Reverting_an_Object

一旦您从Status API了解原因,您也可以尝试直接在处于错误状态的实体上执行更新,但是没有记录,因此它可能无法正常工作。

答案 1 :(得分:1)

添加以下代码行似乎解决了这个问题。付款现在正在QuickBooks中记录。

paymentHeader.TotalAmt = Convert.ToDecimal(rdr["amount"]);
paymentHeader.TotalAmtSpecified = true;
相关问题