@fin.cx/skr
Version:
SKR03 and SKR04 German accounting standards for double-entry bookkeeping
111 lines (110 loc) • 2.71 kB
TypeScript
import type { TSKRType } from './skr.types.js';
export interface IExportOptions {
exportPath: string;
fiscalYear: number;
dateFrom: Date;
dateTo: Date;
includeDocuments?: boolean;
generatePdfReports?: boolean;
signExport?: boolean;
timestampExport?: boolean;
companyInfo?: {
name: string;
taxId: string;
registrationNumber?: string;
address?: string;
};
}
export interface IExportMetadata {
exportVersion: string;
exportTimestamp: string;
generator: {
name: string;
version: string;
};
company?: {
name: string;
taxId: string;
registrationNumber?: string;
address?: string;
};
fiscalYear: number;
dateRange: {
from: string;
to: string;
};
skrType: TSKRType;
schemaVersion: string;
crypto: {
digestAlgorithms: string[];
signatureType?: string;
timestampPolicy?: string;
merkleTree: boolean;
};
options: {
packagedAs: 'bagit';
compression: 'none' | 'deflate';
deduplication: boolean;
};
}
export interface IBagItManifest {
[filePath: string]: string;
}
export interface IDocumentIndex {
contentHash: string;
sizeBytes: number;
mimeType: string;
createdAt: string;
originalFilename?: string;
pdfaAvailable: boolean;
zugferdXml?: string;
retentionClass: string;
}
export declare class SkrExport {
private logger;
private options;
private exportDir;
private manifest;
private tagManifest;
constructor(options: IExportOptions);
/**
* Creates the BagIt directory structure for the export
*/
createBagItStructure(): Promise<void>;
/**
* Creates the bagit.txt declaration file
*/
private createBagItDeclaration;
/**
* Creates the README.txt file with Verfahrensdokumentation
*/
private createReadme;
/**
* Creates the export metadata JSON file
*/
createExportMetadata(skrType: TSKRType): Promise<void>;
/**
* Creates JSON schemas for the export data structures
*/
createSchemas(): Promise<void>;
/**
* Writes the BagIt manifest files
*/
writeManifests(): Promise<void>;
/**
* Calculates SHA-256 hash of a file
*/
private hashFile;
/**
* Stores a document in content-addressed storage
*/
storeDocument(content: Buffer, originalFilename?: string): Promise<string>;
/**
* Creates a Merkle tree from all file hashes
*/
createMerkleTree(): Promise<string>;
/**
* Validates the BagIt structure
*/
validateBagIt(): Promise<boolean>;
}