-
Notifications
You must be signed in to change notification settings - Fork 0
/
content_nel_extrato.js
43 lines (38 loc) · 1.39 KB
/
content_nel_extrato.js
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
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
getData();
sendResponse();
}
);
function getData() {
var tds, detail, type, client, date, doc, description, amount, charges_array;
charges_array = [
["Tipo", "Quantia", "Data", "Mês de Competência", "Descrição", "Documento", "Categoria", "Cliente / Fornecedor", "Centro de Custo / Receita", "Transferência para", "Produto", "Região"]
];
$('#RetornoConsulta tbody tr').each(function(index) {
tds = $(this).children();
date = tds[0].textContent.trim();
detail = $(tds).eq(1).children('span').children('span.TextoDetalheTransferenciaExtrato')
client = ""
if (detail.length > 0) {
client = $(detail)[0].textContent.trim();
}
description = tds[1].textContent.replace(client, "").trim();
doc = tds[2].textContent.trim();
amount = amountFormat(tds[3].textContent.trim());
if (amount > 0) {
type = "Crédito";
} else {
type = "Débito";
}
charges_array.push([type, amount, date, "", description, doc, "", client, "Banco do Nordeste", "", "", ""]);
});
var wb = XLSX.utils.book_new(),
ws = XLSX.utils.aoa_to_sheet(charges_array);
XLSX.utils.book_append_sheet(wb, ws, "Extrato");
XLSX.writeFile(wb, "Extrato_NEL.xls");
}
function amountFormat(amount) {
var value = amount.replace(/[^0-9-,]/g, '').replace(",", ".");
return value * 1;
}