PracticalReputation

joined 11 months ago
[–] PracticalReputation@lemmy.world 2 points 7 months ago* (last edited 7 months ago)

Kind of got it as I started thinking about it after posting... Would be better as a oneliner set to an alias so one can add flags on the fly, but this works:

#!/usr/bin/env bash

# Where to save temporary journal
PROGRESS_JOURNAL_PATH="/tmp/progress.journal"

# Current month as number
MONTH=$(date +%m)
# Need to increment the month with one for loop to work
((MONTH++))

# Clean out the temp journal in case it already exists
echo -e "; Temporary progress journal\n" > "$PROGRESS_JOURNAL_PATH"

for ((COUNTER = 1 ; COUNTER < $MONTH ; COUNTER++)); do
  # Append each months transactions until current month within the same date range as today
  hledger print -b "$(date +%Y)-$COUNTER-01" -e "$(date +%Y)-$COUNTER-$(date +%d)" >> "$PROGRESS_JOURNAL_PATH"
done

# Print out the command that should run to output
echo "$ hledger -f $PROGRESS_JOURNAL_PATH is -t -M -A"
# Get the result
hledger -f "$PROGRESS_JOURNAL_PATH" is -t -M -A -S
 

Is there a way I could see my is view monthly, but from current date from each month? I.e. if I ran the command today I would see January to April where each month is showing expenses and incoming from 1-9, i.e. 1-9 January, 1-9 February, 1-9 March and so forth?

Idea is to have a comparison how expenses/income ratio is going compared to previous months at the "same time".

Like for January only I could $ hledger print -b $(date +%Y-)01-01 -e $(date +%Y)-01-$(date +%d)

[–] PracticalReputation@lemmy.world 1 points 10 months ago

Thank you so much! It works exactly like I wanted!

 

In hledger I have my income set up like income:job:main (gross) and taxes are in expenses:job:tax, so when I run: $ hledger is -t job I can see my net value for my work and if I run $ hledger is -t other expenses come into play as well.

Sometimes though, I would like to be able to see the income statement view with my net for my job under Revenues and the rest of my expenses under Expenses. Is there any easy way to do this with an alias or similar?

[–] PracticalReputation@lemmy.world 2 points 11 months ago

Thanks for pointing that out, it was one of the problems, the solution was using: date-format %Y-%m-%d %H:%M:%S

Next problem was I forgot to add skip 1 at the top.

 

I have a csv file I'd like to read, seems I'm correct other than parsing the date. The csv file shows the date like so: ""2023-03-04 07:54:33"

I've tried a bunch without success. I feel it should be:

date-format %Y-%M-%D %H:%M:%S

But nope, getting an error it can not parse it.