diff --git a/services/templater.go b/services/templater.go index 8feefec..c1178c4 100644 --- a/services/templater.go +++ b/services/templater.go @@ -7,6 +7,7 @@ import ( "fmt" "html/template" "image/png" + "strings" "git.odit.services/lfk/document-server/templates" "github.com/boombuler/barcode" @@ -91,14 +92,16 @@ func (t *DefaultTemplater) SelectSponsorImage(id int) (string, error) { } func FormatUnit(unit string, amount int) (string, error) { + var formatted string switch unit { case "kilometer": - return fmt.Sprintf("%.3f", float64(amount)/1000), nil + formatted = fmt.Sprintf("%.3f", float64(amount)/1000) case "euro": - return fmt.Sprintf("%.2f", float64(amount)/100), nil + formatted = fmt.Sprintf("%.2f", float64(amount)/100) default: return "", errors.New("unknown unit") } + return strings.Replace(formatted, ".", ",", -1), nil } func (t *DefaultTemplater) StringToTemplate(templateString string) (*template.Template, error) {