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

View file

@ -5,35 +5,27 @@
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 {
"0." + j.slice(-2) + "€"
} else {
j.slice(0,-2)+ "." + j.slice(-2) + "€"
}
str(d).slice(0, -1) + "€"
}
#let common(title: none, doc) = {
set document(
title: title,
author: "swablab e.V."
author: "swablab e.V.",
)
set text(
font: "Noto Sans",
size: 11pt,
lang: "de"
lang: "de",
)
set par(
justify: true
)
set par(justify: true)
set page(
paper: "a4",
@ -41,6 +33,6 @@
)
show link: underline
doc
}
}