Vertragsereignisse: Speicher-Aufgaben mit gelesenen Details
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e5cc57cefd
commit
05363d06ad
2 files changed
+29
-3
No files matched your search
@@ -105,14 +105,15 @@ export function openWithdrawals(events, now = new Date()) {
|
||||
.filter((entry) => now <= entry.until)
|
||||
}
|
||||
|
||||
/** Offene Zusatzspeicher-Aufgaben fuers Team, faelligste zuerst. */
|
||||
/** Offene Zusatzspeicher-Aufgaben fuers Team, faelligste zuerst, mit geparstem details. */
|
||||
export async function listOpenStorageTasks() {
|
||||
return listDocuments(COLLECTION(), [
|
||||
const docs = await listDocuments(COLLECTION(), [
|
||||
Query.equal('type', 'speicher'),
|
||||
Query.equal('status', 'offen'),
|
||||
Query.orderAsc('dueAt'),
|
||||
Query.limit(1000),
|
||||
])
|
||||
return docs.map((doc) => ({ ...doc, details: parseJson(doc.details, {}) }))
|
||||
}
|
||||
|
||||
/** Zusatzspeicher-Aufgabe erledigt (Team hat die Postfachgroesse angepasst). */
|
||||
|
||||
@@ -38,7 +38,32 @@ test('Ereignis speichern und lesen (details als JSON)', async () => {
|
||||
})
|
||||
const [e] = await listContractEvents('c1')
|
||||
assert.deepEqual(e.details, { fromUnits: 0, toUnits: 2 })
|
||||
assert.equal((await listOpenStorageTasks()).length, 1)
|
||||
|
||||
// Zweites offenes Speicher-Ereignis mit frueherem dueAt, absichtlich NACH dem ersten angelegt
|
||||
// (umgekehrte Reihenfolge): listOpenStorageTasks() muss trotzdem nach dueAt aufsteigend sortieren,
|
||||
// nicht nach der Anlage-Reihenfolge.
|
||||
await recordContractEvent({
|
||||
customerId: 'c5',
|
||||
subscriptionId: 'sub_5',
|
||||
type: 'speicher',
|
||||
productKey: 'hosting',
|
||||
details: { fromUnits: 0, toUnits: 1 },
|
||||
consent: {
|
||||
termsVersion: '2026-10-05-v4',
|
||||
consentAt: '2026-10-02T10:00:00.000Z',
|
||||
consentIp: '1.2.3.4',
|
||||
consentUserAgent: 'UA',
|
||||
},
|
||||
status: 'offen',
|
||||
dueAt: '2026-10-03T10:00:00.000Z',
|
||||
})
|
||||
|
||||
const tasks = await listOpenStorageTasks()
|
||||
assert.equal(tasks.length, 2)
|
||||
// Wichtig: details kommt geparst zurueck, wie bei listContractEvents (nicht als JSON-String)
|
||||
assert.equal(tasks[0].details.toUnits, 1)
|
||||
// Minor: faelligstes (frueheres dueAt) zuerst, unabhaengig von der Anlage-Reihenfolge
|
||||
assert.deepEqual(tasks.map((t) => t.dueAt), ['2026-10-03T10:00:00.000Z', '2026-10-05T10:00:00.000Z'])
|
||||
})
|
||||
|
||||
test('Widerrufsfristen je Bestellung', () => {
|
||||
|
||||
Reference in new issue
Block a user