Catching and Discarding Transactions

In this example you will take a sample input file, run it through QifCon to remove specific transactions.

This is handy for Grisbi where you have transactions in two accounts and the transaction is a transfer from one account to another. There will be a matching transaction record in each account QIF file (one positive amount and one negative amount). Grisbi is meant to record such transactions as a transfer but Bug 232 indicates that this does not work as expected.

To work around this problem, one of these transactions is removed as part of the transformation so that the remaining transaction can be correctly modified to be a "transfer", which automatically creates the correct transaction record in the transferred account.

You can also combine this with splitting into months .

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0">
  <xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes" />

  <!-- Discard the specified transaction records -->
  <xsl:template match="transactionRecord">
    <xsl:choose>
      <!-- Work around for Bug 232 -->
      <xsl:when
        test="starts-with(child::payee/text(),'Transfer from  02336700')">
        <!-- Ignore these as the will be created in Grisbi when the transfer is setup manually -->
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy>
          <xsl:apply-templates />
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <!-- Copy Unmatched Attributes and Nodes As Is -->
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()" />
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

Running

qifcon --input examples/discard_transaction/discard_transaction.qif --output output.qif examples/discard_transaction/discard_transaction.xsl quicken.xsl

Now open the output.qif file in your favourite editor. Compare it to the input file discard_transaction.qif . You should notice that the transaction with payee "Transfer from 12345678" has been removed from the output.