Giter Site home page Giter Site logo

Comments (12)

apauley avatar apauley commented on June 18, 2024 1

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.

apauley avatar apauley commented on June 18, 2024

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.

ketzacoatl avatar ketzacoatl commented on June 18, 2024

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.

apauley avatar apauley commented on June 18, 2024

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.

ketzacoatl avatar ketzacoatl commented on June 18, 2024

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.

apauley avatar apauley commented on June 18, 2024

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.

ketzacoatl avatar ketzacoatl commented on June 18, 2024

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.

apauley avatar apauley commented on June 18, 2024

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.

ketzacoatl avatar ketzacoatl commented on June 18, 2024

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.

ketzacoatl avatar ketzacoatl commented on June 18, 2024

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.

ketzacoatl avatar ketzacoatl commented on June 18, 2024

@apauley,

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.

apauley avatar apauley commented on June 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.