summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2021-05-16 09:44:38 -0400
committerBen Sima <ben@bsima.me>2021-05-16 09:44:38 -0400
commit3bd39549493d3edcb337b6f5c4aa13c62944da7f (patch)
tree6532c342ad8beeecd0ba8390ffc1a4ae6b54894c
parentd37664d373449acde7f40b2a097afda505332da8 (diff)
add script to download info from bamboohr
-rwxr-xr-xpayinfo-to-journal67
1 files changed, 67 insertions, 0 deletions
diff --git a/payinfo-to-journal b/payinfo-to-journal
new file mode 100755
index 0000000..5c22232
--- /dev/null
+++ b/payinfo-to-journal
@@ -0,0 +1,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