15

I can query for the SalesReceipt object:

    public bool GetSalesReceipt(string sRefNum, string sAccount, out ISalesReceiptRet ret)
    {
        ret = null;

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

        ISalesReceiptQuery q = msr.AppendSalesReceiptQueryRq();
        q.metaData.SetValue(ENmetaData.mdMetaDataAndResponseData);
        q.ORTxnQuery.TxnFilter.ORRefNumberFilter.RefNumberFilter.RefNumber.SetValue(sRefNum);
        q.ORTxnQuery.TxnFilter.ORRefNumberFilter.RefNumberFilter.MatchCriterion.SetValue(ENMatchCriterion.mcContains);
        q.ORTxnQuery.TxnFilter.AccountFilter.ORAccountFilter.FullNameList.Add(sAccount);
        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.rtSalesReceiptQueryRs)
            {
                ISalesReceiptRetList crl = (ISalesReceiptRetList)r.Detail;
                if (crl.Count == 1)
                    ret = crl.GetAt(0);
            }
        }

        if (ret == null)
            return false;

        return true;
    }

The SalesReceipt has a list of SalesReceipt Lines in ORSalesReceiptLineRetList, but none of those lines are the payment line. There is no way to get the TxnLineID from the SalesReceipt object for the payment line (that I can find).

What I'm trying to do is find a particular TxnLineID from the SalesReceipt, so that I can mark it as cleared. When I do a search, I can see there is a transaction line (the one below in the Credit Card Batches:Visa/MC account). How can I find the TxnLineID For that particular line?

qb transaction

Here is a screenshot showing the transaction marked as cleared which I accomplished through the UI by clicking the box in the Cleared column.

enter image description here

Michael Pryor
  • 25,046
  • 18
  • 72
  • 90

3 Answers3

1

From the research I am seeing, this maybe an answer for you:

https://idnforums.intuit.com/messageview.aspx?catid=7&threadid=12760&highlight_key=y&keyword1=TxnLineID

"Resurrected some older code that invoked the SDK with an older version reference ("US",1,1) while I should have been using ("US",7,0)."

or

https://idnforums.intuit.com/messageview.aspx?catid=7&threadid=10776

At least they may be able to assist you further in your problem.

Hope it helps.

Rusty Nail
  • 2,692
  • 3
  • 34
  • 55
1

Journal Entries and Sales Receipts are two entirely different object types in QuickBooks.

So this:

Unfortunately, if the transaction I'm querying for is part of a SalesReceipt,

In conjunction with the code you posted (which is entirely about Journal Entries) makes no sense at all.

If you're looking for Sales Receipts, you need to query for Sales Receipts. If you're looking for Journal Entries, then you need to query for Journal Entries. You can't query for one, and expect to get the other back.

Keith Palmer Jr.
  • 27,666
  • 16
  • 68
  • 105
  • I added some info to the bottom of my question to address your concerns. I understand that a salesreceipt is not a journalentry. I just have no idea how to find the TxnLineID for the Transaction Line from the SalesReceipt. – Michael Pryor Feb 12 '13 at 01:26
  • If you're trying to find a TxnLineID for a sales receipt, then why are you querying for journal entries in your code then...? Why don't you update your code so that you're querying for the sales receipt? – Keith Palmer Jr. Feb 12 '13 at 12:13
  • updated code snippet to show alternate code I've tried. Still can't find the txnlineid for the payment associated with the salesreceipt. – Michael Pryor Feb 12 '13 at 18:47
1

To my understanding, a Sales Receipt does not have a separate payment line. With an Invoice you receive a Payment with lines at some later point in time, but with a Sales Receipt the payment has already taken place, so that information is captured as part of the Sales Receipt itself. The payment line that you see in the screenshot is then generated from the information stored on the Sales Receipt.

This would also explain why Sales Receipts only allow a single payment method and why split payments are not possible - the full amount of the Sales Receipt is regarded as having been received, so only information about the payment method itself is stored.

Take a look at the PaymentMethodRef, CheckNumber, DepositToAccountRef and CreditCardTxnInfo properties of the returned ISalesReceiptRet; the closest linkable documentation I could find is for adding a Sales Receipt, but that should be sufficient for listing the available properties (Their OSR tool is prettier, but provides no way to link to a particular set of results).

You may also find it helpful to examine Interop.QBFC5Lib.dll in Reflector (Or your preferred equivalent). For me, it was often faster than trying to consult the official documentation.


I'm not sure what you mean when you say you want to use the TxnLineID to mark the payment line as cleared. If you mean that the Sales Receipt is showing an open balance, then it seems that this is a known issue.

Alternatively, if you want to confirm the status of the credit card transaction, you can look at the ResultCode and ResultMessage properties on ISalesReceiptRet.CreditCardTxnInfo.CreditCardTxnResultInfo.

Keep in mind that there are some restrictions around modifying a Sales Receipt that has a credit card payment. From the Programmer's Guide:

If the payment method used in the original SalesReceipt is a credit card, with the credit card transaction data provided by QBMS via the qbmsXML requests and responses, you cannot change the customer, payment method, or the total transaction amount, including any line item changes that would change the total amount of the transaction.


Update: In my testing, it appears that you don't need a TxnLineID when clearing a Sales Receipt. Continuing on from your code, once you've populated ret, the following should do what you want:

msr.ClearRequests();

IClearedStatusMod csm = msr.AppendClearedStatusModRq();
csm.TxnID.SetValue(ret.TxnID.GetValue());
// Leave TxnLineID null
csm.ClearedStatus.SetValue(ENClearedStatus.csCleared);

resp = sm.DoRequests(msr);
// Confirm status here
Ashley Ross
  • 2,345
  • 2
  • 23
  • 43
  • I uploaded a screenshot to the end of my question showing the transaction I'm talking about "marked as cleared" through the UI. I'm trying to do this through the SDK and I can for any txn that I have the txnLineID for. Problem is finding that for the payment of a SalesReceipt. – Michael Pryor Feb 20 '13 at 21:55
  • That last screenshot is of the account referenced by `ISalesReceiptRet.DepositToAccountRef`, correct? Does the `ISalesReceiptRet.CreditCardTxnInfo.CreditCardTxnResultInfo.PaymentStatus` property have any correlation to the check? – Ashley Ross Feb 21 '13 at 08:54
  • Yes, the last screenshot is the account referenced by ISalesReceipt.DepositToAccountRef. In my case the salesreceipt was also entered programmatically, so CreditCardTxnInfo is actually NULL. – Michael Pryor Feb 21 '13 at 17:11
  • As the credit card payment is not present at the time the Sales Receipt is created, how is it being brought into the system? Through QBMS? – Ashley Ross Feb 21 '13 at 18:39
  • Via the SDK and a AppendSalesReceiptAddRq call. The DepositToAccountRef was set. – Michael Pryor Feb 21 '13 at 18:56
  • Great! This is hopefully my first and last foray into QuickBooks. ;) – Ashley Ross Feb 22 '13 at 21:06