Tracking contributions to an account

470 views
Skip to first unread message

Nathan Grigg

unread,
Jul 20, 2014, 11:19:11 PM7/20/14
to ledge...@googlegroups.com
I’ve been thinking about how to track transfers into a certain account, for example, a Health Savings Account or 401k.

For example:

2014-06-01 Transfer
Assets:Health Savings $500
Assets:Checking

2014-06-10 Doctor
Expenses:Health $200
Assets:Health Savings

2014-07-01 Interest
Assets:Health Savings $0.25
Income:Interest

For tax purposes, I care about the total amount transferred in ($500 in this case).

Solution 1: Tags.
2014-06-01 Transfer
Assets:Health Savings $500
; Taxes: HSA Contribution
Assets:Checking

Now leger bal "Assets:Health Savings” and “%Taxes=HSA Contribution” gives me $500. The downside is that tags can be difficult to work with. (For example, can you match a tag value by regex? Not that I can see)

Solution 2: extra accounts. I’ve put them under Expenses, because that seems most apt, but still a little weird.

2014-06-01 Transfer
Expenses:HSA:Contribution $500
Expenses:HSA:Transfer -$500
Assets:Health Savings $500
Assets:Checking

Now leger bal “Expenses:HSA:Contribution" gives me $500. The downside is that this is more verbose. You also have a more or less meaningless account in Expenses:HSA:Transfer. You can use automated transactions to clean up data entry, but it still may not be worth it. Also, I’m soured on automatic transactions since rediscovering bug 983 http://bugs.ledger-cli.org/show_bug.cgi?id=983.

Does anyone else try to solve this problem? Is there a solution I’m overlooking?

Nathan
signature.asc

Michael Norrish

unread,
Jul 20, 2014, 11:31:56 PM7/20/14
to ledge...@googlegroups.com
How about

ledger {reg|bal} assets:health.savings and payee transfer

?

Of course, you need to be consistent about what you're doing in the payee field.

Michael

Erik Hetzner

unread,
Jul 20, 2014, 11:59:48 PM7/20/14
to ledge...@googlegroups.com, Nathan Grigg
At Sun, 20 Jul 2014 20:19:07 -0700,
Nathan Grigg wrote:
>
> I’ve been thinking about how to track transfers into a certain
> account, for example, a Health Savings Account or 401k.
>
> […]

Hi Nathan,

I use “transfer” accounts to keep track of transferring money. [1]
Maybe you can try this:

2014-06-01 Transfer
Transfer:A:Checking->A:Health Savings
Assets:Checking -$500

2014-06-01 Transfer
Transfer:A:Checking->A:Health Savings
Assets:Health Savings $500

2014-06-10 Doctor
Expenses:Health $200
Assets:Health Savings

2014-07-01 Interest
Assets:Health Savings $0.25
Income:Interest

2014-08-01 Transfer
Transfer:A:Savings->A:Health Savings
Assets:Savings -$100

2014-08-01 Transfer
Transfer:A:Savings->A:Health Savings
Assets:Health Savings $100

This report (if I understand it correctly) will report transfers to
the health savings account:

$ ledger -f x.lgr -s -r --display "account=~/^Assets:Health/" bal ^Transfer
$600.00 Assets:Health Savings

best, Erik

1. I find transfer accounts useful because my banks tend to report
each “side” of a transfer, e.g. when I pay a credit card my bank
account has a transaction and my credit card has a transaction. Rather
than delete one of these, I keep both with an intermediary transfer
account. Additionally, they allow reports like this one with needing a
particular payee or metadata.

--
Sent from my free software system <http://fsf.org/>.

Martin Blais

unread,
Jul 21, 2014, 1:18:54 AM7/21/14
to ledger-cli
Michael: this is a clever solution, I had never thought of it.
Mostly because I don't have good filtering capabilities yet.

Nathan: I solved this problem by using a second currency to track the transfers, with an associated Income, Asset and Expense accounts in that currency. This requires no special filtering, only a bit of discipline to replicate existing postings (which can be automated). I'm assuming these HSA accounts are similar to tracking 401k and IRA contributions, which have limits and for which you may have to declare an amount for taxes.

I briefly allude to this in this new section of the cookbook I wrote today (look for US401K):

I'll be adding a section about 401K's very soon - meant to do it today actually - which describe this "mirrorring" solution in more detail, but if you look on the list you will find some emails where I discuss the solution, look for IRA or 401K or RSP.

