Created
May 22, 2018 09:51
-
-
Save DavideMontersino/9a8259ccf829a451da26230112f6913e to your computer and use it in GitHub Desktop.
ING bankieren afschrift creditcard downloaden
This file contains hidden or 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
// AT Ing, they say they cannot let you download an extract of your | |
// credit card expenses because it is impossible given how the system was built. | |
// But I needed to be able to do it, so I just spent an hour doing it. | |
function ConvertToCSV(objArray) { | |
var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray; | |
var str = ''; | |
for (var i = 0; i < array.length; i++) { | |
var line = ''; | |
for (var index in array[i]) { | |
if (line != '') line += ',' | |
line += array[i][index]; | |
} | |
str += line + '\r\n'; | |
} | |
return str; | |
} | |
function download(filename, text) { | |
var element = document.createElement('a'); | |
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)); | |
element.setAttribute('download', filename); | |
element.style.display = 'none'; | |
document.body.appendChild(element); | |
element.click(); | |
document.body.removeChild(element); | |
} | |
var arr = []; | |
$('tr.riaf-datatable-contents').trigger('click'); | |
$('tr.riaf-datatable-contents').each(function(index) { | |
var vreemdeValuta = $(this).next().find('td.riaf-datatable-details-contents>table>tbody>tr:nth-child(3)>td:nth-child(2)').text(); | |
var datum = $(this).find('td.riaf-datatable-column-date').text(); | |
var partsOfDate = datum.split("-"); | |
var currentLine = { | |
datum: new Date(Number(partsOfDate[2]), Number(partsOfDate[1]) - 1, Number(partsOfDate[0])), | |
amount: $(this).find('td.riaf-datatable-column-amount').text().replace(',','.'), | |
description: $(this).find('td.riaf-datatable-column-text').text(), | |
}; | |
if (vreemdeValuta){ | |
originValueMatch = vreemdeValuta.match(/[0-9]+,[0-9]{2}/); | |
originCurrencyMatch = vreemdeValuta.match(/^[A-Z]+/); | |
if (originValueMatch && originCurrencyMatch){ | |
currentLine.originalValue = originValueMatch ? originValueMatch[0].replace(',','.') : ''; | |
currentLine.originCurrency = originCurrencyMatch[0] || ''; | |
} else { | |
console.log({ | |
originValueMatch, originCurrencyMatch, vreemdeValuta | |
}) | |
} | |
} | |
arr.push(currentLine); | |
}); | |
console.log(arr); | |
download('extract.csv', ConvertToCSV(arr)); |
I have also created a Python tool IngBank2Excel, which allows to create an Excel or CSV file with all credit card transactions, available through the web interface of the ING bank
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script looks like exactly what I need. However, I got an error. May be their page changed?
Is there a newer version? thanks.
/*
Exception: TypeError: $(...) is null
@Scratchpad/4:37:1
*/
current page seems to iterating over