Last active
February 23, 2020 19:55
-
-
Save ahirschberg/1b3f2f33bd3954a3b4f38e261b222775 to your computer and use it in GitHub Desktop.
Creates a {Name: Sum} mapping of all the transactions on a Barclays bank statement page for a desired month
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(month_desired => { | |
let store = {} | |
let transactions = document.querySelectorAll('.panel'); | |
for (let t of transactions) { | |
let name = t.querySelector('.description').innerText; | |
let amt = parseInt(t.querySelector('.amount').innerText.replace(/[^0-9.]/g, '')); | |
let date = t.querySelector('.date').innerText; | |
if (date.toLowerCase().substring(0,3) != month_desired) { | |
console.log("Skipping", date); | |
} else { | |
let prev_amt = store[name] || 0; | |
store[name] = prev_amt + amt; | |
} | |
} | |
console.log(store); | |
})("dec") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment