Zusatzspeicher: Plus sofort anteilig, Minus zum Monatsende, Aufgaben für konsoleH
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
887e1e54a0
commit
379cc26dcd
11 files changed
+1531
-27
No files matched your search
@@ -1,3 +1,5 @@
|
||||
import path from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { config } from '../config.js'
|
||||
|
||||
/**
|
||||
@@ -34,6 +36,19 @@ export function termsDocFor(termsVersion) {
|
||||
return { url: '/vertragsunterlagen/v3/abo-bedingungen.html', pdfFile: 'WEBklar-Wartungs-Abo-Vertragsunterlagen.pdf' }
|
||||
}
|
||||
|
||||
const PUBLIC_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), '..', '..', 'public')
|
||||
|
||||
/**
|
||||
* Vertragsunterlagen als Mail-Anhang in der Fassung, der der Kunde zugestimmt hat (§ 312f BGB):
|
||||
* { filename, path } mit dem absoluten Pfad unter public/. Ein Speicher-Plus haengt die Fassung aus der
|
||||
* Zustimmung an (consent.termsVersion), nicht die des Abos (F22): Bestandskunden mit Fassung 3 bestellen
|
||||
* den Zusatzspeicher nach Fassung 4.
|
||||
*/
|
||||
export function contractAttachmentFor(termsVersion) {
|
||||
const { pdfFile } = termsDocFor(termsVersion)
|
||||
return { filename: pdfFile, path: path.join(PUBLIC_DIR, pdfFile) }
|
||||
}
|
||||
|
||||
/** Ansicht eines Produkts fuers Kundenportal (Vergleich, Bestellseite): Preis und Leistungen. */
|
||||
export function productView(key) {
|
||||
const product = getProduct(key)
|
||||
@@ -78,12 +93,27 @@ export function describeItems(items) {
|
||||
|
||||
const priceIdOfLine = (line) => line?.pricing?.price_details?.price || null
|
||||
|
||||
// Regulaere Abo-Zeile (Monatsposition): keine anteilige Verrechnung, keine einzelne Rechnungsposition
|
||||
const isRegularSubscriptionLine = (line) =>
|
||||
line?.parent?.type === 'subscription_item_details' && line.parent.subscription_item_details?.proration === false
|
||||
|
||||
/** Preis-IDs aller Rechnungszeilen, jede nur einmal. */
|
||||
export function priceIdsOfInvoice(invoice) {
|
||||
const ids = (invoice?.lines?.data || []).map(priceIdOfLine).filter(Boolean)
|
||||
return [...new Set(ids)]
|
||||
}
|
||||
|
||||
/**
|
||||
* Regulaere Zusatzspeicher-Zeile einer bezahlten Rechnung (Stueckzahl des Abrechnungsmonats) oder null.
|
||||
* Anteilige Zeilen (Plus im laufenden Monat) zaehlen nicht. priceKeys wie bei creditMinutesForInvoice.
|
||||
*/
|
||||
export function regularStorageLine(invoice, priceKeys) {
|
||||
return (
|
||||
(invoice?.lines?.data || []).find((line) => priceKeys.get(priceIdOfLine(line)) === 'mailStorage' && isRegularSubscriptionLine(line)) ||
|
||||
null
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Arbeitszeit, die eine bezahlte Rechnung gutschreibt: die Minuten des Produkts der ersten
|
||||
* regulären (nicht anteiligen) Abo-Zeile über 0 €, deren Produkt Arbeitszeit enthält. Anteilige
|
||||
@@ -100,10 +130,7 @@ export function creditMinutesForInvoice(invoice, priceKeys) {
|
||||
const key = legacy && known == null ? 'wartung' : known
|
||||
if (!PRODUCT_KEYS.includes(key)) continue
|
||||
const minutes = config.products[key].minutesPerMonth
|
||||
const regular =
|
||||
line.parent?.type === 'subscription_item_details' &&
|
||||
line.parent.subscription_item_details?.proration === false
|
||||
if (minutes > 0 && regular && line.amount > 0) return minutes
|
||||
if (minutes > 0 && isRegularSubscriptionLine(line) && line.amount > 0) return minutes
|
||||
}
|
||||
return 0
|
||||
}
|
||||
Reference in new issue
Block a user