Comments (12)
Hi @ketzacoatl - hledger-flow already exposes all of the hledger functionality you mention. hledger-flow just runs hledger with a specific rules file.
Here is a fuller example, where someone gets paid 100 gold pieces in total, but just 40 of those gold pieces are paid into the bank account after taxes and benefits are kept back.
Given a csv line from the bank:
"20220125","MyCompany 1234-XYZ Salary","40"
And a rules file:
fields date, description, amount
date-format %Y%m%d
currency XAU
account1 assets:Liquid:MyBankAccount
if
MyCompany.*Salary
account2 income:Salary:Gross
amount2 -100.00
account3 assets:Fixed:Pension
amount3 20
account4 expenses:Tax:Income:Salary
amount4 40
You'll get the following generated journal:
$ hledger print --rules-file /tmp/t.rules -f /tmp/t.csv
2022-01-25 MyCompany 1234-XYZ Salary
assets:Liquid:MyBankAccount XAU40.00
income:Salary:Gross XAU-100.00
assets:Fixed:Pension XAU20.00
expenses:Tax:Income:Salary XAU40.00
Note that this example is 100% hledger, nothing specific to hledger-flow.
hledger-flow will guide you into where you should place your rules files for which account etc, but inside the rules file it is just normal hledger stuff.
from hledger-flow.
Hi @ketzacoatl
This sounds like something that you would structure with hledger subaccounts, using the normal hledger rules files.
And I think tags could also be useful here.
from hledger-flow.
Thanks for the super fast reply @apauley!
If I may ask, could you clarify what that would look like with a small example?
from hledger-flow.
Sure, I was just looking through my own rules files.
This contrived example can be put in a rules file. It has both a subaccount and a tag for ProjectA
- you may not need both though. It all depends on how you'd want to query it.
if
someregex
account2 expenses:Supplies:ProjectA
comment project: ProjectA
from hledger-flow.
One thing I'm not understanding is what the csv entries would look like. Using my example above, ATM I have only one transaction for the top-level interaction with the hardware store, but I'm not sure how to tell hledger-flow about the breakdown for that one transaction into the several smaller ones that make it up.
from hledger-flow.
You can specify multiple accounts and amounts when you want to do a breakdown of one transaction:
if
someregex
comment project: ProjectA
account2 expenses:Supplies:ProjectA
amount2 80
account3 expenses:Supplies:ProjectA:Tax
amount3 20
from hledger-flow.
That's in the rules file?
Ok, that seems a little odd though, no?
Eg for each trx that gets a breakdown like this, I'd need to add a unique ID or something, and then add an entry in the rules file.. or am I missing something?
from hledger-flow.
Yes, this is in the rules file. There are lots of cool options:
https://hledger.org/hledger.html#csv-rules
I don't understand what you mean by "unique ID", are you talking about the regex/matcher?
In your example you may need a regex/matcher that uniquely matches your transaction, and then you need to specify the breakdown.
In my rules files I mostly have matchers that match multiple transactions, e.g. one matcher for groceries. And in a few specific cases I match just one unique transaction when I want to do something different with it.
I do this kind of multi-account breakdown on my salary, to specify which is spent on taxes and which is allocated to the retirement benefit etc.
from hledger-flow.
I don't understand what you mean by "unique ID", are you talking about the regex/matcher?
In your example you may need a regex/matcher that uniquely matches your transaction, and then you need to specify the breakdown.
Yes
I do this kind of multi-account breakdown on my salary, to specify which is spent on taxes and which is allocated to the retirement benefit etc.
Nice, can you share a redacted/example csv entry and rule pair that demonstrate this? That would help me understand what pieces are in this puzzle.
Thank you!
from hledger-flow.
hledger seems to have support for accountN/amountN, for 1..9 - simonmichael/hledger#1095. Could that be exposed/used from hledge-flow import csv processing?
from hledger-flow.
Thank you for taking the time to explain these details to me.
hledger-flow already exposes all of the hledger functionality you mention. hledger-flow just runs hledger with a specific rules file.
Does this mean the account2...N and such are also available in the csv file, if specified as a field in the rules file? I think one thing I've been confused about in your examples have been the 2nd/etc amounts down in the rules file instead of being in the csv data.
from hledger-flow.
If you are lucky enough to have the information needed for a breakdown in your CSV files, then you can match on that for your accountN and amountN postings.
In practice I've only seen that when some institutions report a transaction fee in one of the fields, in addition to the amount.
What is in your CSV files?
Usually only the net amount is present in my CSV lines.
So in the salary example, I only see "40 gold pieces" in the CSV line, but I know this isn't the gross salary, and I know that there are benefits and taxes that aren't reported in the CSV data.
So I manually put the extra information in my rules file.
The hledger docs point to some examples.:
https://github.com/simonmichael/hledger/tree/master/examples/csv
https://github.com/simonmichael/hledger/blob/master/examples/csv/amazon-orders.csv.rules
https://github.com/simonmichael/hledger/blob/master/examples/csv/stripe.csv.rules
from hledger-flow.
Related Issues (20)
- File-specific rules HOT 5
- hledger-flow does not 'see' _manual_ year subdirectory if there is no corresponding 1-in subdirectory HOT 1
- If I delete a file in a `1-in` directory, re-running `hledger-flow import` does not remove the corresponding files in the `2-preprocessed` and `3-journal` directories HOT 4
- Missing version bound on turtle breaks build HOT 3
- Have a way to use `--cost` option for income-expense reports HOT 1
- Documentation on workflow HOT 8
- `hledger-flow` reports empty for user sub-accounts (due to missing `directives.journal` at lower levels) HOT 3
- (docs) unclear what to do if starting balance is not 0 HOT 6
- Where to put account declarations and prices? HOT 1
- Support for Apple Silicon (aarch64-darwin) HOT 3
- hackage doesn't have the 0.15 release
- Windows: the preprocess and construct scripts are not executed HOT 1
- QUESTION: tags, reports, multiple contributors, virtual accounts, how to do it simply? HOT 2
- when preprocess is called with a $1 that has a .timeclock extension, $2 has a .csv extension HOT 3
- 3-journal/ files not ending in ".journal" extension are added to yearly include files HOT 6
- Make it possible to configure the number of cores being used (the default is to use all cores, which slows down the machine) HOT 18
- hledger-flow does not 'see' hledger despite it being present in the PATH as a symlinked executable HOT 3
- cabal install error: Not in scope: type constructor 'Rel' HOT 2
- Question: where to include "meta" statements (`account...`, `commodity format` & `alias`) & prices? HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hledger-flow.