Cheers,



--

---
You received this message because you are subscribed to the Google Groups "Ledger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ledger-cli+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Martin Michlmayr

unread,
Jul 21, 2014, 1:46:03 AM7/21/14
to ledge...@googlegroups.com
* Nathan Grigg <nat...@nathangrigg.net> [2014-07-20 20:19]:
> Now leger bal "Assets:Health Savings” and “%Taxes=HSA Contribution” gives me $500. The downside is that tags can be difficult to work with. (For example, can you match a tag value by regex? Not that I can see)

Yes, you can match tags:
ledger -f d reg "tag("Taxes") =~ /^HSA*/'"

> Does anyone else try to solve this problem? Is there a solution I’m overlooking?

If you always transfer from Assets:Checking, you can do:

ledger -f d reg 'Assets:Health Savings' and expr 'any(account =~ /Assets:Checking/)'

--
Martin Michlmayr
http://www.cyrius.com/

Martin Blais

unread,
Jul 21, 2014, 2:17:05 AM7/21/14
to ledger-cli
On Mon, Jul 21, 2014 at 1:18 AM, Martin Blais <bl...@furius.ca> wrote:
Michael: this is a clever solution, I had never thought of it.
Mostly because I don't have good filtering capabilities yet.

Sorry I wasn't clear: I meant that Beancount could not handle this at the moment, because it requires the ability to filter by payee (I did not mean that I didn't think of it because of that, which is irrelevant). 

Instead of using the payee, if it is possible to identify the set of transfer transactions with "those that involve postings in accounts X and Y" where X is an account external to the account Y whose transfers we're interested in, and filter down to just those, one wouldn't need to rely on a payee string.

Craig Earls

unread,
Jul 21, 2014, 9:11:20 AM7/21/14
to ledge...@googlegroups.com
I use something like this:

ledger bal 401k --period "$period" --limit "commodity=='\$' and amount<=0"

The amount<=0 clause makes sure it only tracks amount coming into the
account. You don't need to worry about consistency of entry that way.
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "Ledger" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ledger-cli+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Craig, Corona De Tucson, AZ
enderw88.wordpress.com

Martin Blais

unread,
Jul 21, 2014, 9:35:01 AM7/21/14
to ledger-cli
On Mon, Jul 21, 2014 at 1:18 AM, Martin Blais <bl...@furius.ca> wrote:
Michael: this is a clever solution, I had never thought of it.
Mostly because I don't have good filtering capabilities yet.

Nathan: I solved this problem by using a second currency to track the transfers, with an associated Income, Asset and Expense accounts in that currency. This requires no special filtering, only a bit of discipline to replicate existing postings (which can be automated). I'm assuming these HSA accounts are similar to tracking 401k and IRA contributions, which have limits and for which you may have to declare an amount for taxes.

I briefly allude to this in this new section of the cookbook I wrote today (look for US401K):

I'll be adding a section about 401K's very soon - meant to do it today actually - which describe this "mirrorring" solution in more detail, but if you look on the list you will find some emails where I discuss the solution, look for IRA or 401K or RSP.

I read up a little bit on HSAs out of curiosity. As far as I can tell, it looks like it behaves like an IRA where there's no withdrawal penalty when you take money out to pay for medical expenses. (Is this right?)

If so, I would use
- an Income account to track how many contributions I've been offered over time (by the govt)
- an Assets account to hold remaining potential contributions for this year
- an Expenses account to count how many contributions I've made so far in the year

These accounts would use units of "HSAUSD".



; Solution for HSA problem for Nathan Grigg


; Potential contribution you receive from the Govt
2012-01-01 open Income:US:Govt:PreTax           HSAUSD

; Remaining contributions
2012-01-01 open Assets:US:Govt:PreTax           HSAUSD

; How many contributions you've made on that year
2012-01-01 open Expenses:Taxes:US:TY2014:PreTax HSAUSD


2012-01-01 open Assets:Health-Savings           USD,HSAUSD
2012-01-01 open Assets:Checking                 USD
2012-01-01 open Expenses:Health
2012-01-01 open Income:Interest

2013-12-31 * "Initializing contributions for 2014"
  Income:US:Govt:PreTax                                            -3300 HSAUSD
  Assets:US:Govt:PreTax

2014-01-01 balance Assets:US:Govt:PreTax                            3300 HSAUSD


