如何实施";申请信用证;如果通过.Net C#代码使用Interop.QBFC13Lib.dll可为该客户提供信用,则将该信用证转换为现有发票?
我在尝试对现有发票实施Quickbooks的“应用信用”功能时遇到了问题,如果该客户可以获得信用。我可以通过Quickbooks桌面UI实现,但无法通过.Net集成应用程序(用C#编写)实现。有谁能给我介绍一下吗 我正在使用的代码通过C#代码对Quickbooks实现“应用信用”。 我得到一个错误:“QuickBooks在解析提供的XML文本流时发现了一个错误。”代码如下如何实施";申请信用证;如果通过.Net C#代码使用Interop.QBFC13Lib.dll可为该客户提供信用,则将该信用证转换为现有发票?,c#,asp.net,quickbooks,C#,Asp.net,Quickbooks,我在尝试对现有发票实施Quickbooks的“应用信用”功能时遇到了问题,如果该客户可以获得信用。我可以通过Quickbooks桌面UI实现,但无法通过.Net集成应用程序(用C#编写)实现。有谁能给我介绍一下吗 我正在使用的代码通过C#代码对Quickbooks实现“应用信用”。 我得到一个错误:“QuickBooks在解析提供的XML文本流时发现了一个错误。”代码如下 public void ApplyCreditsOnPrePayInvoices() { // open
public void ApplyCreditsOnPrePayInvoices()
{
// open connection and begin session before data fetch - intentionally skipped this code
IMsgSetRequest msgset = null;
ICreditMemoQuery creditMemoQuery = null;
string sCustomerName = string.Empty;
if (this.GetConnectedToQB()) //this is the method call to login to quickbooks desktop
{
try
{
// during data fetch
msgset = m_sessionManager.CreateMsgSetRequest("US", 8, 0);
creditMemoQuery = msgset.AppendCreditMemoQueryRq();
creditMemoQuery.ORTxnQuery.TxnFilter.ORDateRangeFilter.ModifiedDateRangeFilter.FromModifiedDate.SetValue(new DateTime(2012, 3, 31), false);
IMsgSetResponse msgRes = m_sessionManager.DoRequests(msgset);
IResponseList responseList = msgRes.ResponseList;
if (responseList.Count > 0)
{
IResponse response = responseList.GetAt(0);
ICreditMemoRetList creditMemoList = response.Detail as ICreditMemoRetList;
if (creditMemoList == null)
{
return;
}
for (int i = 0; i <= creditMemoList.Count - 1; i++)
{
ICreditMemoRet qbCreditMemo = creditMemoList.GetAt(i);
if (this.GetQBCustomerListId(qbCreditMemo.CustomerRef.FullName.GetValue()) != string.Empty)
{
m_requestMsgSet.ClearRequests();
m_requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
IInvoiceAdd invoiceAddRq = m_requestMsgSet.AppendInvoiceAddRq();
invoiceAddRq.CustomerRef.FullName.SetValue(qbCreditMemo.CustomerRef.FullName.GetValue());
ISetCredit SetCredit1 = invoiceAddRq.SetCreditList.Append();
SetCredit1.CreditTxnID.SetValue(qbCreditMemo.TxnID.GetValue());
SetCredit1.AppliedAmount.SetValue(qbCreditMemo.TotalAmount.GetValue());
IMsgSetResponse responseSetInvoice = m_sessionManager.DoRequests(m_requestMsgSet);
DataSet dsInvoice = this.GetExtractResponseFromQB(responseSetInvoice);
string sQueryResponse = Stringcl.GetValue(dsInvoice.Tables["InvoiceAddRs"].Rows[0]["statusMessage"]);
if (sQueryResponse == "Status OK")
{
Console.WriteLine("Credit no.:" + qbCreditMemo.TxnID.GetValue() + " Customer:" + qbCreditMemo.CustomerRef.FullName.GetValue() + " Total:" + qbCreditMemo.TotalAmount.GetValue());
}
}
}
}
}
catch (Exception ex)
{
string ss = ex.Message;
//handle exception here
}
finally
{
if (msgset != null)
{
Marshal.FinalReleaseComObject(msgset);
}
if (creditMemoQuery != null)
{
Marshal.FinalReleaseComObject(creditMemoQuery);
}
}
}
// end session and close connection after data fetch - intentionally skipped this code
}
public void applycreditsonpreadwardinvoices()
{
//在获取数据之前打开连接并开始会话-故意跳过此代码
IMsgSetRequest msgset=null;
ICreditMemoQuery creditMemoQuery=null;
string sCustomerName=string.Empty;
if(this.GetConnectedToQB())//这是登录到quickbooks桌面的方法调用
{
尝试
{
//在数据获取期间
msgset=m_sessionManager.CreateMsgSetRequest(“US”,8,0);
creditMemoQuery=msgset.AppendCreditMemoQueryRq();
creditMemoQuery.ORTxnQuery.TxnFilter.ORDateRangeFilter.ModifiedDataRangeFilter.FromModifiedDate.SetValue(新日期时间(2012,3,31),false);
IMsgSetResponse msgRes=m_sessionManager.DoRequests(msgset);
IResponseList responseList=msgRes.responseList;
如果(responseList.Count>0)
{
IResponse-response=responseList.GetAt(0);
ICreditMemoRetList CreditMemorList=响应。详细信息为ICreditMemoRetList;
如果(creditMemoList==null)
{
返回;
}
对于(int i=0;i我使用以下函数得到了解:-
public void ApplyCreditsOnPrePayInvoices(string sMonth, string sYear)
{
IMsgSetRequest IMsgSetRequestToQB = null;
ICreditMemoQuery ICreditMemoQueryToQB = null;
string sInvoiceTxnId = string.Empty;
string sInvoiceNumber = string.Empty;
if (this.GetConnectedToQB())
{
try
{
IMsgSetRequestToQB = m_sessionManager.CreateMsgSetRequest("US", 8, 0);
ICreditMemoQueryToQB = IMsgSetRequestToQB.AppendCreditMemoQueryRq();
ICreditMemoQueryToQB.ORTxnQuery.TxnFilter.ORDateRangeFilter.ModifiedDateRangeFilter.FromModifiedDate.SetValue(DateTimecl.GetValue("1." + sMonth + sYear), true);
IMsgSetResponse IMsgSetResponseFromQB = m_sessionManager.DoRequests(IMsgSetRequestToQB);
IResponseList ICreditListMemoAvailable = IMsgSetResponseFromQB.ResponseList;
if (ICreditListMemoAvailable.Count > 0)
{
string sCustomerListIdQB = string.Empty;
string sCustomerAccountNumber = string.Empty;
string sQBImportPrepayAccounts = Path.Combine(Environment.CurrentDirectory, sMonth + sYear, "Step11_QBImport_PrepayAccounts.csv");
DataTable dtQBImportPrepayAccounts = Utilcl.GetDataTableFromCSVFile(sQBImportPrepayAccounts);
IResponse ICreditMemoAvailable = ICreditListMemoAvailable.GetAt(0);
ICreditMemoRetList iCreditMemoList = ICreditMemoAvailable.Detail as ICreditMemoRetList;
if (iCreditMemoList != null)
{
for (int iCtr = 0; iCtr <= iCreditMemoList.Count - 1; iCtr++)
{
ICreditMemoRet ICreditMemo = iCreditMemoList.GetAt(iCtr);
DataRow[] drInvoiceNos = dtQBImportPrepayAccounts.Select("RefNumber = '" + ICreditMemo.RefNumber.GetValue() + "'");
if (drInvoiceNos.Length > 0)
{
sInvoiceNumber = Stringcl.GetValue(drInvoiceNos[0]["RefNumber"]);
m_requestMsgSet.ClearRequests();
m_requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
IReceivePaymentAdd IReceivePayment = m_requestMsgSet.AppendReceivePaymentAddRq();
sInvoiceTxnId = this.GetQBInvoiceTxnIDList(ICreditMemo.CustomerRef.FullName.GetValue()); //To get the Transaction ID of Invoice
IReceivePayment.CustomerRef.FullName.SetValue(Stringcl.GetValue(ICreditMemo.CustomerRef.FullName.GetValue()));
IAppliedToTxnAdd IAppliedToTxnAddress = IReceivePayment.ORApplyPayment.AppliedToTxnAddList.Append();
IAppliedToTxnAddress.TxnID.SetValue(sInvoiceTxnId);
ISetCredit ISetCreditToInvoice = IAppliedToTxnAddress.SetCreditList.Append();
ISetCreditToInvoice.CreditTxnID.SetValue(ICreditMemo.TxnID.GetValue());
ISetCreditToInvoice.AppliedAmount.SetValue(ICreditMemo.TotalAmount.GetValue());
IMsgSetResponse responseApplyCredit = m_sessionManager.DoRequests(m_requestMsgSet);
DataSet dsInvoice = this.GetExtractResponseFromQB(responseApplyCredit);
string sQueryResponse = Stringcl.GetValue(dsInvoice.Tables["ReceivePaymentAddRs"].Rows[0]["statusMessage"]);
if (sQueryResponse != "Status OK")
{
Utilcl.LogMessage("QB Credit Memo Query Response: " + sQueryResponse);
}
}
}
}
}
}
catch (Exception ex)
{
Utilcl.LogMessage(ex);
}
finally
{
if (IMsgSetRequestToQB != null)
{
Marshal.FinalReleaseComObject(IMsgSetRequestToQB);
}
if (ICreditMemoQueryToQB != null)
{
Marshal.FinalReleaseComObject(ICreditMemoQueryToQB);
}
}
}
}
public void applycreditsonpreadvanced发票(字符串sMonth,字符串sYear)
{
IMsgSetRequest IMsgSetRequestToQB=null;
ICREDITMOORQUERY ICREDITMOORQUERYTOQB=null;
string sInvoiceTxnId=string.Empty;
string sInvoiceNumber=string.Empty;
if(this.GetConnectedToQB())
{
尝试
{
IMsgSetRequestToQB=m_sessionManager.CreateMsgSetRequest(“US”,8,0);
ICreditMemoQueryToQB=IMsgSetRequestToQB.AppendCreditMemoQueryRq();
ICreditMemoQueryToQB.ORTxnQuery.TxnFilter.ORDateRangeFilter.ModifiedDataRangeFilter.FromModifiedDate.SetValue(DateTimecl.GetValue(“1.”+sMonth+sYear),true);
IMsgSetResponse IMsgSetResponseFromQB=m_sessionManager.DoRequests(IMsgSetRequestToQB);
IResponseList ICreditListMemoAvailable=IMsgSetResponseFromQB.ResponseList;
如果(ICreditListMemoAvailable.Count>0)
{
string sCustomerListIdQB=string.Empty;
string sCustomerAccountNumber=string.Empty;
字符串sqbimportpreadwardaccounts=Path.Combine(Environment.CurrentDirectory,sMonth+sYear,“Step11_QBImport_preadwardaccounts.csv”);
DataTable DTQBIMPortPreadwardAccounts=Utilcl.GetDataTableFromCSVFile(SQBIMPortPreadwardAccounts);
IResponse ICreditMemoAvailable=ICreditListMemoAvailable.GetAt(0);
ICreditMemoRetList ICREditMemorList=ICREditMemorAvailable。详细信息为ICreditMemoRetList;
如果(iCreditMemoList!=null)
{
(国际卢旺达问题国际法庭=0;国际卢旺达问题国际法庭0)
{
sInvoiceNumber=Stringcl.GetValue(drInvoiceNos[0][“RefNumber”]);
m_requestMsgSet.ClearRequests();
m_requestMsgSet.Attributes.OnError=ENRqOnError.roeContinue;
IReceivePaymentAdd IReceivePayment=m_requestMsgSet.AppendReceivePaymentAddRq();
sInvoiceTxnId=this.GetQBInvoiceTxnIDList(ICreditMemo.CustomerRef.FullName.GetValue());//获取发票的交易ID
IReceivePayment.CustomerRef.FullName.SetValue(Stringcl.GetValue(ICreditMemo.CustomerRef.FullName.GetValue());
IAppliedToTxnAdd IAppliedToTxnAddress=IReceivePayment.ORApplyPayment.AppliedToTxnAddList.Append();
i应用otxnaddress.TxnID.SetValue(sInvoiceTxnId);
ISetCredit ISetCreditToInvoice=iaappliedtotxNaddress.SetCreditList.Append();
ISetCreditToInvoice.CreditTxnID.SetValue(icredItemo.TxnID.GetValue());
ISetCreditToInvoice.AppliedAmount.SetValue(icredItemo.TotalAmount.GetValue());
IMsgSetResponse responseaplycredit=m_sessionManager.DoRequests(m_requestMsgSet);
数据集dsInvoice=this.GetExtractResponseFromQB(responseApplyCredit);
string sQueryResponse=Stringcl.GetValue(dsInvoice.Tables[“ReceivePaymentAddRs”]。行[0][“statusMessage”]);
if(sQueryResponse!=“状态正常”)
{
Utilcl.LogMessage(“QB信用备忘录查询响应:“+sQueryResponse”);
}
}
}
}
}
}
捕获(例外情况除外)
{
使用日志消息(ex);
}
最后
{
if(IMsgSetRequestToQB!=null)
{
封送。最终电子对象(IMsgSetRequestToQB);
}
如果(ICreditMemoQueryToQB!=null)
{
最终选举对象(ICREDITMOORQUERYTOQB);
}
}
}
}
请提供一些您尝试过的代码。您的问题应该是感谢Balagurunathan的回答,我已经在下面发布了用于实现“申请信用”的代码到Quickbooks。你应该编辑你的问题并发布你的代码。请阅读好的问题谢谢你的回答,我在问题部分这样做了,如果可能的话请提供帮助。