Vermietungs-Tool
A local web app for a small room-rental business in Austria: guest register, room ledger, occupancy plan, invoices, the monthly tourist-tax report and the quarterly VAT list. Application code only; it ships no data. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
45424e6fd6
47 files changed
+6701
No files matched your search
@@ -0,0 +1,45 @@
|
||||
"""German number/currency formatting for display (1.234,56 €)."""
|
||||
from app import i18n
|
||||
|
||||
|
||||
def de_number(value, decimals=2):
|
||||
if value is None or value == "":
|
||||
return ""
|
||||
formatted = f"{float(value):,.{decimals}f}" # 1,234.56
|
||||
return formatted.replace(",", "\x00").replace(".", ",").replace("\x00", ".")
|
||||
|
||||
|
||||
def euro(value):
|
||||
if value is None or value == "":
|
||||
return ""
|
||||
return f"{de_number(value)} €"
|
||||
|
||||
|
||||
WEEKDAYS = i18n.t("weekdays_short")
|
||||
|
||||
|
||||
def de_date_wd(iso):
|
||||
"""'Mo 13.09.2026' — the weekday before the date, so the lists show at once which day an arrival or
|
||||
departure falls on (weekly prices run from weekday to weekday)."""
|
||||
import datetime
|
||||
text = de_date(iso)
|
||||
if not text:
|
||||
return text
|
||||
try:
|
||||
day = datetime.date.fromisoformat(str(iso)[:10])
|
||||
except ValueError:
|
||||
return text # not a real date (a month name or the like) — leave it as it is
|
||||
# a non-breaking space: on paper the table would otherwise break between weekday and date
|
||||
# ("So" on one line, "13.09.2026" on the next)
|
||||
return f"{WEEKDAYS[day.weekday()]} {text}"
|
||||
|
||||
|
||||
def de_date(iso):
|
||||
"""ISO yyyy-mm-dd -> German dd.mm.yyyy for display."""
|
||||
if not iso:
|
||||
return ""
|
||||
try:
|
||||
y, m, d = str(iso).split("-")
|
||||
return f"{d}.{m}.{y}"
|
||||
except ValueError:
|
||||
return str(iso)
|
||||
Reference in new issue
Block a user