import { JournalEntry } from './skr.classes.journalentry.js'; import type { TSKRType } from './skr.types.js'; import type { IInvoice, IBookingRules, IBookingInfo, IPaymentInfo } from './skr.invoice.entity.js'; /** * Options for booking an invoice */ export interface IBookingOptions { autoBook?: boolean; confidenceThreshold?: number; bookingDate?: Date; bookingReference?: string; skipValidation?: boolean; } /** * Result of booking an invoice */ export interface IBookingResult { success: boolean; journalEntry?: JournalEntry; bookingInfo?: IBookingInfo; confidence: number; warnings?: string[]; errors?: string[]; } /** * Automatic booking engine for invoices * Creates journal entries from invoice data based on SKR mapping rules */ export declare class InvoiceBookingEngine { private logger; private skrType; private mapper; constructor(skrType: TSKRType); /** * Book an invoice to the ledger */ bookInvoice(invoice: IInvoice, bookingRules?: Partial, options?: IBookingOptions): Promise; /** * Build journal entry from invoice */ private buildJournalEntry; /** * Build AP (Accounts Payable) journal entry lines */ private buildAPEntry; /** * Build AR (Accounts Receivable) journal entry lines */ private buildAREntry; /** * Build VAT lines */ private buildVATLines; /** * Calculate VAT amount from taxable amount and rate */ private calculateVAT; /** * Build reverse charge VAT lines (§13b UStG) */ private buildReverseChargeVATLines; /** * Group invoice lines by account */ private groupLinesByAccount; /** * Book the payment of an invoice through the core recipe * (`core.bookBankPayment`): the control account settled by what was paid * and the Skonto taken, against the bank. The Skonto is split over the * VAT groups of the invoice in proportion to their gross amounts and * corrects the tax of each rate by its share (§ 17 Abs. 1 Sätze 1 und 2 * UStG) on the policy's VAT account of the rate. `rules.skontoMethod` * picks where the net share goes: `'gross'` onto the policy's Skonto * account of the rate, `'net'` onto the expense or revenue account the * group's lines were booked on, which the Skonto reduces. A part without * VAT takes its share on the account its lines were booked on under * either method. */ bookPayment(invoice: IInvoice, payment: IPaymentInfo, rules: IBookingRules): Promise; /** * The parts of the invoice a Skonto was granted on, one per VAT group: its * gross amount at its rate, and the account its lines were booked on — for * a group without VAT always, for a group at a rate under the net method. * A group whose lines went to several accounts, or to none, is refused * where it needs one: which account the Skonto reduces is not guessed. A * § 13b or intra-Community acquisition invoice is refused: its Skonto * corrects the tax the recipient owes itself and its deduction (§ 17 * Abs. 1 Satz 5 UStG), which this engine does not book — it does not read * the German rate of the self-assessed tax from the invoice, whose VAT * category commonly carries 0 %. `core.bookBankPayment` books it with a * share naming that rate and `selfAssessed`. */ private skontoSharesOf; /** * Validate invoice before booking */ private validateInvoice; /** * Generate warnings for the booking */ private generateWarnings; /** * Build description for journal entry */ private buildDescription; /** * Get account description for a group of lines */ private getAccountDescription; /** * Get used expense accounts */ private getUsedExpenseAccounts; /** * Get used revenue accounts */ private getUsedRevenueAccounts; /** * Get used VAT accounts */ private getUsedVATAccounts; }