2014-06-01 * "Transfer"
  Assets:Health-Savings                                             500 USD
  Assets:Checking                                                  -500 USD
  Assets:US:Govt:PreTax                                            -500 HSAUSD
  Expenses:Taxes:US:TY2014:PreTax                                   500 HSAUSD

2014-06-10 * "Doctor"
  Expenses:Health                                                   200 USD
  Assets:Health-Savings

2014-07-01 * "Interest"
  Assets:Health-Savings                                            0.25 USD
  Income:Interest



; bean-query /home/blais/p/ledger-experiments/hsa.beancount bal
;
; |-- Assets
; |   |-- Checking                      -500.00 USD
; |   |-- Health-Savings                 300.25 USD
; |   `-- US
; |       `-- Govt
; |           `-- PreTax               2,800.00 HSAUSD
; |-- Expenses
; |   |-- Health                         200.00 USD
; |   `-- Taxes
; |       `-- US
; |           `-- TY2014
; |               `-- PreTax             500.00 HSAUSD
; `-- Income
;     |-- Interest                        -0.25 USD
;     `-- US
;         `-- Govt
;             `-- PreTax              -3,300.00 HSAUSD



You've got your contributed amount for the year (500 HSAUSD) on the expenses account.

According to Wikipedia, you can apparently contribute up to your filing date for a tax year, so I would write off unused contributions (if any remain) from the Assets account on April 14th.
2015-04-14 * "Writing off unused contributions for 2014"
  Assets:US:Govt:PreTax                                            -2800 HSAUSD
  Expenses:Taxes:US:TY2014:WriteOffs                                2800 HSAUSD



Nathan Grigg

unread,
Jul 21, 2014, 9:44:26 AM7/21/14
to ledge...@googlegroups.com
On Jul 21, 2014, at 6:34 AM, Martin Blais <bl...@furius.ca> wrote:

> I read up a little bit on HSAs out of curiosity. As far as I can tell, it looks like it behaves like an IRA where there's no withdrawal penalty when you take money out to pay for medical expenses. (Is this right?)


Yes, that is right, except change “withdrawal penalty” to “withdrawal penalty or US federal tax”.

I’m facing the same question with 401k as well, but the Health Savings Account is more complicated because you can’t just assume that every account increase is a contribution (like you probably can with a 401k). It is really just a regular account, and you might have interest or a refund from your doctor.

Nathan

signature.asc

Nathan Grigg

unread,
Jul 21, 2014, 9:45:32 AM7/21/14
to ledge...@googlegroups.com
On Jul 20, 2014, at 10:45 PM, Martin Michlmayr <t...@cyrius.com> wrote:

Yes, you can match tags:
 ledger -f d reg "tag("Taxes") =~ /^HSA*/'"

For me, this is matching everything with the “Taxes” tag, regardless of what I use for the regular expression.
signature.asc

Jostein Berntsen

unread,
Jul 21, 2014, 11:29:05 AM7/21/14
to ledge...@googlegroups.com
This should work:

ledger reg tag taxes=HSA.*


Jostein


Nathan Grigg

unread,
Jul 21, 2014, 10:51:45 PM7/21/14
to ledge...@googlegroups.com
Yes, that works. Thank you.
signature.asc

Red Street

unread,
Jul 27, 2014, 10:39:32 PM7/27/14
to ledge...@googlegroups.com
I find using custom payees for a single part of a transaction works out really well:

2014/1/1 Salary
    Income:Salary $100
    Assets:Health Accounts:HSA:HSA Bank    $2.00  ; Payee: Employee Contribution
    Assets:Health Accounts:HSA:HSA Bank    $1.00  ; Payee: Individual Contribution
    ....

2014/1/12 Transfer/HSA contrib
    Assets:Checking Account
    Assets:Health Accounts:HSA:HSA Bank    $4.00  ; Payee: Individual Contribution
    ....

2014/1/12 Transfer/HSA contrib
    Assets:Checking Account
    Assets:Health Accounts:HSA:HSA Bank    $1.00  ; Payee: Nondeductible Contribution
    ....

Then, you can determine different types of contributions separately:
ledger reg ".*:HSA.*" and @Individual
ledger reg ".*:HSA.*" and @Employer
ledger reg ".*:HSA.*" and @Nondeductible

Hope that helps.
Reply all
Reply to author
Forward
0 new messages