-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
executable file
·36 lines (28 loc) · 1.04 KB
/
index.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
const Auth = require('./components/auth.js');
const CliReport = require('./components/cliReport.js');
const Invoices = require('./components/invoices.js');
const TimeEntries = require('./components/timeEntries.js');
(async () => {
// authenticate
await CliReport.start();
const auth = await Auth.logIn();
const {page, browser} = auth;
// get data
const invoiceSheet = await Invoices.getInvoices(browser, page);
const timeSheet = await TimeEntries.getTimeEntries(browser, page);
// get all incoices that are due
const dueInvoices = await Invoices.sum(invoiceSheet, 'outstanding');
// get all invoices that will be sent
const draftedInvoices = await Invoices.sum(invoiceSheet, 'drafted');
// get time from timetrackers that is not on any invoice yet
const unbilledAndNoInvoiceAmount = await TimeEntries.sumUnbilledIncome(timeSheet, false);
// show data
await CliReport.report(
dueInvoices,
draftedInvoices,
unbilledAndNoInvoiceAmount
);
// logout
await Auth.logOut(browser);
await CliReport.stop();
})();