go #49
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user