Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const { createInvoice } = require("./createInvoice.js");
- var axios = require('axios');
- var invoiceUrl = process.argv[2];
- // invoiceUrl = 'https://aod.eazybi.com/accounts/30271/export/report/230227.csv?embed_token=gyhm3p40jdgb5y2zf9ai6m2tq4vl3gvz0nuiadare1lbbk2qry99ul7774ej'
- axios
- .get(invoiceUrl)
- .then(response => {
- var lines = response.data.split(/\r\n|\n/);
- for(var i=0; i<lines.length; i++) {
- lines[i] = lines[i].split(',');
- }
- const invoice = {
- shipping: {
- name: lines[1][0],
- address: "1234 Main Street",
- city: "San Francisco",
- state: "CA",
- country: "US",
- postal_code: 94111
- },
- items: [],
- subtotal: 0,
- paid: 0,
- invoice_nr: 0
- };
- for(var i=1; i<(lines.length-1); i++) {
- invoice.items.push({
- resumo: lines[i][1],
- solicitante: lines[i][2],
- dataResolucao: lines[i][3],
- horasFaturadas: lines[i][4]
- })
- }
- createInvoice(invoice, "invoice.pdf");
- });
- var resumoUrl = process.argv[3];
- // resumoUrl = 'https://aod.eazybi.com/accounts/30271/export/report/230227.csv?embed_token=gyhm3p40jdgb5y2zf9ai6m2tq4vl3gvz0nuiadare1lbbk2qry99ul7774ej'
- axios
- .get(resumoUrl)
- .then(response => {
- var lines = response.data.split(/\r\n|\n/);
- for(var i=0; i<lines.length; i++) {
- lines[i] = lines[i].split(',');
- }
- const resumo = {
- shipping: {
- name: lines[1][0],
- address: "1234 Main Street",
- city: "San Francisco",
- state: "CA",
- country: "US",
- postal_code: 94111
- },
- items: [],
- subtotal: 0,
- paid: 0,
- invoice_nr: 0
- };
- for(var i=1; i<(lines.length-1); i++) {
- resumo.items.push({
- contratoHoras: lines[i][1],
- horasFaturadas: lines[i][2],
- contratoValor: lines[i][3],
- contratoValorExcedente: lines[i][4],
- valorTotal: lines[i][5]
- })
- }
- createInvoice(resumo, "resumo.pdf");
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement