谁可以使用C#在QuickBooks中添加和选择JournalEntry

时间:2013-07-19 03:57:20

标签: c# quickbooks

请用简单的代码或示例教我。

如何在QuickBooks中添加/选择JournalEntry

我在这个网站上学习,但我不明白。 https://member.developer.intuit.com/qbSDK-current/Common/newOSR/index.html

非常感谢你。

#In另外。

我正在使用QBFC10Lib

        bool sessionBegun = false;
        bool connectionOpen = false;
        QBSessionManager rp = null;

        rp = new QBSessionManager();
        IMsgSetRequest msr = rp.CreateMsgSetRequest("US", 8, 0);
        msr.Attributes.OnError = ENRqOnError.roeContinue;

        //Connect to QuickBooks and begin a session
        rp.OpenConnection("", "QuickBooks Integration Demo");
        connectionOpen = true;
        rp.BeginSession("", ENOpenMode.omDontCare);
        sessionBegun = true;

        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("Petty Cash");
        jcl.EntityRef.FullName.SetValue("1000");

        IJournalDebitLine jdl = jea.ORJournalLineList.Append().JournalDebitLine;
        jdl.Amount.SetValue(1);
        jdl.AccountRef.FullName.SetValue("Petty Cash");
        jdl.EntityRef.FullName.SetValue("1000");

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

        IJournalEntryRet jet = null;

        msr = rp.CreateMsgSetRequest("US", 8, 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 = rp.DoRequests(msr);
        if (msp.ResponseList.Count > 0)
        {
            IResponseList rl = msp.ResponseList;
            if (rl.Count >= 1)
            {
                IResponse r = rl.GetAt(0);
                if (r.Detail == null)
                    Console.WriteLine("Fail: Detail was null");

                if (r.StatusCode != 0)
                    Console.WriteLine("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)
            Console.WriteLine("Success!");

结果是:

 Error during test

 There is an invalid reference to QuickBooks entity "1000" in the General Journal credit line. QuickBooks error message: Invalid argument. The specified record does not exist in the list.

 Fail: Detail was null
 Fail: Status code was not zero

为什么是null。有些不对劲。

2 个答案:

答案 0 :(得分:0)

现在我可以从quickbooks获取数据并在myApp中显示。

已经工作了。

必须是查询2层。

第一个日期图层。

信用卡,借记图层。

现在 - >我成功了添加/选择

答案 1 :(得分:0)

代码行,你得到错误:

jdl.EntityRef.FullName.SetValue( “1000”);

您应该从客户,供应商,员工的现有名称输入此处的名称......