@casoon/invoice-generator
Version:
Generate PDF invoices, XRechnung XML, and ZUGFeRD PDF/A-3 from JSON data with TypeScript support
32 lines (27 loc) • 828 B
text/typescript
import { Invoice } from '../types/invoice.types';
import fs from 'fs';
import path from 'path';
/**
* Lädt die zentrale Testdaten-JSON-Datei
*/
export function loadTestInvoice(): Invoice {
const testDataPath = path.join(process.cwd(), 'data', 'test-invoice.json');
if (!fs.existsSync(testDataPath)) {
throw new Error(`Testdaten-Datei nicht gefunden: ${testDataPath}`);
}
const jsonContent = fs.readFileSync(testDataPath, 'utf8');
return JSON.parse(jsonContent);
}
/**
* Lädt die Testdaten und gibt sie als InvoiceData-Objekt zurück (für Tests)
*/
export function loadTestInvoiceData() {
const invoice = loadTestInvoice();
return {
invoices: [invoice],
extractionDate: "2025-01-30T12:00:00Z",
invoiceCount: 1,
formatVersion: "1.0",
description: "Test invoice data"
};
}