Übernahmegutschrift: Verrechnung nach Wechsel, Mail K09, Leitfaden, Admin zeigt das Abo, Tests
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
0c2e50fc20
commit
e456c3de69
9 files changed
+80
-23
No files matched your search
@@ -6,7 +6,7 @@ import { domainToASCII, domainToUnicode } from 'node:url'
|
||||
import { config } from '../config.js'
|
||||
import { createDocument, getDocument, listDocuments, Query, updateDocument } from './appwriteAdmin.js'
|
||||
import { sendAdminNotice, sendCustomerMail } from './mailer.js'
|
||||
import { getProduct } from './products.js'
|
||||
import { getProduct, PRODUCT_KEYS } from './products.js'
|
||||
import { ACTIVE_STATUSES, getCurrentSubscription, getStripe, isStripeConfigured } from './stripeBilling.js'
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ export const STATUS = {
|
||||
export const SERVICE_LABELS = {
|
||||
domain: 'Domain',
|
||||
hosting: 'Hosting / Website-Betrieb',
|
||||
email: 'E-Mail-Postfach',
|
||||
email: 'E-Mail-Postfächer',
|
||||
sonstiges: 'Sonstiges',
|
||||
}
|
||||
|
||||
@@ -349,6 +349,8 @@ function withHistory(doc, entry) {
|
||||
|
||||
const serviceStartOf = (sub) => sub?.trialEnd || sub?.startedAt || null
|
||||
const isActiveSub = (sub) => Boolean(sub && ACTIVE_STATUSES.has(sub.status))
|
||||
// Produkt des Abos: Altbestand ohne productKey und unbekannte Schluessel gelten als Wartungs-Abo
|
||||
const productKeyOf = (sub) => (PRODUCT_KEYS.includes(sub?.productKey) ? sub.productKey : 'wartung')
|
||||
|
||||
export async function getTakeoverRequest(id) {
|
||||
return getDocument(COLLECTION(), id)
|
||||
@@ -638,9 +640,9 @@ export async function runAutoChecks(doc, { allRequests, subscription, calc }) {
|
||||
)
|
||||
}
|
||||
|
||||
// Plausibilitaet gegen die Monatsgebuehr des Abos des Kunden; Abos ohne productKey (Altbestand) gelten als Wartungs-Abo
|
||||
// Plausibilitaet gegen die Monatsgebuehr des Abos des Kunden (productKeyOf: ohne bzw. mit unbekanntem Schluessel = Wartungs-Abo)
|
||||
const monthly = doc.invoiceAmountCents / Math.max(1, doc.billingMonths)
|
||||
const aboCents = getProduct(subscription?.productKey || 'wartung').amountCents
|
||||
const aboCents = getProduct(productKeyOf(subscription)).amountCents
|
||||
if (monthly > aboCents) {
|
||||
checks.push({
|
||||
key: 'amount',
|
||||
@@ -735,6 +737,8 @@ export async function getAdminDetail(id) {
|
||||
? {
|
||||
status: subscription.status,
|
||||
active: isActiveSub(subscription),
|
||||
productKey: productKeyOf(subscription),
|
||||
productName: getProduct(productKeyOf(subscription)).name,
|
||||
startedAt: subscription.startedAt,
|
||||
serviceStart: serviceStartOf(subscription),
|
||||
currentPeriodEnd: subscription.currentPeriodEnd,
|
||||
|
||||
Reference in new issue
Block a user