feature: simplify money
All checks were successful
deploy / deploy (push) Successful in 12s

This commit is contained in:
ndsboy 2025-04-30 19:13:56 +00:00
parent d7f8f441fd
commit 4548890ec8
2 changed files with 39 additions and 35 deletions

View file

@ -8,7 +8,7 @@
invoice: "Rechnung", invoice: "Rechnung",
offer: "Angebot", offer: "Angebot",
estimate: "Kostenvoranschlag", estimate: "Kostenvoranschlag",
internal: "Eigenbeleg" internal: "Eigenbeleg",
).at(config.type), ).at(config.type),
address: config.address, address: config.address,
info: [ info: [
@ -31,7 +31,7 @@
*Grund für Eigenbeleg:* \ *Grund für Eigenbeleg:* \
#config.internal_reason #config.internal_reason
] ]
#text(size: 0.7em, fill: colors.subtext)[ #text(size: 0.7em, fill: colors.subtext)[
#if config.type == "invoice" [ #if config.type == "invoice" [
Gesamtbetrag fällig in 10 Tagen ab Rechnungserhalt. \ Gesamtbetrag fällig in 10 Tagen ab Rechnungserhalt. \
@ -51,7 +51,7 @@
Bitte nutze deine Rechnungs-Nr. als Verwendungszweck für die Überweisung! Bitte nutze deine Rechnungs-Nr. als Verwendungszweck für die Überweisung!
] ]
#table( #table(
columns: (auto, 1fr, auto, auto, auto ,auto), columns: (auto, 1fr, auto, auto, auto, auto),
fill: (_, row) => if row == 0 { colors.highlight } else { white }, fill: (_, row) => if row == 0 { colors.highlight } else { white },
stroke: 0.1pt + colors.subtext, stroke: 0.1pt + colors.subtext,
[*Pos.*], [*Pos.*],
@ -60,18 +60,23 @@
[*Einzelpreis*], [*Einzelpreis*],
[*Rabatt*], [*Rabatt*],
[*Betrag*], [*Betrag*],
..config.entries.enumerate().map(e => ( ..config
e.at(0)+1, .entries
e.at(1).description, .enumerate()
e.at(1).pieces, .map(e => (
money(e.at(1).price), e.at(0) + 1,
money(e.at(1).sale), e.at(1).description,
money(e.at(1).pieces * e.at(1).price - e.at(1).sale), e.at(1).pieces,
)).flatten().map(e => [#e]), money(e.at(1).price),
money(e.at(1).sale),
money(e.at(1).pieces * e.at(1).price - e.at(1).sale),
))
.flatten()
.map(e => [#e]),
) )
#align(right)[ #align(right)[
#pad(x:1em)[ #pad(x: 1em)[
*Gesamtbetrag: #money(config.entries.map(e => e.pieces * e.price - e.sale).sum())* *Gesamtbetrag: #money(config.entries.map(e => e.pieces * e.price - e.sale).sum())*
] ]
] ]
@ -82,12 +87,19 @@
#block( #block(
stroke: 1pt, stroke: 1pt,
inset: 1em, inset: 1em,
radius: 1em radius: 1em,
)[ )[
#qr-code("BCD\n002\n1\nSCT\n\nswablab e.V.\nDE18603913100125634005\nEUR" + str(config.entries.map(e => e.pieces * e.price - e.sale).sum()) + "\nGDDS\n\nRechnung " + str(config.invoice_no) + "\nswablab Rechnung", width: 2cm) #qr-code(
"BCD\n002\n1\nSCT\n\nswablab e.V.\nDE18603913100125634005\nEUR"
#place(center+bottom, dy: 1.1em)[ + str(config.entries.map(e => e.pieces * e.price - e.sale).sum())
#block(width: 100%+0.75em, fill: white)[ + "\nGDDS\n\nRechnung "
+ str(config.invoice_no)
+ "\nswablab Rechnung",
width: 2cm,
)
#place(center + bottom, dy: 1.1em)[
#block(width: 100% + 0.75em, fill: white)[
#text(size: 8pt)[ #text(size: 8pt)[
Zahlen mit Code Zahlen mit Code
] ]
@ -95,4 +107,4 @@
] ]
] ]
] ]
] ]

View file

@ -5,35 +5,27 @@
highlight: oklch(90%, 0, 0deg), highlight: oklch(90%, 0, 0deg),
) )
#let money(i) = {
if i == 0 {
return "0.00€"
}
let j = str(calc.round(i * 100)) #let money(d) = {
d = calc.round(d, digits: 2)
d += decimal("0.001")
if i < 1 { str(d).slice(0, -1) + "€"
"0." + j.slice(-2) + "€"
} else {
j.slice(0,-2)+ "." + j.slice(-2) + "€"
}
} }
#let common(title: none, doc) = { #let common(title: none, doc) = {
set document( set document(
title: title, title: title,
author: "swablab e.V." author: "swablab e.V.",
) )
set text( set text(
font: "Noto Sans", font: "Noto Sans",
size: 11pt, size: 11pt,
lang: "de" lang: "de",
) )
set par( set par(justify: true)
justify: true
)
set page( set page(
paper: "a4", paper: "a4",
@ -41,6 +33,6 @@
) )
show link: underline show link: underline
doc doc
} }