Buchungskalender: Team-API wie Webshop (anfrage null, Stripe-Status)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9d01d38a45
commit
35b0438d00
4 files changed
+33
-9
No files matched your search
@@ -30,7 +30,8 @@ async function zaehle(collection, queries, was) {
|
||||
}
|
||||
}
|
||||
|
||||
const stripeZustand = (einst) => (!einst?.stripeAccountId ? 'keins' : einst.stripeStatus?.charges_enabled === true ? 'aktiv' : 'onboarding')
|
||||
/** stripeStatus (JSON-Objekt in ukEinstellungen, schon geparst) oder null. */
|
||||
const stripeStatus = (roh) => (roh !== null && typeof roh === 'object' && !Array.isArray(roh) ? roh : null)
|
||||
|
||||
async function projektStand(project, feature) {
|
||||
let einst = null
|
||||
@@ -53,8 +54,8 @@ async function projektStand(project, feature) {
|
||||
projectId: project.$id,
|
||||
name: project.projectName || '',
|
||||
state: feature?.state || 'off',
|
||||
anfrage: anfrageAnsichtTeam(einst),
|
||||
stripe: { status: stripeZustand(einst) },
|
||||
anfrage: einst?.anfrageStatus ? anfrageAnsichtTeam(einst) : null,
|
||||
stripe: { accountId: Boolean(einst?.stripeAccountId), status: stripeStatus(einst?.stripeStatus) },
|
||||
unterkuenfte,
|
||||
offeneAnfragen,
|
||||
}
|
||||
|
||||
@@ -234,7 +234,12 @@ router.get('/status', route(async (req, res) => {
|
||||
const antwort = { state, stripe: { status: 'keins', vorhandenesShopKonto: false }, onlineZahlung: false, unterkuenfte: 0, rechnungenVorhanden: false }
|
||||
if (state === 'off') {
|
||||
// Anfrage der Funktion: offen | abgelehnt | angenommen (zurueckgezogen und keine zaehlen als keine)
|
||||
const ansicht = doc ? funktionAnfrageAnsicht(await sp.ladeEinstellungen(doc.$id)) : null
|
||||
let ansicht = null
|
||||
try {
|
||||
ansicht = doc ? funktionAnfrageAnsicht(await sp.ladeEinstellungen(doc.$id)) : null
|
||||
} catch (err) {
|
||||
console.warn(`[unterkunft] Anfrage im Status nicht lesbar: ${err?.message}`)
|
||||
}
|
||||
antwort.anfrage = ansicht && ansicht.status !== 'zurueckgezogen' ? ansicht : null
|
||||
return res.json(antwort)
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ export async function entscheideAnfrage({ customerId, projectId, entscheidung, b
|
||||
throw err?.status === 400 && err.type ? stop(403, 'Kein Zugriff auf dieses Projekt') : err
|
||||
}
|
||||
const feature = await getFeatureDoc(customerId, projectId, 'unterkunft')
|
||||
if (!feature) throw stop(409, MELDUNG.nichtEntscheidbar, 'nicht_offen')
|
||||
if (!feature || feature.state !== 'off') throw stop(409, MELDUNG.nichtEntscheidbar, 'nicht_offen')
|
||||
const neu = await withLocks([`uk-einst:${feature.$id}`], async () => {
|
||||
const einst = await ladeEinstellungen(feature.$id)
|
||||
if (!einst || einst.anfrageStatus !== 'offen') throw stop(409, MELDUNG.nichtEntscheidbar, 'nicht_offen')
|
||||
|
||||
Reference in new issue
Block a user