Kundenansicht P6: Team-Endpunkt Stundenkonto mit Vorschuss
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f016d7ae6c
commit
3d4d49de82
2 files changed
+61
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { Router } from 'express'
|
||||
import { config } from '../../config.js'
|
||||
import { listViewLog } from '../../services/customerViewLog.js'
|
||||
import { getLedger } from '../../services/hourLedger.js'
|
||||
import { getPortalAccessStatus } from '../../services/portalAccessStatus.js'
|
||||
import { PRODUCT_KEYS } from '../../services/products.js'
|
||||
import { ACTIVE_STATUSES, getCurrentSubscription } from '../../services/stripeBilling.js'
|
||||
@@ -53,6 +54,30 @@ router.get('/:id/abo', async (req, res) => {
|
||||
}
|
||||
})
|
||||
|
||||
// Stundenkonto fuers Ticketsystem (Abo-Modell der Funktionen): Produkt wie /:id/abo, dazu Guthaben, Vorschuss
|
||||
// (Einrichtung ohne Deckung) und Mehraufwand. Nur das Wartungs-Abo hat ein Konto, auch nach dem Ende
|
||||
// (dann Guthaben 0, der Vorschuss bleibt stehen); Hosting und kein Abo ergeben ledger null
|
||||
router.get('/:id/stundenkonto', async (req, res) => {
|
||||
try {
|
||||
const sub = await getCurrentSubscription(req.params.id)
|
||||
if (!sub) return res.json({ produkt: null, ledger: null })
|
||||
const produkt = PRODUCT_KEYS.includes(sub.productKey) ? sub.productKey : 'wartung'
|
||||
if (produkt !== 'wartung') return res.json({ produkt, ledger: null })
|
||||
const l = await getLedger(req.params.id, { active: ACTIVE_STATUSES.has(sub.status) })
|
||||
return res.json({
|
||||
produkt,
|
||||
ledger: {
|
||||
balanceMinutes: l.balanceMinutes,
|
||||
vorschussMinutes: l.vorschussMinutes,
|
||||
overageMinutes: l.overageMinutes,
|
||||
nextExpiry: l.nextExpiry,
|
||||
},
|
||||
})
|
||||
} catch (err) {
|
||||
return res.status(500).json({ error: err.message || 'Stundenkonto konnte nicht geladen werden' })
|
||||
}
|
||||
})
|
||||
|
||||
// Kundenansicht oeffnen: Einmal-Link (60 s), den das Ticketsystem in einem neuen Tab aufruft
|
||||
router.post('/:id/kundenansicht', async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user