Search code examples
quickbooksintuit-partner-platformquickbooks-online

Finding which invoice(s) are paid by a credit memo


So I have an invoice and a credit memo, and the two are linked via a payment as per these instructions. All is good, the invoice is showing as paid and the customer's balance is correct.

If I open up the credit memo (Adjustment Note) in the GUI I am able to see at a glance the related payment at the right side of the screen:

related payment

Now, I am trying to read back this information from the QBO IPP API (v3). Querying for the adjustment note I get the following response. As you can see, there is nothing there to tell me about this linked payment:

  <CreditMemo domain="QBO" sparse="false">
    <Id>1239</Id>
    <SyncToken>1</SyncToken>
    <MetaData>
      <CreateTime>2015-01-15T09:17:07-08:00</CreateTime>
      <LastUpdatedTime>2015-01-15T09:17:09-08:00</LastUpdatedTime>
    </MetaData>
    <DocNumber>4109</DocNumber>
    <TxnDate>2014-12-02</TxnDate>
    <CurrencyRef name="Australian Dollar">AUD</CurrencyRef>
    <PrivateNote>Cancelled</PrivateNote>
    <Line>
      <Id>1</Id>
      <LineNum>1</LineNum>
      <Amount>318.18</Amount>
      <DetailType>SalesItemLineDetail</DetailType>
      <SalesItemLineDetail>
        <ItemRef name="IPP">10</ItemRef>
        <TaxCodeRef>10</TaxCodeRef>
      </SalesItemLineDetail>
    </Line>
    <Line>
      <Amount>318.18</Amount>
      <DetailType>SubTotalLineDetail</DetailType>
      <SubTotalLineDetail />
    </Line>
    <TxnTaxDetail>
      <TotalTax>31.82</TotalTax>
      <TaxLine>
        <Amount>31.82</Amount>
        <DetailType>TaxLineDetail</DetailType>
        <TaxLineDetail>
          <TaxRateRef>20</TaxRateRef>
          <PercentBased>true</PercentBased>
          <TaxPercent>10</TaxPercent>
          <NetAmountTaxable>318.18</NetAmountTaxable>
        </TaxLineDetail>
      </TaxLine>
    </TxnTaxDetail>
    <CustomerRef name="xxxxxx">99</CustomerRef>
    <GlobalTaxCalculation>TaxInclusive</GlobalTaxCalculation>
    <TotalAmt>350.00</TotalAmt>
    <PrintStatus>NeedToPrint</PrintStatus>
    <EmailStatus>NotSet</EmailStatus>
    <Balance>0</Balance>
    <RemainingCredit>0</RemainingCredit>
  </CreditMemo>

If I read the payment I can learn about this adjustment note and the invoice from Line.LinkedTxn:

<Line>
  <Amount>350.00</Amount>
  <LinkedTxn>
    <TxnId>1190</TxnId>
    <TxnType>Invoice</TxnType>
  </LinkedTxn>
  <LineEx>
    <NameValue>
      <Name>txnId</Name>
      <Value>1190</Value>
    </NameValue>
    <NameValue>
      <Name>txnOpenBalance</Name>
      <Value>350.00</Value>
    </NameValue>
    <NameValue>
      <Name>txnReferenceNumber</Name>
      <Value>4069</Value>
    </NameValue>
  </LineEx>
</Line>
<Line>
  <Amount>350.00</Amount>
  <LinkedTxn>
    <TxnId>1239</TxnId>
    <TxnType>CreditMemo</TxnType>
  </LinkedTxn>
  <LineEx>
    <NameValue>
      <Name>txnId</Name>
      <Value>1239</Value>
    </NameValue>
    <NameValue>
      <Name>txnOpenBalance</Name>
      <Value>350.00</Value>
    </NameValue>
    <NameValue>
      <Name>txnReferenceNumber</Name>
      <Value>4109</Value>
    </NameValue>
  </LineEx>
</Line>

If I read the invoice I can learn about the payment from LinkedTxn:

<LinkedTxn>
  <TxnId>1240</TxnId>
  <TxnType>Payment</TxnType>
</LinkedTxn>

But I need to find the payment given the adjustment note. As far as I can tell from the documentation, there is no way to query payments for their lines' contents. So, how do I find this payment given the credit memo, so I can learn what it is paying?


Solution

  • Credit Memo, Invoice and Payment all apply to same CustomerRef. Credit memo does not support the linked txn details yet, so as a workaround, you can try this- Get the Payment/s which have same customerref as creditmemo's customeref. Then loop through the payment/s to read the linked txn ids and match it against the credit memo id you have.

    Not a great solution but since your use is not supported by the V3 api right now, you can try the above.