2013-03-12 82 views
0

我將其歸結爲一個總是使用QB Enterprise失敗的簡單示例。 (奇怪的是,我可以發誓,以前工作的代碼。)爲什麼我在Quickbooks SDK中找不到使用RefNumber的journalentries?

  1. 創建一個特定的業務參考號「PTD1234」通過SDK日記帳分錄
  2. 搜索在同一個代碼塊特定日記帳分錄
  3. 觀察,沒有發現結果?

但是,如果我更改了在QB中手動創建相同日記帳分錄的過程,那麼以下搜索代碼正常工作並找到日記帳分錄。

 Quickbooks qb = new Quickbooks(); 
     qb.Connect(this); 

     IMsgSetRequest msr = qb.sm.CreateMsgSetRequest("US", 7, 0); 
     msr.Attributes.OnError = ENRqOnError.roeStop; 

     IJournalEntryAdd jea = msr.AppendJournalEntryAddRq(); 

     jea.TxnDate.SetValue(new DateTime(2013, 3, 1)); 
     jea.RefNumber.SetValue("PTD1234"); 

     IJournalCreditLine jcl = jea.ORJournalLineList.Append().JournalCreditLine; 
     jcl.Amount.SetValue(1); 
     jcl.AccountRef.FullName.SetValue("Credit Card Batches:Paymentech"); 
     jcl.EntityRef.FullName.SetValue("CHASE PAYMENTECH"); 

     IJournalDebitLine jdl = jea.ORJournalLineList.Append().JournalDebitLine; 
     jdl.Amount.SetValue(1); 
     jdl.AccountRef.FullName.SetValue("Chase Deposits EUR"); 
     jdl.EntityRef.FullName.SetValue("CHASE PAYMENTECH"); 

     IMsgSetResponse msp = qb.sm.DoRequests(msr); 
     IResponse resp = msp.ResponseList.GetAt(0); 
     if (resp.StatusCode != 0) 
     { 
      Log("-------------\r\nError during test"); 
      Log(resp.StatusMessage); 
     } 

     IJournalEntryRet jet = null; 

     msr = qb.sm.CreateMsgSetRequest("US", 7, 0); 
     msr.Attributes.OnError = ENRqOnError.roeStop; 

     IJournalEntryQuery q = msr.AppendJournalEntryQueryRq(); 
     q.metaData.SetValue(ENmetaData.mdNoMetaData); 
     q.ORTxnQuery.TxnFilter.ORRefNumberFilter.RefNumberFilter.RefNumber.SetValue("PTD1234"); 
     q.ORTxnQuery.TxnFilter.ORRefNumberFilter.RefNumberFilter.MatchCriterion.SetValue(ENMatchCriterion.mcContains); 
     q.ORTxnQuery.TxnFilter.AccountFilter.ORAccountFilter.FullNameList.Add("Chase Deposits EUR"); 
     q.IncludeLineItems.SetValue(false); 

     msp = qb.sm.DoRequests(msr); 
     if (msp.ResponseList.Count > 0) 
     { 
      IResponseList rl = msp.ResponseList; 
      if (rl.Count >= 1) 
      { 
       IResponse r = rl.GetAt(0); 
       if (r.Detail == null) 
        Log("Fail: Detail was null"); 

       if (r.StatusCode != 0) 
        Log("Fail: Status code was not zero"); 

       if (r.Type.GetValue() == (short)ENResponseType.rtJournalEntryQueryRs) 
       { 
        IJournalEntryRetList crl = (IJournalEntryRetList)r.Detail; 
        if (crl != null && crl.Count == 1) 
         jet = crl.GetAt(0); 
       } 
      } 
     } 

     if (jet != null) 
      Log("Success!"); 

     qb.Cleanup(); 
+0

@keith我想。唯一的問題是,如果Intuit沒有使用IPP標籤進行標記,Intuit就不會看它... – 2013-03-13 01:21:59

+0

如果您想要,可以重新標記,但發佈有關非IPP問題的更好的地方是他們的論壇:https: //idnforums.intuit.com/ – 2013-03-13 02:03:02

+0

@KeithPalmer不,你的編輯是正確的。我真的不明白他們在做什麼,他們的支持。 – 2013-03-13 02:29:53

回答

0

不知什麼原因,有些journalentries不會出現使用JournalEntryQuery和TxnFilter.ORRefNumberFilter.RefNumberFilter。但是,解決方法是使用ORTxnQuery.RefNumberList,然後循環查看日記行並確保帳戶匹配。

public bool GetExactJournalTransaction(string sRefNum, string sAccount, out IJournalEntryRet jet) 
    { 
     jet = null; 

     IMsgSetRequest msr = sm.CreateMsgSetRequest("US", 4, 0); 
     msr.Attributes.OnError = ENRqOnError.roeStop; 

     IJournalEntryQuery q = msr.AppendJournalEntryQueryRq(); 
     q.metaData.SetValue(ENmetaData.mdNoMetaData); 
     q.ORTxnQuery.RefNumberList.Add(sRefNum); 
     q.IncludeLineItems.SetValue(true); 


     IMsgSetResponse resp = sm.DoRequests(msr); 
     if (resp.ResponseList.Count == 0) 
      return false; 

     IResponseList rl = resp.ResponseList; 
     if (rl.Count == 1) 
     { 
      IResponse r = rl.GetAt(0); 
      if (r.Detail == null) 
       return false; 

      if (r.StatusCode != 0) 
       return false; 

      if (r.Type.GetValue() == (short)ENResponseType.rtJournalEntryQueryRs) 
      { 
       IJournalEntryRetList crl = (IJournalEntryRetList)r.Detail; 
       if (crl != null) 
       { 
        for (int i = 0; i < crl.Count; i++) 
        { 
         jet = crl.GetAt(i); 
         for (int j = 0; j < jet.ORJournalLineList.Count; j++) 
         { 
          IORJournalLine l = jet.ORJournalLineList.GetAt(j); 
          if (l.JournalCreditLine != null && l.JournalCreditLine.AccountRef.FullName.GetValue() == sAccount) 
           return true; 
          else if (l.JournalDebitLine != null && l.JournalDebitLine.AccountRef.FullName.GetValue() == sAccount) 
           return true; 
         } 
        } 
       } 
      } 
     } 
     return false; 
    } 
相關問題