Buchungskalender: Verwaltungs-API – Einstellungen, Zustimmung, Online-Zahlung

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
knsoandClaude Opus 5.5 committed 2026-10-07 14:30:20 +00:00
1 parent d0ab92658a
commit 32cffb3518
5 files changed
+87 -27

No files matched your search

+7
View File
@@ -49,6 +49,11 @@ function fuerFeature(ctx, a) {
return a
}
/** Ohne Rechnungsauftrag (Zustimmung des Vermieters) darf nichts freigegeben oder verbindlich gebucht werden. */
function brauchtZustimmung(ctx) {
if (!ctx?.einstellungen?.rechnungAuftragAt) throw new UkFehler(409, 'zustimmung_fehlt')
}
const text = (v, max) => (typeof v === 'string' ? v.trim().slice(0, max) : '')
const EMAIL_RE = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/
@@ -115,6 +120,7 @@ export async function legeAnfrageAn(ctx, eingabe, { now = new Date(), ipHash = '
export async function gibFrei(ctx, anfrageId, { posten, fristTage, nachricht, now = new Date() } = {}) {
const pre = fuerFeature(ctx, await ladeAnfrage(anfrageId))
brauchtZustimmung(ctx)
const ergebnis = await withLocks(withLocksKey(pre.unterkunftId), async () => {
const a = fuerFeature(ctx, await ladeAnfrage(anfrageId))
if (a.status !== 'neu') throw new UkFehler(409, 'status_ungueltig')
@@ -192,6 +198,7 @@ export async function bucheVerbindlich(ctx, anfrageId, token, { rechnungsadresse
if (a.status === 'gebucht' || a.status === 'bezahlt') {
return { anfrage: a, rechnung: a.rechnungId ? await ladeRechnung(a.rechnungId) : null, neu: false }
}
brauchtZustimmung(ctx)
if (a.status === 'abgelaufen') throw new UkFehler(410, 'frist_abgelaufen')
if (a.status !== 'freigegeben') throw new UkFehler(409, 'status_ungueltig')
if (!(Date.parse(a.fristAt) > ms(now))) throw new UkFehler(410, 'frist_abgelaufen')