Riscontro List

96 views
Skip to first unread message

Esben Stien

unread,
May 8, 2014, 10:53:48 AM5/8/14
to ledge...@googlegroups.com
When I get an incoming invoice from a company called foo, I do:

2014-04-21 REG foo.33341
;[[id:0b073899-81b7-4e41-b137-f62c839d316f][foo.33341]]
Expenses:4110 381
Liabilities:2400:foo

2014-04-21 PAY foo.33341
;[[id:0b073899-81b7-4e41-b137-f62c839d316f][foo.33341]]
Liabilities:2400:foo 381
Assets:1920

I've marked each transaction with a link to the corresponding document
that describes the invoice, but ledger itself doesn't know anything
about it.

That makes it hard to write out a so called riscontro list of the
2400:foo account to look at unpaid invoices.

Is there any way to bind a transaction to an identifier, so that it's
possible to write out a riscontro list?

--
Esben Stien is b0ef@e s a
http://www. s t n m
irc://irc. b - i . e/%23contact
sip:b0ef@ e e
jid:b0ef@ n n

John Wiegley

unread,
May 8, 2014, 11:19:12 PM5/8/14
to ledge...@googlegroups.com
>>>>> Esben Stien <b0...@esben-stien.name> writes:

> 2014-04-21 PAY foo.33341
> ;[[id:0b073899-81b7-4e41-b137-f62c839d316f][foo.33341]]
> Liabilities:2400:foo 381
> Assets:1920

> I've marked each transaction with a link to the corresponding document that
> describes the invoice, but ledger itself doesn't know anything about it.

I think you'd need:

2014-04-21 PAY foo.33341
; Link: [[id:0b073899-81b7-4e41-b137-f62c839d316f][foo.33341]]
Liabilities:2400:foo 381
Assets:1920

Now you can refer to %(tag('Link')) in a format string.

John

Esben Stien

unread,
May 10, 2014, 1:41:01 AM5/10/14
to ledge...@googlegroups.com
"John Wiegley" <jo...@newartisans.com> writes:

> I think you'd need:
>
> 2014-04-21 PAY foo.33341
> ; Link: [[id:0b073899-81b7-4e41-b137-f62c839d316f][foo.33341]]
> Liabilities:2400:foo 381
> Assets:1920
>
> Now you can refer to %(tag('Link')) in a format string.

I don't understand. If I do several of these registrations when I
receive the invoice:

2014-04-21 REG foo.33341
;[[id:0b073899-81b7-4e41-b137-f62c839d316f][foo.33341]]
Expenses:4110 381
Liabilities:2400:foo

2014-04-21 REG foo.33342
;[[id:7fab2e8e-97d1-0d2b-459d-ae6de1130215][foo.33342]]
Expenses:4110 481
Liabilities:2400:foo

2014-04-21 REG foo.33343
;[[id:7d5d7b6b-13d5-1e23-11fc-a27dfc11fd20][foo.33343]]
Expenses:4110 581
Liabilities:2400:foo

There must be some way to get a list of invoices that are not paid, f.ex
in this case, the following invoices are not paid:

foo.33341
foo.33342
foo.33343

Jostein Berntsen

unread,
May 10, 2014, 4:40:21 AM5/10/14
to ledge...@googlegroups.com
I guess you can mark the invoice as pending and get the list of unpaid
invoices with "--pending"?


2014-04-21 ! REG foo.33342
;[[id:7fab2e8e-97d1-0d2b-459d-ae6de1130215][foo.33342]]
Expenses:4110 481
Liabilities:2400:foo

2014-04-21 ! REG foo.33343
;[[id:7d5d7b6b-13d5-1e23-11fc-a27dfc11fd20][foo.33343]]
Expenses:4110 581
Liabilities:2400:foo

Jostein


Esben Stien

unread,
May 10, 2014, 4:54:12 PM5/10/14
to ledge...@googlegroups.com
Jostein Berntsen <jbe...@broadpark.no> writes:

> I guess you can mark the invoice as pending and get the list of unpaid
> invoices with "--pending"?

No actually, I figured it out. I could just append the invoice number to
the account.

2014-04-21 REG foo.33342
;[[id:7fab2e8e-97d1-0d2b-459d-ae6de1130215][foo.33342]]
Expenses:4110 481
Liabilities:2400:foo:33342

