- Added PeppolValidator class to validate PEPPOL BIS 3.0 invoices, including checks for endpoint IDs, document type IDs, process IDs, party identification, and business rules. - Implemented validation for GLN check digits, document types, and transport protocols specific to PEPPOL. - Added XRechnungValidator class to validate XRechnung 3.0 invoices, focusing on German-specific requirements such as Leitweg-ID, payment details, seller contact, and tax registration. - Included validation for IBAN and BIC formats, ensuring compliance with SEPA regulations. - Established methods for checking B2G invoice indicators and validating mandatory fields for both validators.
104 lines
3.3 KiB
TypeScript
104 lines
3.3 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
|
|
|
|
// Tax identifiers
|
|
sellerTaxId?: string; // BT-31
|
|
buyerTaxId?: string; // BT-48
|
|
buyerReference?: string; // BT-10
|
|
profileId?: string; // BT-23
|
|
paymentTerms?: string; // BT-20
|
|
|
|
// 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;
|
|
} |