Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@leandrocrs
Last active February 8, 2021 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leandrocrs/b67b8bed070983f1f47f0679630118e5 to your computer and use it in GitHub Desktop.
Save leandrocrs/b67b8bed070983f1f47f0679630118e5 to your computer and use it in GitHub Desktop.
mobills - exportar transações como CSV
/**
* @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