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

add action to calculate balance of transaction #127

Open
zanona opened this issue Apr 3, 2022 · 3 comments
Open

add action to calculate balance of transaction #127

zanona opened this issue Apr 3, 2022 · 3 comments

Comments

@zanona
Copy link

zanona commented Apr 3, 2022

Hello,
Just following up my previous comment with a suggestion for adding an action to allow calculating the balance for an specific transaction. An good use case would be on automated transactions, which need to be explicitly balanced.

= income:salary
  bank:foo         $1.234
  savings:bar      $1.293
  investment:baz   $1.939
  bank:busines    $-0.000   ; i.e we could have `:call ledger#balance_transaction()`

2022-04-05 Salary
  bank:business    $5.000
  income:salary

Originally posted by @zanona in #109 (comment)

@alerque
Copy link
Member

alerque commented Apr 6, 2022

Pardon my ignorance here because I use hledger and this is a ledger specific syntax. I'm a little confused what would actually be calculated here. It seems to be a far more common use case for automated transactions would be using multipliers, not fixed amounts:

= income:salary
  bank:foo         0.8
  savings:bar      0.2
  bank:business   -1.0

2022-04-05 Salary
  bank:business    $5,000
  income:salary

In the case you posted, it seems like the automation rule would only work for fixed amounts, in which case it isn't clear to me what you would expect VIM to be calculating. Do you expect it to add up the postings in just the automated transaction and come up with $-4.466, or what? Wouldn't that then only work as long as your following transactions relating to salary were always the same amount?

@zanona
Copy link
Author

zanona commented Apr 6, 2022

Hey, @alerque
I believe this is a nice example:


= income:salary
	expense:gym                                         $75
        expense:bar                                         $50
	assets:bank                                       -$125

~ monthly
	assets:bank                                      $1,500
	income:salary                                   -$1,500

It's not always that I would to declare values in percentile, so it is more readable (I know straight how much I pay for gym as $75 rather than 0.05), but not only that, sometimes there are a group of transactions which happen simultaneously, in which case it could become quite annoying to calculate every time, like the one below.

= income:salary
	fund:electricity                                ($800/12)
	fund:tv-licence                                 ($150/12)
	fund:damages-insurance                          ($125/12)
	fund:rent-insurance                             ($150/12)
	fund:recycling-tax                               ($65/12)
        assets:bank                                      ....

So, at least in my case, those transactions don't always revert to -1.0 spending the full amount of the original transaction. i.e: salary

However, perhaps this is far too outside the scope of this plugin and a possible edge-case scenario, in which case we can certainly close this issue and I will find another ways to automate these calculations otherwise 😉

@alerque
Copy link
Member

alerque commented Apr 6, 2022

If I'm following along correctly here, you just want to balance postings in a single transaction. The fact that it is an automatic transaction is nearly irrelevant. That seems like something we may be able to do, although currency handling is likely to make this excessively complicated to actually pull off. In any case it's possible that as long as what you want is scoped to a single transaction (not referencing a value from another transaction) that me may be able to cover that in this plugin.

I personally don't have much interest in making this happen because I use hledger which doesn't have the same balance requirements and also I normalize translations by printing them with hledger itself which automatically calculates and fills in elided values.

Given the parameters above that it was scoped to a transaction and makes reasonably attempt at handling different currencies and formats properly I'd be willing to facilitate a PR if somebody else jumps in to contribute this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants