I can't get started

148 views
Skip to first unread message

Benjamin Compson

unread,
Jun 20, 2023, 5:50:05 PM6/20/23
to Ledger
I'm trying to get started with ledger, but I'm having a bit of an issue getting over the start line.  I created a file called `testing.journal` which contains:

2023/06/20 * Opening Balance
  Assets:Checking $400.00
  Assets:Savings  $1300.00
  Assets:Cash     $60.00
  Liabilities:MasterCard  $400.00
2023/06/16 Transfer to Bob
  Expenses:Bob   $20.00
  Assets:Checking
2023/06/08 HarborTown Marina
  Expenses:Boat   $300.00
  Assets:Checking
2023/06/08 7-11
  Expenses:ATM  $100
  Assets:Checking
2023/06/08 Gas Company
  Expenses:Utilities:Gas  $30.00
  Assets:Checking
2023/06/06 Transfer From Bob
  Expenses:Bob   -$200.00
  Assets:Checking
2023/06/06 Insurance
  Expenses:Automobile   $200.00
  Assets:Checking

Now when I run ledger -f testing.journal bal, I get:

            $-850.00   Assets
              $60.00    Cash
            $-450.00    Checking
           $-1760.00    Checking $400.00
            $1300.00    Savings
             $450.00   Expenses
             $100.00    ATM
             $200.00    Automobile
             $300.00    Boat
            $-180.00    Bob
              $30.00    Utilities:Gas
             $400.00   Liabilities:MasterCard
--------------------
                   0

Which just doesn't seem right. Like the negative amounts seem backwards and I don't understand why there is a Checking and a Checking $400.00 line?

I used a starting balance from today, but then post-dated transactions. Maybe that's bad form. I'm sorry if this is too basic, but I swear I've been reading through the documentation. Also, I'm very not used to html email, so if this formatting is screwed up, I apologize.

Michael Cordover

unread,
Jun 20, 2023, 6:33:53 PM6/20/23
to ledge...@googlegroups.com
Hi Benjamin

Welcome to the glorious world of plaintext accounting!

The main issue here is that "Assets:Checking $400" account. That exists because in the `Opening Balance` transaction, you need at least two spaces between the account name and the amount. Because there's only one space, at the moment ledger thinks that transaction involves an account called "Assets:Checking $400" with no amount specified.

So if you add at least one more space before "$400" that will fix that - but you'll encounter a different error: "Transaction does not balance". That's because every transaction - even your opening balance! - needs a double entry. At the moment your opening balance transaction doesn't balance against anything else. It's common to use an account like "Equity:Opening balances" to balance that, and then essentially ignore that account. So your new first transaction would look like this:

2023/06/20 * Opening Balance
  Assets:Checking  $400.00
  Assets:Savings  $1300.00
  Assets:Cash     $60.00
  Liabilities:MasterCard  $400.00
  Equity:Opening balances

Now running ledger -f testing.journal bal you'll get something like this:

            $1310.00  Assets
              $60.00    Cash
             $-50.00    Checking
            $1300.00    Savings
           $-2160.00  Equity:Opening balances
             $450.00  Expenses
             $100.00    ATM
             $200.00    Automobile
             $300.00    Boat
            $-180.00    Bob
              $30.00    Utilities:Gas
             $400.00  Liabilities:MasterCard
--------------------
                   0

And that seems mostly accurate to me. Your checking account is $50 overdrawn (started at $400, $650 in expenses with drawn, then a $200 refund from Bob for a net of $450 withdrawn). Similarly, expenses from Bob net -$180, because you paid him $20 but got $200 back.

However, you're going to run into trouble when you try to pay off that MasterCard. Keep in mind that ledger doesn't have a concept of "assets" and "liabilities" based on account names. It only has accounts. Transactions consist of debits (increases to asset or expense accounts, or decreases to liability or equity accounts) or credits (decreases to asset or expense accounts, or increases to liability or equity accounts). The thing which distinguishes a debit from a credit is the sign (negative or positive).

As your file is set up at the moment, it seems like debits are positive, and credits are negative. That makes sense! Your checking account has +$400 in it at the start; and you owe $400 on your MasterCard. But to show that you _owe_ that money, it should be marked as -$400. Hence your new opening balance transaction might be:

2023/06/20 * Opening Balance
  Assets:Checking  $400.00
  Assets:Savings  $1300.00
  Assets:Cash     $60.00
  Liabilities:MasterCard  -$400.00
  Equity:Opening balances

and then running the balance report:

            $1310.00  Assets
              $60.00    Cash
             $-50.00    Checking
            $1300.00    Savings
           $-1360.00  Equity:Opening balances
             $450.00  Expenses
             $100.00    ATM
             $200.00    Automobile
             $300.00    Boat
            $-180.00    Bob
              $30.00    Utilities:Gas
            $-400.00  Liabilities:MasterCard
--------------------
                   0

Now this looks totally accurate to me. Some things you can see here:

 - you owe $400 to MasterCard (negative in assets/liabilities means "not your money")
 - you have $1310 in total assets (positive in assets/liabilities means "your money")
 - your net expense with Bob has been -$180, which is another way of saying he's given you $180, because a negative expense is income

There's more about this credits/debits thing in the manual at https://ledger-cli.org/doc/ledger3.html#Stating-where-money-goes. I also find the Plain Text Accounting Wiki at https://github.com/plaintextaccounting/plaintextaccounting/wiki/Newcomer-FAQ to be useful.

Hopefully this helps!

mjec
--

---
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.

Benjamin Compson

unread,
Jun 20, 2023, 6:49:48 PM6/20/23
to Ledger
Well that was a quick, and simple, fix. I read that I had to be
careful about the 2 white spaces in formatting and still made the
mistake.  Thank you so much.

Now off to read the links you sent, wrap my head around basic 
accounting terms and then see if I can import the OFX file from 
my bank for the year without having to manually enter all the
transactions. Then configure Vim for .journal filetypes. This is 
going to be fun. I love text based stuff.

Thanks again.
Reply all
Reply to author
Forward
0 new messages