Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you find the TxnLineID of a payment line from a Quickbooks transaction if it is part of a Sales Receipt?

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

like image 729
Michael Pryor Avatar asked Feb 01 '13 15:02

Michael Pryor


People also ask

What is the difference between payment and sales receipt in QuickBooks?

The main difference is that invoices are issued before a business has received payment from a customer, and a receipt is issued after payment has been collected.

How do I find sales receipts in QuickBooks?

After you sign in to your QuickBooks account, open the plus sign menu and click on Customers. Choose Sales Receipt, and a blank form will pop up.

What is a sales receipt used for in QuickBooks?

What a QuickBooks Sales Receipt Is. Similar to an invoice, a sales receipt provides customers with a detailed description of the products or services that they have purchased. Invoices are issued to request payment from the customer.


1 Answers

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
like image 53
Ashley Ross Avatar answered Oct 14 '22 02:10

Ashley Ross