fix(services): Updated templater comma logic

This commit is contained in:
Nicolai Ort 2024-12-09 17:03:13 +01:00
parent 692f378eab
commit af73b35b18
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F

View File

@ -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) {