feat(validation): Implement EN16931 compliance validation types and VAT categories

- Added validation types for EN16931 compliance in `validation.types.ts`, including interfaces for `ValidationResult`, `ValidationOptions`, and `ValidationReport`.
- Introduced `VATCategoriesValidator` in `vat-categories.validator.ts` to validate VAT categories according to EN16931 rules, including detailed checks for standard, zero-rated, exempt, reverse charge, intra-community, export, and out-of-scope services.
- Enhanced `IEInvoiceMetadata` interface in `en16931-metadata.ts` to include additional fields required for full standards compliance, such as delivery information, payment information, allowances, and charges.
- Implemented helper methods for VAT calculations and validation logic to ensure accurate compliance with EN16931 standards.
This commit is contained in:
2025-08-11 12:25:32 +00:00
parent 01c6e8daad
commit 10e14af85b
53 changed files with 11315 additions and 17 deletions

View File

@@ -0,0 +1,64 @@
#!/usr/bin/env node
/**
* Script to download official Schematron files for e-invoice validation
*/
import { SchematronDownloader } from '../ts/formats/validation/schematron.downloader.js';
async function main() {
console.log('📥 Starting Schematron download...\n');
const downloader = new SchematronDownloader('assets/schematron');
await downloader.initialize();
// Download EN16931 Schematron files
console.log('🔵 Downloading EN16931 Schematron files...');
try {
const en16931Paths = await downloader.downloadStandard('EN16931');
console.log(`✅ Downloaded ${en16931Paths.length} EN16931 files`);
en16931Paths.forEach(p => console.log(` - ${p}`));
} catch (error) {
console.error(`❌ Failed to download EN16931: ${error.message}`);
}
console.log('\n🔵 Downloading PEPPOL Schematron files...');
try {
const peppolPaths = await downloader.downloadStandard('PEPPOL');
console.log(`✅ Downloaded ${peppolPaths.length} PEPPOL files`);
peppolPaths.forEach(p => console.log(` - ${p}`));
} catch (error) {
console.error(`❌ Failed to download PEPPOL: ${error.message}`);
}
console.log('\n🔵 Downloading XRechnung Schematron files...');
try {
const xrechnungPaths = await downloader.downloadStandard('XRECHNUNG');
console.log(`✅ Downloaded ${xrechnungPaths.length} XRechnung files`);
xrechnungPaths.forEach(p => console.log(` - ${p}`));
} catch (error) {
console.error(`❌ Failed to download XRechnung: ${error.message}`);
}
// List cached files
console.log('\n📂 Cached Schematron files:');
const cached = await downloader.getCachedFiles();
cached.forEach(file => {
if (file.metadata) {
console.log(` - ${file.path}`);
console.log(` Version: ${file.metadata.version}`);
console.log(` Format: ${file.metadata.format}`);
console.log(` Downloaded: ${file.metadata.downloadDate}`);
} else {
console.log(` - ${file.path} (no metadata)`);
}
});
console.log('\n✅ Schematron download complete!');
}
// Run the script
main().catch(error => {
console.error('❌ Script failed:', error);
process.exit(1);
});