import type { IJournalDraft } from './core.types.js'; import { type IAccountPolicy } from './core.accountpolicy.js'; import { type IDatevBuchungsstapelRow } from './core.datev.js'; export type TDatevImportErrorCode = /** the first line is no EXTF header of a Buchungsstapel, or a field of it is not readable (`details.field`) */ 'extf_header_invalid' /** the Stapel or a row is in another currency than the euro (`details.field`, `.value`) */ | 'extf_currency_unsupported' /** a field of a row is not readable (`details.row`, `.line`, `.field`, `.value`) */ | 'extf_row_malformed' /** a BU key skr's table does not know (`details.row`, `.line`, `.key`) */ | 'extf_bu_key_unknown' /** a Belegdatum that falls in no day of the Stapel's period (`details.row`, `.line`, `.value`) */ | 'extf_date_outside_period' /** a row with a tax whose account cannot be told: both or neither side can carry it (`details.row`, `.line`, `.accounts`) */ | 'extf_tax_account_unclear' /** the entry a row gives is no valid journal draft (`details.row`, `.line`, `.errors`) */ | 'extf_row_invalid'; export interface IDatevImportErrorDetails { /** the data row, from 1 */ row?: number; /** the line of the file, from 1: the data row plus the header and the caption line */ line?: number; field?: string; value?: string; key?: string; accounts?: string[]; errors?: string[]; } /** A Buchungsstapel that cannot be read as it is: the file is the problem, not the code. */ export declare class DatevImportError extends Error { readonly code: TDatevImportErrorCode; readonly details: IDatevImportErrorDetails; constructor(code: TDatevImportErrorCode, message: string, details?: IDatevImportErrorDetails); } /** What the header of a Buchungsstapel states (the fields `writeExtfBuchungsstapel` writes). */ export interface IDatevExtfHeader { formatVersion: number; createdAt?: Date; consultantNumber: number; clientNumber: number; /** Wirtschaftsjahr-Beginn (field 13) */ fiscalYearStart: Date; /** Sachkontenlänge (field 14) */ accountLength: number; /** the period (fields 15 and 16) */ dateFrom: Date; dateTo: Date; label: string; festschreibung: boolean; } export interface IExtfBuchungsstapel { header: IDatevExtfHeader; rows: IDatevBuchungsstapelRow[]; /** * what was read but not taken, each naming its row, line and field: a * Beleginfo pair of one part only, or of an Art or Inhalt longer than DATEV * takes, is skipped (fields 21 to 36) */ warnings: string[]; } /** One row of a Stapel with the journal draft it gives. */ export interface IImportedDatevRow { /** the data row, from 1 */ row: number; datevRow: IDatevBuchungsstapelRow; draft: IJournalDraft; } /** * Reads a Buchungsstapel as DATEV writes it: Windows-1252 bytes, the EXTF * header, the caption line and one row per Buchungssatz. Refuses with a * `DatevImportError` naming the row; a Beleginfo pair DATEV would not take is * skipped, named in `warnings`. */ export declare function readExtfBuchungsstapel(bytesArg: Uint8Array): IExtfBuchungsstapel; /** * The journal draft of one row of a Buchungsstapel, its tax unfolded onto * the tax accounts of the policy as `consolidateJournalDraftForDatev` folds * it, so a Stapel skr wrote reads back into drafts it writes again row for * row. A key on an Automatikkonto that books the tax of its automatism is * read as the automatism (`keyRestatesAutomatism`), so the account never * carries it; a key of another tax stays on the account, which * `validateJournalDraft` refuses (`automatik_bu_key`). Refuses * (`extf_tax_account_unclear`) a row that books a tax where the account it is * computed on cannot be told. */ export declare function journalDraftOfDatevRow(rowArg: IDatevBuchungsstapelRow, policyArg: IAccountPolicy): IJournalDraft; /** * Reads a Buchungsstapel and gives each row's journal draft, each checked * against the policy (`validateJournalDraft`). Refuses the first row that * cannot be read or booked, naming it. What the reading skipped is in * `warnings` (`readExtfBuchungsstapel`): a Beleginfo DATEV would not take * never refuses a row, as the drafts carry only the pairs it took. */ export declare function importExtfBuchungsstapel(bytesArg: Uint8Array, policyArg: IAccountPolicy): { header: IDatevExtfHeader; entries: IImportedDatevRow[]; warnings: string[]; };