Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
added: spent free options
  • Loading branch information
Andreas Müller committed Feb 28, 2021
commit 6f24ba34579fa32dcd02c6f0af754c1c424ca00c
5 changes: 5 additions & 0 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 16 additions & 1 deletion src/output/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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);
});

Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/output/invoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down