Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support simple expressions in postings #183

Open
alexanderkjeldaas opened this issue May 4, 2014 · 4 comments
Open

Support simple expressions in postings #183

alexanderkjeldaas opened this issue May 4, 2014 · 4 comments
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. journal The journal file format, and its features.

Comments

@alexanderkjeldaas
Copy link

When working with differenciated VAT (in EU), an invoice might say:

Food A (12% vat) EUR 50
Food B (12% vat) EUR 10
...
...
Plastic bag (25% vat) EUR 0.1
Transportation (25% vat) EUR 4

Total: EUR 1423.00
including VAT 25% EUR 0.82
including VAT 12% EUR 240

In this scenario, it is useful to be able to write any of the following:

expenses:food:12%   1423.10 - 0.1 - 4
expenses:other:25%     0.1 + 4
cash

That is, if a few entries have a different vat setting, being able to use some simple calculations is good. The idea is that the posting should only include numbers that are easy to find on the receipt and it should be succinct.

It could have been written:

expenses:food:12%   1423.10
expenses:food:12%        -0.1
expenses:food:12%        -4
expenses:other:25%     0.1
expenses:other:25%     4
cash

but that is pretty hackish and unclear I think.

In this example I have accounts that have fixed VAT amounts, so I can transfer the VAT at the end of the reporting period:

expenses:food:12%     -41243  = 0
expenses:food             41243/1.12
vat:incoming:12%

Another way to do this is like this:

expenses:food:12%   (1423.10 - 0.1 - 4)/1.12
vat:incoming:12%        240
expenses:other:25%     (0.1 + 4)/1.25
vat:incoming:25%       0.82
cash                           -1423

In that example, only numbers from the receipt are used, and the posting must balance. Without the ability to calculate non-vat food and other expenses, a calculator must be used, which makes writing the posting 3x as much work. A posting where the numbers are calculated is also less clear. It is hard to know whether the numbers correspond to the receipt.

The following simple 2-minute hack in perl implements this partially as a preprocessor, but more principled support would be great.

#!/usr/bin/perl -p

if (m/(\s+[a-zäöåA-ZÖÄÅ0-9:%]+\s\s+)(-?[0-9.()]+(\s*[-+*\/]\s*[0-9.()]+)+)/) {
    $_=$1.eval($2)."\n";
}
@simonmichael
Copy link
Owner

A nice feature request with great examples. I can see how this can be useful and a labour saver, yet I feel it will bring a lot of new complexities, interactions and support burden. It will be quite a few more lines of code than your (annoyingly short) perl script too. So I think I'm around -0.1 on this feature. But if a pull request appeared I would accept it.

@simonmichael
Copy link
Owner

Needs discussion/developers, closing.

@simonmichael
Copy link
Owner

On #913 @sorsasampo wrote:

@simonmichael I think it would be nice if there was a separate issue for expression amounts that people could subscribe to.

I followed #183 / #923 -> #871 comments here.

I can't easily keep track of this set of issues, so I'm not sure if we have one already, but I've reopened #183 for this.

@simonmichael simonmichael reopened this Nov 14, 2018
@simonmichael
Copy link
Owner

Summary: there is new interest in this issue and some related PRs from @ag-eitilt, beginning with #871. It might happen, if we can keep the complexities down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-WISH Some kind of improvement request, hare-brained proposal, or plea. journal The journal file format, and its features.
Projects
None yet
Development

No branches or pull requests

2 participants