That way, when writing a report out for the 2400 account, I see directly
the invoices;)

I'm just wondering why noone answered with a solution to this. Isn't
this quite a normal thing to do in an accounting software; to write out
a list of unpaid invoices?

Alexandre Rademaker

unread,
May 10, 2014, 5:19:55 PM5/10/14
to ledge...@googlegroups.com

Sorry for this probably silly question but I didn't find any info in the docs.

I need to add an automatic post about the tax that I pay each time that I use my credit card for international purchases. If I buy in Brazilian Reais, no tax, but if I buy something in dollars or euros, I have to pay 6.38% of tax. I could register one transaction per statement (summing up the total amount of tax that I payed for all international purchases in that statement) or I could register the tax amount per entry (purchase). I prefer the second one. Any idea?

Automatic transaction is the only way to go? Can I have on post relative to the amount of the transaction? Can automatic transaction be fired only when specific currency was used in a specific account?

Best,
Alexandre

Russell Adams

unread,
May 10, 2014, 6:12:17 PM5/10/14
to ledge...@googlegroups.com
On Sat, May 10, 2014 at 10:54:12PM +0200, Esben Stien wrote:
> Jostein Berntsen <jbe...@broadpark.no> writes:
>
> > I guess you can mark the invoice as pending and get the list of unpaid
> > invoices with "--pending"?
>
> No actually, I figured it out. I could just append the invoice number to
> the account.
>
> 2014-04-21 REG foo.33342
> ;[[id:7fab2e8e-97d1-0d2b-459d-ae6de1130215][foo.33342]]
> Expenses:4110 481
> Liabilities:2400:foo:33342
>
> That way, when writing a report out for the 2400 account, I see directly
> the invoices;)
>
> I'm just wondering why noone answered with a solution to this. Isn't
> this quite a normal thing to do in an accounting software; to write out
> a list of unpaid invoices?

That's technically not account, that's document management.

I found very quickly that it's a bad idea to use accounts for
documents. A better idea is to use a metadata tag with document ID or
state (ie: paid). That allows you to use the new validation methods to
lock down your list of accounts so typos don't unbalance your books.

Thanks.


------------------------------------------------------------------
Russell Adams RLA...@AdamsInfoServ.com

PGP Key ID: 0x1160DCB3 http://www.adamsinfoserv.com/

Fingerprint: 1723 D8CA 4280 1EC9 557F 66E8 1154 E018 1160 DCB3

Martin Michlmayr

unread,
May 10, 2014, 6:41:22 PM5/10/14
to ledge...@googlegroups.com
* Esben Stien <b0...@esben-stien.name> [2014-05-10 22:54]:
> No actually, I figured it out. I could just append the invoice number to
> the account.

I agree with Russell Adams that I wouldn't put such information in the
account name. Unfortunately, I cannot quite articulate why, but
experience has shown me that it's a bad approach. (Alas, I don't have
any examples showing why.)

Yes, what you're looking for is common and I'm not sure if a ledger
query can do it. I think we need more business logic on top of (or
in) ledger.

Thinking about it, I believe the --pivot option might do everything
(or almost everything) you want.

Take this example:

2011-01-01 * Opening balance
Assets:Cash 25.00 GBP
Equity:Opening balance -25.00 GBP

2011-02-01 * Sell to customer AAA
; Customer: AAA
; Invoice: 101
Assets:Receivables 10.00 GBP
Income:Sale -10.00 GBP

2011-02-02 * Sell to customer BBB
; Customer: BBB
; Invoice: 102
Assets:Receivables 11.00 GBP
Income:Sale -11.00 GBP

2011-02-03 * Sell to customer AAA
; Customer: AAA
; Invoice: 103
Assets:Receivables 12.00 GBP
Income:Sale -12.00 GBP

2011-02-03 * Money received from customer AAA for invoice 101
; Customer: AAA
; Invoice: 101
Assets:Cash 10.00 GBP
Assets:Receivables -10.00 GBP

Now you can see how much each customer owes you:

ledger -f d bal assets:receivables --pivot Customer
23.00 GBP Customer
12.00 GBP AAA:Assets:Receivables
11.00 GBP BBB:Assets:Receivables
--------------------
23.00 GBP

