From 248f4a1276ee6eceae69d12042ed2d527c635ab6 Mon Sep 17 00:00:00 2001 From: Özgür Kesim Date: Thu, 28 Nov 2024 11:48:49 +0100 Subject: correction to report --- templates/report.t | 8 ++++---- zeitgeist.go | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/templates/report.t b/templates/report.t index d89b921..c1e470e 100644 --- a/templates/report.t +++ b/templates/report.t @@ -8,13 +8,13 @@ Beneficiary: {{.Beneficiary}}{{- $p := .}} {{range $wp, $t := .Totals }} Total for {{ $wp }}: - Budgeted: {{ printf "%8s" $t.Budgeted.AsDay }} - - Planned: {{ printf "%8s" $t.Planned.AsDay }}{{with $t.Unaccounted }} !Unaccounted: {{.AsDay}}{{end}} + - Planned: {{ printf "%8s" $t.Planned.AsDay }}{{with $t.Unaccounted }} !Unaccounted: {{printf "%8s" .AsDay}}{{end}} - Actual: {{ printf "%8s" $t.Actual.AsDay }} - 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: {{.AsDay}}{{end}} - - Actual: {{ printf "%8s" $tt.Actual.AsDay }} + - Budgeted: {{ printf "%8s" $tt.Budgeted }} + - Planned: {{ printf "%8s" $tt.Planned }}{{with $tt.Unaccounted }} !Unaccounted: {{printf "%8s" .AsDay}}{{end}} + - Actual: {{ printf "%8s" $tt.Actual }} {{ end }} {{ end }} diff --git a/zeitgeist.go b/zeitgeist.go index abcbe52..869d062 100644 --- a/zeitgeist.go +++ b/zeitgeist.go @@ -177,25 +177,25 @@ func (a Date) After(b Date) bool { type Amount float64 const ( - Days Amount = Amount(215) - DaysInMonth = Amount(Days) / 12 - HoursInDay = Amount(8) + DaysInYear = 215 + DaysInMonth = DaysInYear / 12 + HoursInDay = 8 ) func (u Amount) String() string { - d := u / HoursInDay + d := int(u / HoursInDay) m := d / DaysInMonth - h := u - Amount(int(d))*HoursInDay + h := int(u) - d*HoursInDay r := "" - if int(m) > 0 { - r = fmt.Sprintf("%dm", int(m)) + if m != 0 { + r = fmt.Sprintf("%dM", m) d -= DaysInMonth * m } - if int(d) > 0 { - r += fmt.Sprintf("%dd", int(d)) + if d != 0 { + r += fmt.Sprintf("%dd", d) } - if h > 0 { - r += fmt.Sprintf("%dh", int(h)) + if h != 0 { + r += fmt.Sprintf("%dh", h) } return r } @@ -209,7 +209,7 @@ func (b Amount) AsDay() string { } func (b Amount) AsMonth() string { - return fmt.Sprintf("%5.2fm", b/HoursInDay/Amount(DaysInMonth)) + return fmt.Sprintf("%5.2fm", b/HoursInDay/DaysInMonth) } func (u *Amount) UnmarshalText(b []byte) error { @@ -448,7 +448,7 @@ func (p *Project) readPlans(dir string) error { Amount: a, Comment: parts[3]} - entries := p.Timeline[Date(d)] + entries := p.Planned[Date(d)] entries = append(entries, entry) p.Planned[Date(d)] = entries } @@ -796,7 +796,7 @@ type Totals struct { func (t *Totals) Unaccounted() Amount { d := t.Budgeted - t.Planned // TODO: rounding OK!? - if d < 0.01 { + if d*d < 1 { return 0 } return d -- cgit v1.2.3