From 69f0a3e8ebe620e840b7b49f8103ca41319ac031 Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Thu, 28 Nov 2024 16:36:54 +0100 Subject: count open days --- templates/report.t | 4 ++-- zeitgeist.go | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/templates/report.t b/templates/report.t index b42aabe..9a807e5 100644 --- a/templates/report.t +++ b/templates/report.t @@ -10,12 +10,12 @@ Beneficiary: {{.Beneficiary}} Total for {{ $wp }}: - Budgeted: {{ printf "%8s" $t.Budgeted.AsDay }} - Planned: {{ printf "%8s" $t.Planned.AsDay }}{{with $t.Unaccounted }} !Unaccounted: {{printf "%8s" .AsDay}}{{end}} - - Actual: {{ printf "%8s" $t.Actual.AsDay }} + - Actual: {{ printf "%8s" $t.Done.AsDay }}{{with $t.Open }} !TODO: {{printf "%8s" .AsDay }}{{end}} - Per Task: {{- range $n, $t := (index $p.Workpackages $wp).Tasks }} - {{ $t.ID }} ({{ $n }}):{{ $tt := $p.TotalWPTask $wp $n }} - Budgeted: {{ printf "%8s" $tt.Budgeted.AsDay }} - Planned: {{ printf "%8s" $tt.Planned.AsDay }}{{with $tt.Unaccounted }} !Unaccounted: {{printf "%8s" .AsDay}}{{end}} - - Actual: {{ printf "%8s" $tt.Actual.AsDay }} + - Actual: {{ printf "%8s" $tt.Done.AsDay }}{{with $tt.Open }} !TODO: {{printf "%8s" .AsDay}}{{end}} {{ end }} {{ end }} diff --git a/zeitgeist.go b/zeitgeist.go index 32d8fd6..643f0e2 100644 --- a/zeitgeist.go +++ b/zeitgeist.go @@ -811,7 +811,7 @@ func (p *Project) Calendars() map[int]string { type Totals struct { Budgeted Amount Planned Amount - Actual Amount + Done Amount } type WPTotals struct { @@ -828,6 +828,15 @@ func (t *Totals) Unaccounted() Amount { return d } +func (t *Totals) Open() Amount { + d := t.Budgeted - t.Done + // TODO: rounding OK!? + if d*d < 1 { + return 0 + } + return d +} + func (p *Project) TotalWPTask(wp, task string) (to *Totals, e error) { w, ok := p.Workpackages[wp] if !ok { @@ -840,7 +849,7 @@ func (p *Project) TotalWPTask(wp, task string) (to *Totals, e error) { to = &Totals{ Budgeted: t.Budget, Planned: p.Planned.FilterWPTask(wp, task).Total(), - Actual: p.Timeline.FilterWPTask(wp, task).Total(), + Done: p.Timeline.FilterWPTask(wp, task).Total(), } return to, nil } @@ -853,7 +862,7 @@ func (p *Project) TotalWP(name string) (t *Totals, e error) { t = &Totals{ Budgeted: wp.TotalBudget(), Planned: p.Planned.FilterWP(name).Total(), - Actual: p.Timeline.FilterWP(name).Total(), + Done: p.Timeline.FilterWP(name).Total(), } return t, nil } -- cgit v1.2.3