And you can see which invoices haven't been paid yet:

ledger -f d bal assets:receivables --pivot Invoice
23.00 GBP Invoice
11.00 GBP 102:Assets:Receivables
12.00 GBP 103:Assets:Receivables
--------------------
23.00 GBP

But I'm not sure if there's a way to see a list of open invoices for each
customer, i.e. a pivot on both Customer and Invoice.

John, does that sound like a reasonable feature request or is there a
way to do this already?

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

Martin Michlmayr

unread,
May 10, 2014, 6:55:01 PM5/10/14
to ledge...@googlegroups.com
* Martin Michlmayr <t...@cyrius.com> [2014-05-11 00:41]:
> John, does that sound like a reasonable feature request or is there a
> way to do this already?

Also, how powerful is the query mechanism? For the example I gave
(plus some Link: directives to link to stored PDFs of invoices), would
it be possible to write a query that does something like:

For each customer, pivot Assets:Receivables by Invoice and show
Invoice:Assets:Receivables if not empty; additionally, show me the
%(tag('Link')) info for each Invoice:Assets:Receivables so I can
easily look up the invoice.

The output should be something like this:

Customer AAA

11.00 GBP 102:Assets:Receivables
Link: foo.pdf

Customer BBB
12.00 GBP 103:Assets:Receivables
Link: bar.pdf

Is this feasible or is the best way to write a Python script?

Martin Blais

unread,
May 11, 2014, 12:03:44 AM5/11/14
to ledger-cli
Hi Eben,

Using account names is not the right solution for this problem; doing this will
force your to create a new account for each new invoice. This is just not how
accounts are meant to be used and these account names will become irrelevant as
soon as the associated invoice is paid. Not a good idea.

In Beancount there is no dedicated feature to do this. I've had the same
question for a long while actually: though I don't currently run invoices and a
company, having just 3 or 4 payables it can be a bit annoying to look through
the journal of a receivables account and figure out which has been paid which
hasn't, from the sum total.

I just had an idea: you can build such a tracking feature in Beancount on top of
the link attributes attached to transactions. What you would do is group linked
transactions that occur in a "transfer account", that is, your payables account
or your receivables account. If the sum of all balance changes for this list of
entries does not add to zero, the transactions are marked as "pending". This
solution work for payables and receivables. It will work with multiple payments
or with groups of multiple invoices as well.

So I've built an example plugin for this a few hours ago, just to test it out.
I'm trying to think of a way to integrate this feature in mainline Beancount in
the most reusable and least complicated way possible. Some thoughts:

- Earlier today I wrote this only for a specific transfer account, e.g. you
  would have to say "Liabilities:AccountsPayable" is the account; I don't like
  that, the fact that I would have to specify one. For this project I really
  much prefer to design features which do not require any custom configuration,
  so I thought of this idea instead:  given a set of entries, automatically
  compute the intersection of all of the common accounts of their postings. This
  list of common accounts now implicitly defines the transfer accounts. I think
  this makes sense.

- Also, I originally wrote a dedicated script to list pending transactions. I
  just changed this into a Beancount plugin that just inserts a "#PENDING" tag
  to those incomplete transactions. This way those transactions automatically
  show up as a tag view in the web interface and you can e.g. view a balance
  sheet of all your unpaid transactions.

  If you run the file as a script it looks for those transactions with a
  #PENDING tag and spits them out.

- Another idea, would be to introduce a special kind of "matching link", maybe
  with an alternative syntax, e.g., ^^da5f4404c77c instead of,^da5f4404c77c or
  perhaps simpler, to allow the user to specify a regexp to restrict which links
  are subjected to this pending detection.


See example script here:
https://hg.furius.ca/public/beancount/file/25adf321377b/src/python/beancount/plugins/tag_pending.py


If you want to try this at home, save the example script to a file, clone
Beancount, build it ("make build") and run this:

  cd beancount/src/python/beancount/plugins
  ./tag_pending.py /tmp/test.beancount


You should get this output with the attached file, which is the pending
transaction:

  Pending/incomplete transactions:

  2013-03-30 * "Bill for gas" #PENDING ^invoice-562b4da33bd9
    Expenses:Gas                                                           204.20
    USD
    Liabilities:AccountsPayable                                           -204.20
    USD


