From 6f24ba34579fa32dcd02c6f0af754c1c424ca00c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sun, 28 Feb 2021 12:55:01 +0100 Subject: [PATCH 1/2] added: spent free options --- documentation.md | 5 +++++ src/output/base.js | 17 ++++++++++++++++- src/output/invoice.js | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/documentation.md b/documentation.md index fabfb2d..3212ed1 100644 --- a/documentation.md +++ b/documentation.md @@ -616,6 +616,11 @@ includeLabels: - pending - approved +# labels free of charge +freeLabels: + - at no charge + - free + # Only works if using a local configuration file! # Extend the global configuration if set to true, pass a string to extend # the configuration file stored at the given path diff --git a/src/output/base.js b/src/output/base.js index 86f91c7..04613d6 100755 --- a/src/output/base.js +++ b/src/output/base.js @@ -100,10 +100,13 @@ class base { let totalEstimate = 0; let totalSpent = 0; let spent = 0; + let spentFree = 0; let users = {}; let projects = {}; let times = []; + let spentFreeLabels = this.config.get('freeLabels'); + ['issues', 'mergeRequests'].forEach(type => { this.report[type].forEach(issue => { issue.times.forEach(time => { @@ -114,6 +117,16 @@ class base { projects[time.project_namespace] += time.seconds; spent += time.seconds; + //if(time.parent.labels) + let free = false; + time.parent.labels.forEach(label => { + spentFreeLabels.forEach(freeLabel => { + free |= (freeLabel == label); + }); + }); + if(free) { + spentFree += time.seconds; + } times.push(time); }); @@ -141,10 +154,12 @@ class base { this.stats = { 'total estimate': this.config.toHumanReadable(totalEstimate, 'stats'), 'total spent': this.config.toHumanReadable(totalSpent, 'stats'), - 'spent': this.config.toHumanReadable(spent, 'stats') + 'spent': this.config.toHumanReadable(spent, 'stats'), + 'spent free': this.config.toHumanReadable(spentFree, 'stats'), }; this.totalEstimate = totalEstimate; this.spent = spent; + this.spentFree = spentFree; this.totalSpent = totalSpent; } diff --git a/src/output/invoice.js b/src/output/invoice.js index 04825bf..dec18bf 100644 --- a/src/output/invoice.js +++ b/src/output/invoice.js @@ -19,7 +19,7 @@ class invoice extends Base { this.invoiceCurrencyPerHour = this.config.get('invoiceCurrencyPerHour'); this.invoiceVAT = this.config.get('invoiceVAT'); this.invoiceCurrencyMaxUnit = this.config.get('invoiceCurrencyMaxUnit'); - this.totalhForInvoice = this.spent / 3600.0; + this.totalhForInvoice = (this.spent-this.spentFree) / 3600.0; this.totalForInvoiceExkl = this.totalhForInvoice * this.invoiceCurrencyPerHour; this.totalForInvoiceMwst = this.totalForInvoiceExkl * this.invoiceVAT; this.totalForInvoice = this.totalForInvoiceExkl + this.totalForInvoiceMwst; From fec31d3ee390068e990017e32c6a75f39fb96d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Sun, 28 Feb 2021 13:01:18 +0100 Subject: [PATCH 2/2] fixed: check for undefined on freeLabels, if config missing, todo should include proper in config --- src/output/base.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/output/base.js b/src/output/base.js index 04613d6..b1bdd2f 100755 --- a/src/output/base.js +++ b/src/output/base.js @@ -106,6 +106,9 @@ class base { let times = []; let spentFreeLabels = this.config.get('freeLabels'); + if(undefined === spentFreeLabels) { + spentFreeLabels = []; + } ['issues', 'mergeRequests'].forEach(type => { this.report[type].forEach(issue => {