Files
einvoice/ts/interfaces/en16931-metadata.ts
Juergen Kunz 10e14af85b 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.
2025-08-11 12:25:32 +00:00

97 lines
3.0 KiB
TypeScript

/**
* EN16931-compliant metadata interface for EInvoice
* Contains all additional fields required for full standards compliance
*/
import type { business } from '@tsclass/tsclass';
import type { InvoiceFormat } from './common.js';
/**
* Extended metadata for EN16931 compliance
*/
export interface IEInvoiceMetadata {
// Format identification
format?: InvoiceFormat;
version?: string;
profile?: string;
customizationId?: string;
// EN16931 Business Terms
vatAccountingCurrency?: string; // BT-6
documentTypeCode?: string; // BT-3
paymentMeansCode?: string; // BT-81
paidAmount?: number; // BT-113
amountDue?: number; // BT-115
// Delivery information (BG-13)
deliveryAddress?: {
streetName?: string;
houseNumber?: string;
city?: string;
postalCode?: string;
countryCode?: string; // BT-80
countrySubdivision?: string;
};
// Payment information (BG-16)
paymentAccount?: {
iban?: string; // BT-84
accountName?: string; // BT-85
bankId?: string; // BT-86
};
// Allowances and charges (BG-20, BG-21)
allowances?: Array<{
amount: number; // BT-92
baseAmount?: number; // BT-93
percentage?: number; // BT-94
vatCategoryCode?: string; // BT-95
vatRate?: number; // BT-96
reason?: string; // BT-97
reasonCode?: string; // BT-98
}>;
charges?: Array<{
amount: number; // BT-99
baseAmount?: number; // BT-100
percentage?: number; // BT-101
vatCategoryCode?: string; // BT-102
vatRate?: number; // BT-103
reason?: string; // BT-104
reasonCode?: string; // BT-105
}>;
// Extensions for specific standards
extensions?: Record<string, any>;
}
/**
* Extended item metadata for EN16931 compliance
*/
export interface IItemMetadata {
vatCategoryCode?: string; // BT-151
priceBaseQuantity?: number; // BT-149
exemptionReason?: string; // BT-120 (for exempt categories)
originCountryCode?: string; // BT-159
commodityCode?: string; // BT-158
// Item attributes (BG-32)
attributes?: Array<{
name: string; // BT-160
value: string; // BT-161
}>;
}
/**
* Extended accounting document item with metadata
*/
export interface IExtendedAccountingDocItem {
position: number;
name: string;
articleNumber?: string;
unitType: string;
unitQuantity: number;
unitNetPrice: number;
vatPercentage: number;
metadata?: IItemMetadata;
}