blob: 5c2223268e99ec74209bc5b1c99341d4052a11b6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#!/usr/bin/env bash
#
# get paystub info from bamboohr, dump to ledger-cli journal file
journal="$HOME/org/fund/from-qutebrowser.journal"
json=$(pup '.PayDetailTable table tr json{}' < "$QUTE_HTML")
# this must be different than 'sel' because the income table has 4 columns
# instead of 3
sel_income() {
jq '.[] | {(.children[0].text): .children[2].text}' <<< $json \
| jq -s add \
| jq ".\"$1\"" \
| sed 's/\$\|\"//g' \
| sed "s/null/0.00/"
}
income=$(sel_income "Regular")
# 'reduce' puts '$in' first, so when we find duplicate fields, we choose the
# first, thus selecting "Deducted from your check" instead of "Paid by your
# employer on your behalf" which I don't need to track
data=$(jq '.[] | {(.children[0].text): .children[1].text}' <<< $json \
| jq -n 'reduce inputs as $in (null; $in + .)'
)
# select a field from extracted data
sel() {
jq ".\"$1\"" <<< $data \
| sed 's/\$\|\"//g' \
| sed "s/null/0.00/"
}
date=$(pup "#fabricModalHeadline text{}" < "$QUTE_HTML" \
| sed "s/ Paystub//"
)
# parse the "Direct Deposit" section
get_deposits() {
pup '.PaystubMessage__text json{}' < "$QUTE_HTML" \
| jq '.[1].text' \
| sed 's/, /\n/g' \
| sed 's/$\([0-9.,]*\) .* x-\(....\)/ as:me:cash:\2 \1 USD/g' \
| sed 's/"//g' \
| sed 's/\.$//g'
}
deposits=$(get_deposits)
cat <<EOF >> ~/org/fund/from-bamboohr.journal
$(date --date="$date" '+%Y/%m/%d') Groq Paycheck
in:me:groq:salary -$income USD
ex:me:taxs:federal:income $(sel "Federal") USD
ex:me:taxs:federal:medicare $(sel "Medicare") USD
ex:me:taxs:federal:social-security $(sel "Social Security") USD
ex:me:taxs:california:sdi $(sel "CA-SDI") USD
ex:me:taxs:california:income $(sel "State (CA)") USD
ex:me:taxs:ohio:income $(sel "State (OH)") USD
as:me:groq:deductions:401k $(sel "401K Savings Pre-Tax") USD
ex:me:groq:deductions:medical $(sel "Blue Shield Plat PPO Med Ins Pre-Tax") USD
ex:me:groq:deductions:medical $(sel "Domestic Partner Medical") USD
ex:me:groq:deductions:dental $(sel "Delta Dental Insurance Pre-Tax") USD
ex:me:groq:deductions:dental $(sel "Domestic Partner Dental") USD
ex:me:groq:deductions:vision $(sel "Vision Insurance Pre-Tax") USD
ex:me:groq:deductions:vision $(sel "Domestic Partner Vision") USD
${deposits[@]}
EOF
|