/** * Booking recipes of a main book beyond the documents and payments: the * opening balances (EB-Werte) of a fiscal year, the carry-forward of a closed * year into the next one, the owners' private withdrawals and deposits, and * the payment and refund of the VAT advance return. Pure builders, like * `core.recipes.ts`: (input, policy) => IJournalDraft, integer cents, no * chart lookups. */ import type { IJournalDraft, TCents } from './core.types.js'; import type { IAccountPolicy } from './core.accountpolicy.js'; /** One opening balance: an account's balance, or one open item of a personal account. */ export interface IOpeningBalanceLine { accountNumber: string; /** debit positive, credit negative; 0 books nothing */ signedCents: TCents; /** a personal account's open item: its Belegfeld 1 (the invoice number); unset: the entry's reference */ belegfeld1?: string; /** the line's text; unset: the entry's description */ buchungstext?: string; } export interface IOpeningBalancesInput { /** the first day of the fiscal year */ date: Date; balances: IOpeningBalanceLine[]; description: string; reference?: string; /** the Beleg: the prior year's balance sheet, the Saldenliste or the Inventar */ docLink?: string; } /** A closing balance of the year that is carried forward. */ export interface IClosingBalance { accountNumber: string; /** debit positive, credit negative */ signedCents: TCents; /** * `balance_sheet`: carried as the account's opening balance; * `profit_and_loss`: not carried, it makes the year's result; * `private`: a sole trader's or a partner's private account, carried into the capital account. */ kind: 'balance_sheet' | 'profit_and_loss' | 'private'; /** a personal account's open items, whose balances sum to `signedCents`: each is carried by its Belegfeld 1 */ openItems?: Array<{ belegfeld1: string; signedCents: TCents; }>; } /** Where the year's result and the private accounts go, by the legal form. */ export type TCarryForwardEquity = /** a company: the result to Gewinnvortrag or Verlustvortrag vor Verwendung (the policy's `resultCarryForward`); no private accounts */ { kind: 'company'; } /** a sole trader: the result and the private accounts to the capital account */ | { kind: 'sole_trader'; capitalAccount: string; } /** * a partnership: each partner's share of the result, as the partnership * agreement or the law distributes it, and the partner's private accounts * to the partner's capital account */ | { kind: 'partnership'; partners: Array<{ capitalAccount: string; privateAccounts: string[]; resultShareCents: TCents; }>; }; export interface ICarryForwardInput { /** the first day of the new fiscal year */ date: Date; /** every closing balance of the closed year, so that they sum to 0 */ closing: IClosingBalance[]; equity: TCarryForwardEquity; description: string; reference?: string; docLink?: string; } export interface IPrivateMovementInput { date: Date; /** positive */ amountCents: TCents; /** * the business account the money leaves or enters; unset: the policy's * bank. For a voucher the owner paid privately: the creditor's personal * account, with the invoice number as `reference`. */ account?: string; /** unset: the policy's `privateAccounts` */ privateAccount?: string; description: string; /** Belegfeld 1 of the lines */ reference?: string; docLink?: string; } export interface IVatPrepaymentInput { date: Date; /** `payment`: to the Finanzamt; `refund`: from it */ direction: 'payment' | 'refund'; /** positive */ amountCents: TCents; /** the Sondervorauszahlung for the Dauerfristverlängerung (1/11) instead of an advance return */ special?: boolean; bankAccount?: string; description: string; reference?: string; docLink?: string; } export interface IInventoryChangeInput { /** the Stichtag: the last day of the fiscal year the Inventar is made for */ date: Date; /** * the stock of goods the books carry before this entry: the balance of the * policy's `goods.stock` account, which is the stock the prior year's * Inventar valued (0 in the first year the books keep goods) */ bookedCents: TCents; /** the stock of goods on the Stichtag as the Inventar values it (§ 240 Abs. 2, § 253 Abs. 1 and 4 HGB) */ closingCents: TCents; description: string; /** Belegfeld 1 of the lines */ reference?: string; /** the Beleg: the Inventar */ docLink?: string; } /** * The change in the stock of goods at the year's end (Bestandsveränderung), * where the purchases of goods are booked as an expense (Wareneingang) and the * stock only at the year's end: the stock the Inventar values on the Stichtag * (`closingCents`) replaces the stock the books carry (`bookedCents`), and the * difference goes on the policy's `goods.stockChange` account, part of the * Materialaufwand (§ 275 Abs. 2 Nr. 5 HGB). A stock that grew: `goods.stock` * debit, `goods.stockChange` credit; one that shrank: the reverse. No VAT and * no BU key: a change in stock is no supply. The stock carries into the next * year with the carry-forward, and no entry reverses this one; the next year * books its own difference. Pure, like every recipe: whether the entry is * one of the year's closing entries is the caller's to decide. * * Refuses a policy without `goods` (`goods_accounts_missing`), a stock or * stock-change account with a DATEV tax automatism or marked for the UStVA * (`goods_account_not_allowed`), an amount that is no whole cents * (`amount_not_whole_cents`) or below 0 (`inventory_value_negative`), and a * stock that did not change (`inventory_unchanged`). */ export declare function bookInventoryChange(input: IInventoryChangeInput, policy: IAccountPolicy): IJournalDraft; /** * The opening balances (EB-Werte) of a fiscal year, as one entry: each * balance on its account against the Saldenvortragskonto — a debtor's against * `openingBalance.debtors`, a creditor's against `.creditors`, every other * against `.generalLedger` — so that the opening balances of all accounts * together leave the three at 0. A personal account is best opened per open * item, each with its invoice number as Belegfeld 1, so its open items and * their later settlement work. Refuses no balance at all, an amount that is * not whole cents, the same account (or open item) twice, a control account * (open the personal accounts) and a Saldenvortragskonto itself. */ export declare function bookOpeningBalances(input: IOpeningBalancesInput, policy: IAccountPolicy): IJournalDraft; /** * The accounts of a year's German VAT in a policy: the output and input tax at * each rate, the paired tax of intra-Community acquisitions and of § 13b UStG, * and the advance return's prepayments and Sondervorauszahlung. Not the VAT * owed to another member state (`vat.otherEuState*`), which is no German tax. */ export declare function germanVatAccountsOf(policy: IAccountPolicy): string[]; /** * A closed year's closing balances with its VAT reclassified for the * carry-forward (`carryForwardOf`): the balances of the year's German VAT * accounts (`vatAccounts`, default `germanVatAccountsOf`) open together on the * previous year's VAT account (`vatSettlement.previousYear`: SKR 03 1790, * SKR 04 3841), and that account's old balance, what was left of the year * before, on the earlier years' account (`vatSettlement.earlierYears`: SKR 03 * 1791, SKR 04 3845), which keeps its own. So the new year's advance returns * start from accounts that hold only their own year's tax, and what a year * owes or is owed stays apart until it is settled. No entry of the closed year * books it: the carry-forward opens the balances there. The balances still sum * as before; accounts left at 0 are not given. * * An individual account of the books under one of the year's VAT accounts * (`IAccountPolicy.individualAccounts`, such as SKR 04 3821 under the * prepayments' 3820) is moved as its parent is, unless its declaration * changes its UStVA mapping: then it stands for itself, as in the VAT checks * (`vatCheckAccountOf`), and is moved only where `vatAccounts` names it. * An individual account under `previousYear` or `earlierYears` itself (SKR 04 * 3842 under 3841, 3846 under 3845) stays on its own number: it holds what the * business keeps apart, such as a year under audit or in dispute, and moving * it is a booking of the new year. * * Refuses a policy without the two accounts (`vat_year_accounts_missing`) and * a VAT account given per open item (`vat_account_per_open_item`). */ export declare function vatOfPastYearsReclassified(closing: IClosingBalance[], policy: IAccountPolicy, options?: { vatAccounts?: readonly string[]; }): IClosingBalance[]; /** * The carry-forward (Saldovortrag) of a closed year: the opening balances of * the next year, dated its first day (§ 252 Abs. 1 Nr. 1 HGB: "Die Wertansätze * in der Eröffnungsbilanz des Geschäftsjahrs müssen mit denen der * Schlußbilanz des vorhergehenden Geschäftsjahrs übereinstimmen"). The * balance-sheet accounts carry their closing balances, a personal account per * open item where they are given. The profit-and-loss accounts are not * carried: their sum, the year's result, goes to equity by the legal form — * a company's to Gewinnvortrag or Verlustvortrag vor Verwendung, a sole * trader's to the capital account together with the private accounts, a * partnership's by the partners' shares to their capital accounts together * with each partner's private accounts. An account that also carries a * balance of its own gets one line with both. * * Refuses closing balances that do not sum to 0 (the year's books are not * complete or not balanced), open items that do not sum to their account, a * Saldenvortragskonto with a balance (the year's own opening balances did not * balance), private accounts of a company, a private account no partner * holds, and partners' shares that do not sum to the result. */ export declare function carryForwardOf(input: ICarryForwardInput, policy: IAccountPolicy): IJournalDraft; /** * A private withdrawal (Privatentnahme): the private account debit, the * business account credit. For a sole trader or a partner; a company has no * private accounts. */ export declare function bookPrivateWithdrawal(input: IPrivateMovementInput, policy: IAccountPolicy): IJournalDraft; /** * A private deposit (Privateinlage): the business account debit, the private * account credit. A voucher the owner paid privately is a deposit into the * creditor's personal account: with the invoice number as `reference` it * settles the invoice's open item. */ export declare function bookPrivateDeposit(input: IPrivateMovementInput, policy: IAccountPolicy): IJournalDraft; /** * The accounts a draft books on that the chart in use does not have, in the * order the draft first names them. A booking on an account the chart lacks * would be a booking on no account. */ export declare function missingChartAccountsOf(draft: IJournalDraft, chartAccounts: readonly string[]): string[]; /** * The payment of a VAT advance return to the Finanzamt, or its refund, on * the Umsatzsteuer-Vorauszahlungen account against the bank; with `special` * the Sondervorauszahlung of the Dauerfristverlängerung on its own account. * The VAT accounts themselves are not touched. * * `chartAccounts` are the account numbers of the chart in use. The recipe * refuses, naming them, when it lacks the prepayment account or the bank * account. skr's own charts (from `@fin.cx/chartdata` 2.5) hold SKR 03 * 1780/1781 and SKR 04 3820/3830. */ export declare function bookVatPrepayment(input: IVatPrepaymentInput, policy: IAccountPolicy, chartAccounts: readonly string[]): IJournalDraft;