Kundenportal: Rechnungsliste kennt das Projekt (Feld projekt aus den Stripe-Metadaten)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
8627ed1124
commit
987268e2f0
3 files changed
+32
-1
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { useTestEnv } from './support/testEnv.js'
|
||||
|
||||
// Reiner Test von customerStripeInvoice: config.js liest die Umgebung beim ersten Import, die Adressen werden nie angefragt.
|
||||
useTestEnv({ appwriteUrl: 'http://127.0.0.1:9', stripeUrl: 'http://127.0.0.1:9' })
|
||||
const { customerStripeInvoice } = await import('../server/services/customerInvoices.js')
|
||||
|
||||
const roh = (over = {}) => ({
|
||||
id: 'in_1', number: 'WEBKLAR-0009', status: 'open', effective_at: 1_791_000_000, due_date: 1_792_000_000,
|
||||
total: 50000, amount_remaining: 50000, hosted_invoice_url: 'https://invoice.stripe.com/i/in_1',
|
||||
invoice_pdf: 'https://pay.stripe.com/invoice/in_1/pdf', metadata: {}, ...over,
|
||||
})
|
||||
|
||||
test('Rechnung der Kunden-Liste: projekt kommt aus metadata.projektName, sonst leer', () => {
|
||||
assert.equal(customerStripeInvoice(roh({ metadata: { projektName: 'Website Anelia Wolf' } })).projekt, 'Website Anelia Wolf')
|
||||
assert.equal(customerStripeInvoice(roh()).projekt, '')
|
||||
assert.equal(customerStripeInvoice(roh({ metadata: { webklarCustomerId: 'c1', art: 'abo' } })).projekt, '')
|
||||
const ohneMetadaten = roh()
|
||||
delete ohneMetadaten.metadata
|
||||
assert.equal(customerStripeInvoice(ohneMetadaten).projekt, '')
|
||||
})
|
||||
|
||||
test('Rechnung der Kunden-Liste: die bisherigen Felder bleiben, projekt kommt dazu', () => {
|
||||
assert.deepEqual(Object.keys(customerStripeInvoice(roh())).sort(), [
|
||||
'amount', 'balance', 'cancelled', 'date', 'dueDate', 'hasPdf', 'id', 'number', 'overdue', 'paid', 'portalUrl', 'projekt', 'source', 'status',
|
||||
])
|
||||
})
|
||||
@@ -184,6 +184,7 @@ test('Liste: Felder einer bezahlten Abo-Rechnung (Betraege in Euro, Link zur Rec
|
||||
overdue: false,
|
||||
portalUrl: 'https://invoice.stripe.com/i/in_c1_abo',
|
||||
hasPdf: true,
|
||||
projekt: '',
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user