From af73b35b1865995143e4e42600166ab5d4972f89 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Mon, 9 Dec 2024 17:03:13 +0100 Subject: [PATCH] fix(services): Updated templater comma logic --- services/templater.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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) {