- Add new page for managing Stripe reports with functionality to generate and view reports. - Create API router for handling Stripe report operations including listing, setting up, and generating reports. - Introduce caching service for managing cache invalidation related to reports. - Update Typst templates for formatting financial reports in EUR. - Enhance utility functions for price formatting and error handling. - Implement a script to check for unused tRPC procedures in the codebase.
38 lines
1 KiB
Typst
38 lines
1 KiB
Typst
#import "@preview/oxifmt:1.0.0": strfmt
|
|
|
|
|
|
|
|
|
|
#let format-eur(cents) = {
|
|
// 1. Gestione del segno
|
|
let is-negative = cents < 0
|
|
let abs-cents = calc.abs(cents)
|
|
|
|
// 2. Calcolo parte intera e frazionaria
|
|
// Usiamo calc.round per sicurezza se l'input non fosse un intero puro
|
|
let total-abs = calc.round(abs-cents)
|
|
let whole = calc.trunc(total-abs / 100)
|
|
let frac = calc.rem(total-abs, 100)
|
|
|
|
// 3. Formattazione Migliaia (punti)
|
|
let chars = str(whole).clusters()
|
|
let formatted-whole = ""
|
|
let count = 0
|
|
for c in chars.rev() {
|
|
if count > 0 and calc.rem(count, 3) == 0 {
|
|
formatted-whole = "." + formatted-whole
|
|
}
|
|
formatted-whole = c + formatted-whole
|
|
count += 1
|
|
}
|
|
|
|
// 4. Formattazione Centesimi (sempre 2 cifre)
|
|
// Usiamo lo zero-padding per casi come 5 centesimi -> "05"
|
|
let frac-str = if frac < 10 { "0" + str(frac) } else { str(frac) }
|
|
|
|
// 5. Output finale
|
|
let sign = if is-negative { "-" } else { "" }
|
|
|
|
// Ritorna il testo formattato
|
|
[#sign #formatted-whole,#frac-str €]
|
|
}
|