// Generated by dts-bundle-generator v8.0.1 import { Hint, ReadConcernLike, ReadPreferenceLike } from 'mongodb'; import { ClientSession, Document, Schema, Types } from 'mongoose'; export interface IAnyObject { [k: string]: any; } export interface ITransaction { _id?: Types.ObjectId; credit: number; debit: number; meta?: IAnyObject; datetime: Date; account_path: string[]; accounts: string; book: string; memo: string; _journal: Types.ObjectId; timestamp: Date; voided?: boolean; void_reason?: string; _original_journal?: Types.ObjectId; } export declare function setTransactionSchema(schema: Schema, collection?: string, options?: { defaultIndexes: boolean; }): void; export type IFilterQuery = { account?: string | string[]; _journal?: Types.ObjectId | string; start_date?: Date | string | number; end_date?: Date | string | number; } & Partial & { [key: string]: string[] | number | string | Date | boolean | Types.ObjectId; }; export interface IPaginationQuery { perPage?: number; page?: number; } export type IBalanceQuery = { account?: string | string[]; start_date?: Date | string | number; end_date?: Date | string | number; start_tx_id?: Types.ObjectId; end_tx_id?: Types.ObjectId; } & { [key: string]: string[] | number | string | Date | boolean | Types.ObjectId | IAnyObject; }; export interface IJournal { _id: Types.ObjectId; datetime: Date; memo: string; _transactions: Types.ObjectId[]; book: string; voided?: boolean; void_reason?: string; } export type TJournalDocument = Omit & T; export declare function setJournalSchema(schema: Schema, collection?: string): void; export type IOptions = { session?: ClientSession; readPreference?: ReadPreferenceLike; hint?: Hint; readConcern?: ReadConcernLike; }; export declare class Entry { book: Book; journal: TJournalDocument & { _original_journal?: Types.ObjectId; }; transactions: U[]; timestamp: Date; static write(book: Book, memo: string, date: Date | null, original_journal?: string | Types.ObjectId): Entry; constructor(book: Book, memo: string, date: Date | null, original_journal?: string | Types.ObjectId); private transact; credit(account_path: string | string[], amount: number | string, extra?: T & Partial): Entry; debit(account_path: string | string[], amount: number | string, extra?: T & Partial): Entry; commit(options?: IOptions & { writelockAccounts?: string[] | RegExp; }): Promise["journal"]>; } export declare class Book { name: string; precision: number; maxAccountPath: number; balanceSnapshotSec: number; expireBalanceSnapshotSec: number; constructor(name: string, options?: { precision?: number; maxAccountPath?: number; balanceSnapshotSec?: number; expireBalanceSnapshotSec?: number; }); entry(memo: string, date?: Date, original_journal?: string | Types.ObjectId): Entry; balance(query: IBalanceQuery, options?: IOptions): Promise<{ balance: number; notes: number; }>; ledger(query: IFilterQuery & IPaginationQuery, options?: IOptions): Promise<{ results: T[]; total: number; }>; void(journal_id: string | Types.ObjectId, reason?: undefined | string, options?: IOptions, use_original_date?: boolean): Promise, "id" | "__v"> & J & { _original_journal?: Types.ObjectId; }>; writelockAccounts(accounts: string[], options: Required>): Promise>; listAccounts(options?: IOptions): Promise; } export declare function setLockSchema(schema: Schema, collection?: string): void; export declare function mongoTransaction(fn: (session: ClientSession) => Promise, options?: IAnyObject): Promise; export declare function initModels(): Promise; /** * Will execute mongoose model's `syncIndexes()` for all medici models. * WARNING! This will erase any custom (non-builtin) indexes you might have added. * @param [options] {{background: Boolean}} */ export declare function syncIndexes(options?: { background: boolean; }): Promise; export declare class MediciError extends Error { code: number; constructor(message: string, code?: number); } export declare class BookConstructorError extends MediciError { code: number; constructor(message: string, code?: number); } export declare class InvalidAccountPathLengthError extends MediciError { code: number; constructor(message: string, code?: number); } export declare class JournalAlreadyVoidedError extends MediciError { code: number; constructor(message?: string, code?: number); } export declare class JournalNotFoundError extends MediciError { code: number; constructor(message?: string, code?: number); } export declare class TransactionError extends MediciError { code: number; total: number; constructor(message: string, total: number, code?: number); } export { Book as default, }; export {};