I made this as a plugin, so you can also run it with the web interface, like
this:

  bean-web --plugin=beancount.plugins.tag_pending /tmp/test.beancount


For those who can't be bothered install it, I baked its output in attachment,
using this command:

  bean-bake --plugin=beancount.plugins.tag_pending /tmp/test.beancount pending

Unzip the file, navigate to index.html, click on #PENDING, then Journal, which
should show only the pending transaction.

Edit the test file various ways and reload your web page to experiment with
changes (it reparses the file automatically on reload).

Thoughts and ideas welcome,




--

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

test.beancount
pending.zip

Russell Adams

unread,
May 11, 2014, 12:17:20 AM5/11/14
to ledge...@googlegroups.com
This is very similar to my expense reporting. I have a expense report
number and customer, and I have shell scripts that iterate over the
tagged values that ledger returns.

I've already tried attaching files by number or link in txns and gave
up, it was such a hassle. I'm open to suggestions though.

Martin Blais

unread,
May 11, 2014, 12:48:13 AM5/11/14
to ledger-cli
Hi Alex,

Can you describe in more detail how you'd like this to look like?

Here's what I think you're saying (please correct me if I'm wrong):
For this kind of input:

  2014-05-11 open Liabilities:CreditCard  BRL
  2014-05-11 open Expenses:CoolStuff      BRL,USD
  2014-05-11 open Expenses:ForeignTax     BRL

  2014-05-11 * "Compra local"
    Liabilities:CreditCard        -102.39 BRL
    Expenses:CoolStuff


  2014-05-11 * "Compra global"
    Liabilities:CreditCard        -82.30 BRL @ 0.45 USD
    Expenses:CoolStuff


You would like the transactions to get parsed into this:

  2014-05-11 * "Compra local"
    Liabilities:CreditCard        -82.30 BRL @ 0.45 USD
    Expenses:CoolStuff             37.0350 USD

  2014-05-11 * "Compra global"
    Liabilities:CreditCard        -82.30 BRL @ 0.45 USD
    Expenses:CoolStuff             34.6721670 USD
    Expenses:ForeignTax            5.25074 BRL @ 0.45 USD


For the local transaction, the automatically filled-in amount is as
usual, just the converted amount.

For the global transaction, instead of just converting the amount,
take 6.38% of it and automatically insert a new posting to book
that against the foreign tax amount, and fill in the auto-posting
with the remainder.

Would that work?



An idea I've been toying with at some point is to allow the user to
specify more than a single posting without an amount, like this:

  2014-05-11 * "Compra global"
    Liabilities:CreditCard        -82.30 BRL @ 0.45 USD
    Expenses:CoolStuff            
    Expenses:ForeignTax            6.38%

where all the percentages of those postings would still have to sum
up to 100%, and one of them could be left without a percentage, as
above (the Expenses:CoolStuff posting is automatically set to
93.62%). The amounts automatically booked would be in proportion to
their percentage. This is the second time I hear of a use case for
this.

However, your use case seems to warrant a more automatic usage. If
the tax is stable (e.g. it only changes every year, for instance),
you would still want to code this into the system.

I think Ledger has some way to automatically book a virtual amount
on a pattern; that might be enough if the tax never changes.





Martin Blais

unread,
May 11, 2014, 12:49:12 AM5/11/14
to Martin Blais, ledger-cli
On Sun, May 11, 2014 at 12:48 AM, Martin Blais <bl...@furius.ca> wrote:
Hi Alex,

Can you describe in more detail how you'd like this to look like?

Here's what I think you're saying (please correct me if I'm wrong):
For this kind of input:

  2014-05-11 open Liabilities:CreditCard  BRL
  2014-05-11 open Expenses:CoolStuff      BRL,USD
  2014-05-11 open Expenses:ForeignTax     BRL

  2014-05-11 * "Compra local"
    Liabilities:CreditCard        -102.39 BRL
    Expenses:CoolStuff


  2014-05-11 * "Compra global"
    Liabilities:CreditCard        -82.30 BRL @ 0.45 USD
    Expenses:CoolStuff


You would like the transactions to get parsed into this:

  2014-05-11 * "Compra local"
    Liabilities:CreditCard        -82.30 BRL @ 0.45 USD
    Expenses:CoolStuff             37.0350 USD


Sorry, this bit should read:

  2014-05-11 * "Compra local"
    Liabilities:CreditCard        -82.30 BRL
    Expenses:CoolStuff             82.30 BRL

John Wiegley

unread,
May 12, 2014, 2:12:50 AM5/12/14
to ledge...@googlegroups.com
>>>>> Martin Michlmayr <t...@cyrius.com> writes:

> But I'm not sure if there's a way to see a list of open invoices for each
> customer, i.e. a pivot on both Customer and Invoice.

> John, does that sound like a reasonable feature request or is there a way to
> do this already?

Can you try adding --group-by=EXPR to your --pivot=EXPR report?

John

Martin Michlmayr

unread,
May 12, 2014, 11:10:24 AM5/12/14
to ledge...@googlegroups.com
* John Wiegley <jo...@newartisans.com> [2014-05-12 06:12]:
> > John, does that sound like a reasonable feature request or is there a way to
> > do this already?
>
> Can you try adding --group-by=EXPR to your --pivot=EXPR report?

That doesn't work. --group-by "tag('Customer')" on its own works as
expected but --group-by "tag('Customer')" --pivot Invoice assets:ca
gives no output at all.

Bugzilla?

John Wiegley

unread,
May 12, 2014, 3:05:51 PM5/12/14
to ledge...@googlegroups.com
>>>>> Martin Michlmayr <t...@cyrius.com> writes:

> That doesn't work. --group-by "tag('Customer')" on its own works as
> expected but --group-by "tag('Customer')" --pivot Invoice assets:ca gives no
> output at all.

> Bugzilla?

Yes, please.

John

Martin Michlmayr

unread,
May 12, 2014, 5:42:17 PM5/12/14
to ledge...@googlegroups.com
* John Wiegley <jo...@newartisans.com> [2014-05-12 19:05]:
> > That doesn't work. --group-by "tag('Customer')" on its own works as
> > expected but --group-by "tag('Customer')" --pivot Invoice assets:ca gives no
> > output at all.
>
> > Bugzilla?
>
> Yes, please.

http://bugs.ledger-cli.org/show_bug.cgi?id=1034

Martin Michlmayr

unread,
May 13, 2014, 9:37:28 AM5/13/14
to ledge...@googlegroups.com
Can someone running OS X please comment on Bug 768 - OS X installer is
incomplete:

http://bugs.ledger-cli.org/show_bug.cgi?id=768

Zack Williams

unread,
May 13, 2014, 10:26:17 AM5/13/14
to ledge...@googlegroups.com
I think this is a documentation problem. I assume they installed the
.dmg installer from the downloads page.

The places that ledger installs binaries are fine, although
/opt/ledger/bin or /usr/local/bin would also be suitable, but neither
of those is in the default PATH under OS X.

It's possible to add informative pages to the OS X installer process
that would tell the user they need to update their PATH variable in
order to use ledger.

I'm not sure how John is generating the installer package, but there
are a variety of ways to do it. I build OS X packages all the time for
$DAYJOB, so I could take this on.

- Zack

John Wiegley

unread,
May 13, 2014, 4:24:57 PM5/13/14
to ledge...@googlegroups.com
>>>>> Zack Williams <zdw...@gmail.com> writes:

> I'm not sure how John is generating the installer package, but there are a
> variety of ways to do it. I build OS X packages all the time for $DAYJOB, so
> I could take this on.

Consider it yours, Zack! :) Thank you so much.

John

Esben Stien

unread,
Jun 12, 2014, 6:59:05 PM6/12/14
to ledge...@googlegroups.com
Martin Michlmayr <t...@cyrius.com> writes:

> I agree with Russell Adams that I wouldn't put such information in the
> account name. Unfortunately, I cannot quite articulate why, but
> experience has shown me that it's a bad approach. (Alas, I don't have
> any examples showing why.)

It worked fine until I paid 3 invoices at the same time, as in 10$ for
invoice0, 20$ for invoice1 and 30$ for invoice2. Then it screwed up and
I had to remove the invoice number from the account;)

> Thinking about it, I believe the --pivot option might do everything
> (or almost everything) you want.

I'll try this way now and let you know how it goes.
Reply all
Reply to author
Forward
0 new messages