infoalloggi-monorepo/apps/infoalloggi/typst/utils.typ

16 lines
467 B
Typst
Raw Normal View History

#import "@preview/oxifmt:1.0.0": strfmt
#let format-price(cents) = {
// Handle case where cents might be null or not a number
if cents == none { return "0,00 €" }
let euros = int(cents / 100)
let decimal = calc.rem(cents, 100)
// Create the decimal string and pad with a leading zero if needed (e.g., 5 cents -> "05")
let decimal-str = if decimal < 10 { "0" + str(decimal) } else { str(decimal) }
return str(euros) + "," + decimal-str + " €"
}