SHARE
TWEET

Untitled

a guest Jul 16th, 2019 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const { createInvoice } = require("./createInvoice.js");
  2.  
  3. var axios = require('axios');
  4.  
  5. var invoiceUrl = process.argv[2];
  6. // invoiceUrl = 'https://aod.eazybi.com/accounts/30271/export/report/230227.csv?embed_token=gyhm3p40jdgb5y2zf9ai6m2tq4vl3gvz0nuiadare1lbbk2qry99ul7774ej'
  7.  
  8. axios
  9.     .get(invoiceUrl)
  10.     .then(response => {
  11.  
  12.         var lines = response.data.split(/\r\n|\n/);
  13.         for(var i=0; i<lines.length; i++) {
  14.             lines[i] = lines[i].split(',');
  15.         }
  16.  
  17.         const invoice = {
  18.           shipping: {
  19.             name: lines[1][0],
  20.               address: "1234 Main Street",
  21.               city: "San Francisco",
  22.               state: "CA",
  23.               country: "US",
  24.               postal_code: 94111
  25.           },
  26.           items: [],
  27.           subtotal: 0,
  28.           paid: 0,
  29.           invoice_nr: 0
  30.         };
  31.  
  32.         for(var i=1; i<(lines.length-1); i++) {
  33.             invoice.items.push({
  34.               resumo: lines[i][1],
  35.               solicitante: lines[i][2],
  36.               dataResolucao: lines[i][3],
  37.               horasFaturadas: lines[i][4]
  38.             })
  39.         }
  40.         createInvoice(invoice, "invoice.pdf");
  41.     });
  42.  
  43. var resumoUrl = process.argv[3];
  44. // resumoUrl = 'https://aod.eazybi.com/accounts/30271/export/report/230227.csv?embed_token=gyhm3p40jdgb5y2zf9ai6m2tq4vl3gvz0nuiadare1lbbk2qry99ul7774ej'
  45. axios
  46.     .get(resumoUrl)
  47.     .then(response => {
  48.  
  49.         var lines = response.data.split(/\r\n|\n/);
  50.         for(var i=0; i<lines.length; i++) {
  51.             lines[i] = lines[i].split(',');
  52.         }
  53.  
  54.         const resumo = {
  55.             shipping: {
  56.               name: lines[1][0],
  57.                 address: "1234 Main Street",
  58.                 city: "San Francisco",
  59.                 state: "CA",
  60.                 country: "US",
  61.                 postal_code: 94111
  62.             },
  63.             items: [],
  64.             subtotal: 0,
  65.             paid: 0,
  66.             invoice_nr: 0
  67.         };
  68.  
  69.         for(var i=1; i<(lines.length-1); i++) {
  70.             resumo.items.push({
  71.               contratoHoras: lines[i][1],
  72.               horasFaturadas: lines[i][2],
  73.               contratoValor: lines[i][3],
  74.               contratoValorExcedente: lines[i][4],
  75.               valorTotal: lines[i][5]
  76.             })
  77.         }
  78.         createInvoice(resumo, "resumo.pdf");
  79.     });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top