有一种使用 CustomDetailReportQuery 的 hacky 方法。我想不出一种方法来获取单个交易的报告,因此必须对整个帐户进行报告,然后循环遍历,直到找到正确的 txn 并返回其清除状态:
public bool IsCleared(string sTxnID, string sTxnLineID, string sAccount, out bool bCleared)
{
bCleared = false;
IMsgSetRequest msr = sm.CreateMsgSetRequest("US", 7, 0);
msr.Attributes.OnError = ENRqOnError.roeStop;
IJournalEntryQuery cq = msr.AppendJournalEntryQueryRq();
cq.metaData.SetValue(ENmetaData.mdMetaDataAndResponseData);
cq.ORTxnQuery.TxnIDList.Add(sTxnID);
cq.IncludeLineItems.SetValue(true);
IMsgSetResponse resp = sm.DoRequests(msr);
try
{
IJournalEntryRetList crl = (IJournalEntryRetList)resp.ResponseList.GetAt(0).Detail;
IJournalEntryRet r = crl.GetAt(0);
msr.ClearRequests();
ICustomDetailReportQuery rq = msr.AppendCustomDetailReportQueryRq();
rq.CustomDetailReportType.SetValue(ENCustomDetailReportType.cdrtCustomTxnDetail);
rq.IncludeColumnList.Add(ENIncludeColumn.icClearedStatus);
rq.IncludeColumnList.Add(ENIncludeColumn.icTxnID);
// Is Cleared status per txn or per txn line?
rq.ReportAccountFilter.ORReportAccountFilter.FullNameList.Add(sAccount);
rq.ORReportPeriod.ReportPeriod.FromReportDate.SetValue(r.TxnDate.GetValue());
rq.ORReportPeriod.ReportPeriod.ToReportDate.SetValue(r.TxnDate.GetValue());
rq.SummarizeRowsBy.SetValue(ENSummarizeRowsBy.srbItemDetail);
resp = sm.DoRequests(msr);
IReportRet rp = (IReportRet)resp.ResponseList.GetAt(0).Detail;
IORReportData data = null;
for (int i = 0; i < rp.ReportData.ORReportDataList.Count; i++)
{
data = rp.ReportData.ORReportDataList.GetAt(i);
if (data.DataRow != null)
{
if (data.DataRow.ColDataList.Count > 1)
{
if (data.DataRow.ColDataList.GetAt(1).value.GetValue() == sTxnID)
{
bCleared = (data.DataRow.ColDataList.GetAt(0).value.GetValue() == "Cleared");
return true;
}
}
}
}
}
catch (Exception e)
{
Log("Error looking up cleared status: " + e.Message);
}
return false;
}