|
[QODBC-Desktop] How to Create a Credit Memo from an Existing Invoice Using QODBC INSERT
Posted by William - QODBC Support on 12 October 2026 12:54 PM
|
|||||||||
[QODBC-Desktop] How to Create a Credit Memo from an Existing Invoice Using QODBC INSERTProblem Description:When using QODBC to write data back to QuickBooks Desktop, you may need to create a Credit Memo based on an existing Invoice. Directly inserting into the Affected products: QODBC Desktop, QuickBooks Desktop Symptoms:
Cause:In QuickBooks Desktop, when you create a credit memo from an existing invoice using the QuickBooks UI, it automatically links the credit memo to the source invoice and applies the credit. When writing via QODBC, this linkage must be established explicitly by inserting data into the The key parameters required are:
Environment:
Solution:Step 1: Retrieve and Verify the Source InvoiceFirst, query the invoice you want to create a credit memo from to confirm its details and obtain the necessary ListIDs. Step 2: Insert Credit Memo Lines Using SELECT from InvoiceLineUse an Step 3: Apply Payment / Credit to the InvoiceAfter creating the credit memo, insert it into SQL Examples:Example 1: Verify the Source InvoiceSELECT * FROM Invoice WHERE RefNumber = '011' Example 2: Verify the Created Credit MemoSELECT * FROM CreditMemo WHERE RefNumber = '012' Example 3: Create Credit Memo - First Line Item (FQSaveToCache = 1)This inserts the first line of the credit memo and establishes the link to the source invoice. Replace the INSERT INTO "CreditMemoLine" ( "CustomerRefListID", "ARAccountRefListID", "TxnDate", "RefNumber", "CreditMemoLineItemRefListID", "CreditMemoLineDesc", "CreditMemoLineRate", "FQSaveToCache" ) SELECT CustomerRefListID, ARAccountRefListID, TxnDate, RefNumber, InvoiceLineItemRefListID, InvoiceLineDesc, InvoiceLineRate, 1 FROM InvoiceLine WHERE InvoiceLineTxnLineID = 'CE16-1892033022' Example 4: Create Credit Memo - Second Line Item (FQSaveToCache = 0)This adds a second line to the same credit memo. The INSERT INTO "CreditMemoLine" ( "CustomerRefListID", "ARAccountRefListID", "TxnDate", "RefNumber", "CreditMemoLineItemRefListID", "CreditMemoLineDesc", "CreditMemoLineRate", "FQSaveToCache" ) SELECT CustomerRefListID, ARAccountRefListID, TxnDate, RefNumber, InvoiceLineItemRefListID, InvoiceLineDesc, InvoiceLineRate, 0 FROM InvoiceLine WHERE InvoiceLineTxnLineID = 'CE17-1892033022' Example 5: Apply Credit Memo Payment to Source InvoiceAfter the credit memo is created, apply it to the source invoice using INSERT INTO ReceivePaymentLine ( CustomerRefListID, ARAccountRefListID, AppliedToTxnTxnID, AppliedToTxnPaymentAmount, AppliedToTxnSetCreditCreditTxnID, AppliedToTxnSetCreditAppliedAmount ) VALUES ( '8000008F-1892011138', '50001-896816252', 'CE14-1892033022', -- Source Invoice TxnID 435, -- Payment amount 'CE38-1892034028', -- Credit Memo TxnID 435 -- Applied credit amount ) Example Scenarios:Scenario 1 - Full refund from a single-line invoice: A customer returned an item billed on invoice #005 (single line). The user queried the InvoiceLine table to get the first line's TxnLineID, then executed the INSERT statement with Scenario 2 - Partial refund from a multi-line invoice: A customer returned only one of three items billed on invoice #011. The user executed two INSERT statements: the first with Additional Notes:
Related Articles:How to Create Credit Memos via QODBC (KB Article 2068) How to Receive a Payment in QODBC (KB Article 359) Understanding CreditMemoLine Tables Understanding InvoiceLine TableUsing FQSaveToCache Parameter in QODBC INSERT Statements Keywords:Credit Memo Invoice INSERT INTO CreditMemoLine ReceivePaymentLine FQSaveToCache InvoiceLinkedTxn Refund/Credit Apply Payment Partial Refund Customer Credit QuickBooks Desktop InvoiceLineTxnLineID Write Back Credit Memo Linking
| |||||||||
|
|
|||||||||


