Limits

Overview

Limits are a way to select only some part of transactions. For example they can be used to show only transactions from the current month. Please note, that only transactions that fall into the limit influence accounts. That means you can analyse your expenses in the current month by applying an appropriate limit and looking at Expenses account and its subaccounts.

Limits are, technically speaking, python expressions consisting of functions Emma provides. This general approach let's you define almost any limit you can imagine (like "please show me transfers from my checking account on Saturdays of the last five Decembers" ;-) Additionally you can create your own functions to provide a simple interface to more complex tasks.

Don't worry if you are not a programmer. You can use Emma without any programming knowledge. Just try out the examples from the next section and see yourself.

Learn by example

I think learn by example approach is the best way to learn limits. To try out the examples below, just put the limit of your choice into the Limit entry at the top of the main window and click Apply limit toolbar button, choose Limit->Apply from the menu or just press Enter while in Limit entry.

Figure 3-6. Applying a limit

Let's begin with some really simple examples.

Example 3-1. Simple limits

emma.year() == 2000

Only transactions from last year of century.

emma.amount() >= 100.00

Only transactions transfering at least $100.

emma.acc_from() == "Cash"

Only transactions draining your wallet.

Please note the double equal sign in the comparissions. It is a common mistake to put just one, which is wrong.

Now we'll introduce how to connect two expressions together. You can do it with the following keywords: and or.

Example 3-2. Connecting two expressions

(emma.year() == 2000) and (emma.acc_to() == "Cinema"

Only transactions spending money on cinema in the year 2000.

(emma.acc_from == "Checking account") or (emma.acc_to == "Checking account")

Only transactions doing something (both debiting and crediting) with your checking account.

(emma.year() == 2001) and (emma.month() == 5)

Only transactions in the May 2000

((emma.acc_from == "Cash") or (emma.acc_to == "Cash")) and (emma.day() <= 15)

Only transactions doing something with your Cash account which happened in the first half of every month.

Note the parethnesses around single expressions.

Now let's try out the lists. To group items into a list you surround them with a square brackets. Note that in operator takes care of checking whether an object belongs to a list. Look at the examples below.

Example 3-3. Limits using lists

emma.month() in [6,7,8]

Only transactions from Summer months.

emma.acc_to() in ["Food", "Bills"]

Only transactions crediting Food or Bills accounts.

Functions

This section contains reference to functions you can use in limit expressions.

Built-in functions.

emma.amount()

Returns the amount of money a transaction transfers.

emma.acc_from()

Returns the name of the account a transaction debits.

emma.acc_to()

Returns the name of the account a transaction credits.

emma.date()

Returns the date of a transaction in seconds since epoch (typically Jan 1, 1970)

emma.year()

Returns the year of a transaction.

emma.month()

Returns the month of a transaction.

emma.day()

Returns the day of a month of a transaction.

emma.weekday()

Returns the day of a week of a transaction. (1 for Monday, 7 for Sunday)

emma.desc()

Returns the description of a transaction.

emma.parents(acc_name)

Returns a list of the given account parents. (eg. emma.parents("Gas") could return ["Gas", "Bills", "Expenses"] ).

emma.date_val(date_string)

Returns seconds since epoch for the given date string. Example usage: emma.date() >= emma.date_val("05/05/2000") (only transactions after May the 5th, 2000).

emma.register_func(name, desc)

This function registers a functions. It just puts a name parameter together with desc in the limit dialog.

Warning

Please use this one only in scripts, read at startup. This function is not meant for use in limit expressions.

Standard extension.

Day()

It is just a wrapper around the emma.day() function.

Weekday()

It is just a wrapper around the emma.weekday() function.

Month()

It is just a wrapper around the emma.month() function.

Year()

It is just a wrapper around the emma.year() function.

CurDay()

Returns True if a transaction happened today.

CurWeek()

Returns True if a transaction happened in the current week.

CurMonth()

Returns True if a transaction happened in the current month.

CurYear()

Returns True if a transaction happened in the current year.

After(date_string)

Returns True if a transaction happened after the given date.

Before(date_string)

Returns True if a transaction happened before the given date.

AccFrom(acc_name)

Returns True if a transaction directly debits the given account.

AccFromSubOf(acc_name)

Returns True if a transaction debits the given account or one of its subaccounts (or its subaccounts subaccounts ;-) etc.)

AccFromIn(acc_list)

Returns True if a transaction directly debits one of the accounts from the given list. Example: AccFromIn(["Cash", "Checking account"])

AccTo(acc_name)

Returns True if a transaction directly credits the given account.

AccToSubOf(acc_name)

Returns True if a transaction credits the given account or one of its subaccounts

AccToIn(acc_list)

Returns True if a transaction directly credits one of the accounts from the given list.

Amount()

Just a wrapper around emma.amount()

DescMatch(regexp)

Returns True if a transaction's description contains regular expression regexp.

Datetime extension. FIXME.