Last active
February 8, 2021 12:20
-
-
Save leandrocrs/b67b8bed070983f1f47f0679630118e5 to your computer and use it in GitHub Desktop.
mobills - exportar transações como CSV
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
/** | |
* @author Leandro Cavalcante (@leandrocrs) | |
* Copiar o trecho abaixo e colar no console do navegador, na página de transações | |
*/ | |
(() => { | |
const result = $r.props.store | |
.getState() | |
.transactions.movimentacoes.filter((m) => m.conta != null) | |
.map((m) => { | |
return { | |
descricao: `"${m.descricao}"`, | |
conta: m.conta.nome, | |
dataMovimentacao: m.dataMovimentacao, | |
observacao: `"${m.observacao}"`, | |
tags: `"${(m.tags || []).map((t) => t.nome).join(",")}"`, | |
categoria: | |
m.tipoDespesa != null ? m.tipoDespesa.nome : m.tipoReceita.nome, | |
valor: m.valor, | |
}; | |
}); | |
console.log("result: ", result); | |
const header = Object.keys(result[0]).join(","); | |
const rows = result.map((m) => Object.values(m).join(",")); | |
const csvData = [].concat(header, rows).join("\n"); | |
console.log("CSV: ", csvData); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment