diff options
| author | Özgür Kesim <oec@codeblau.de> | 2024-12-03 17:50:03 +0100 | 
|---|---|---|
| committer | Özgür Kesim <oec@codeblau.de> | 2024-12-03 17:50:03 +0100 | 
| commit | ddbc2e9f4ac0940ca08e430d64bb0b1697b609da (patch) | |
| tree | 25c9fc641ae9ca0bbabeea55ce0634a6cf171597 | |
| parent | b309f277eb32a5dda0120f274e153a010806a91a (diff) | |
added percentage and diffmain
| -rw-r--r-- | templates/status.md | 27 | ||||
| -rw-r--r-- | templates/wp-total.md | 22 | ||||
| -rw-r--r-- | zeitgeist.go | 25 | 
3 files changed, 52 insertions, 22 deletions
diff --git a/templates/status.md b/templates/status.md index 375058f..c67f071 100644 --- a/templates/status.md +++ b/templates/status.md @@ -6,19 +6,30 @@ Beneficiary: {{.Beneficiary}}  {{- $p := . }}  {{- $start := ParseDate "2023-12-01" }}  {{- $end := ParseDate "2024-11-30" }} -{{- $totals := .Totals $start $end }} +{{- $totals := .Totals }}  # Status, as of {{.Today}}  ```   Planned : {{ printf "%8s" $totals.Planned }}{{with $totals.Unaccounted}}   ! Open !: {{ printf "%8s" . }}{{end}} -    Done : {{ printf "%8s" $totals.Done }}{{ with $totals.Open }} - ! Todo !: {{ printf "%8s" . }} +    Done : {{ printf "%8s" $totals.Done.AsMonth }} +           {{ printf "  %5.2f%%" $totals.Percent }} +    Diff : {{ printf "%8s" $totals.Difference.AsMonth }}{{with $totals.Open }} + ! Todo !: {{ printf "%8s" .AsMonth }}  Time left: {{ printf "%8s" ($p.AsDaysAmount (len $p.DaysRemaining)) }} * {{len $p.Users}}{{end}}  ```  ## Overview of WP Status + +``` +{{- range .ParallelWPTotals  }} +{{.}} +{{- end}} +``` + +## Overview of WP Status +  {{range $wp, $t := $totals.WP }}  Total for {{ $wp }}:   - Budgeted: {{ printf "%8s" $t.Budgeted.AsDay }} @@ -26,17 +37,9 @@ Total for {{ $wp }}:   - Actual:   {{ printf "%8s" $t.Done.AsDay }} ({{ printf "%5.2f%%" $t.Percent }}){{with $t.Open }}   !Todo!: {{printf "%8s" .AsDay }}{{end}}   - Per Task:    {{- range $n, $t := $t.Tasks }} -    - {{ $n }}:{{ $tt := $p.TotalWPTask $wp $n $start $end }} +    - {{ $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.Done.AsDay }} ({{ printf "%5.2f%%" $t.Percent }}){{with $tt.Open }}   !Todo!: {{printf "%8s" .AsDay}}{{end}}    {{ end }}  {{ end }} - -## Overview of WP Status - -``` -{{- range .ParallelWPTotals  }} -{{.}} -{{- end}} -``` diff --git a/templates/wp-total.md b/templates/wp-total.md index c664634..8b30eca 100644 --- a/templates/wp-total.md +++ b/templates/wp-total.md @@ -1,18 +1,20 @@  Total for {{ .WP }}:  ------------------- -Budgeted : {{ printf "%8s" .Budgeted.AsDay }} - Planned : {{ printf "%8s" .Planned.AsDay }}{{with .Unaccounted }} - ! Open !: {{ printf "%8s" .AsDay}}{{end}} -    Done : {{ printf "%8s" .Done.AsDay }}{{with .Open }} - ! Todo !: {{ printf "%8s" .AsDay }}{{end}} +Budgeted : {{ printf "%8s" .Budgeted.AsMonth }} + Planned : {{ printf "%8s" .Planned.AsMonth }}{{with .Unaccounted }} + ! Open !: {{ printf "%8s" .AsMonth}}{{end}} +    Done : {{ printf "%8s" .Done.AsMonth }} +           {{ printf "  %5.2f%%" .Percent }} +    Diff : {{ printf "%8s" .Difference.AsMonth }}{{with .Open }} + ! Todo !: {{ printf "%8s" .AsMonth }}{{end}}  Per Task:  {{- range $n, $t := .Tasks }}  »{{ $n }}«: -Budgeted : {{ printf "%8s" $t.Budgeted.AsDay }} - Planned : {{ printf "%8s" $t.Planned.AsDay }}{{with $t.Unaccounted }} - ! Open !: {{ printf "%8s" .AsDay}}{{end}} -    Done : {{ printf "%8s" $t.Done.AsDay }}{{with $t.Open }} - ! Todo !: {{ printf "%8s" .AsDay}}{{end}} +Budgeted : {{ printf "%8s" $t.Budgeted.AsMonth }} + Planned : {{ printf "%8s" $t.Planned.AsMonth }}{{with $t.Unaccounted }} + ! Open !: {{ printf "%8s" .AsMonth}}{{end}} +    Done : {{ printf "%8s" $t.Done.AsMonth }}{{with $t.Open }} + ! Todo !: {{ printf "%8s" .AsMonth}}{{end}}  {{- end }}
\ No newline at end of file diff --git a/zeitgeist.go b/zeitgeist.go index 2e99d91..a44f25c 100644 --- a/zeitgeist.go +++ b/zeitgeist.go @@ -644,6 +644,27 @@ var funcs = template.FuncMap{  		d, e := time.Parse(time.DateOnly, in)  		return Date(d), e  	}, +	"Percent": func(a, b Amount) float64 { +		return float64(a/b) * 100 +	}, +	"AsDay": func(a Amount) string { +		return a.AsDay() +	}, +	"AsMonth": func(a Amount) string { +		return a.AsMonth() +	}, +	"Unit": func(unit string, a Amount) (string, error) { +		switch unit { +		case "M", "m": +			return a.AsMonth(), nil +		case "D", "d": +			return a.AsDay(), nil +		case "H", "h": +			return a.String(), nil +		default: +			return "", fmt.Errorf("unknown unit %q", unit) +		} +	},  }  func (p *Project) printReport(name string) { @@ -960,6 +981,10 @@ func (t *Totals) Open() Amount {  	return d  } +func (t *Totals) Difference() Amount { +	return t.Planned - t.Done +} +  func (t *Totals) Percent() float64 {  	if t.Done < 1 && t.Planned < 1 {  		return 0  | 
