UNPKG

@accounter/server

Version:
52 lines (51 loc) 3.5 kB
import DataLoader from 'dataloader'; import { TimelessDateString } from '../../../shared/types/index.js'; import { AdminContextProvider } from '../../admin-context/providers/admin-context.provider.js'; import { TenantAwareDBClient } from '../../app-providers/tenant-db-client.js'; import type { IGetLedgerRecordsByDatesParams, IInsertLedgerRecordsParams, IReplaceLedgerRecordsChargeIdParams, IUpdateLedgerRecordParams } from '../types.js'; /** * Fallback cap for a filtered ledger search that names no `limit`. The table is * the largest in the schema, so an unbounded read is a foot-gun — a caller that * genuinely wants more rows asks for them explicitly. */ export declare const DEFAULT_LEDGER_RECORDS_LIMIT = 10000; /** The account slots a ledger record can reference a financial entity in. */ export declare const LEDGER_RECORD_ACCOUNTS: readonly ["DEBIT_ACCOUNT_1", "DEBIT_ACCOUNT_2", "CREDIT_ACCOUNT_1", "CREDIT_ACCOUNT_2"]; export type LedgerRecordAccount = (typeof LEDGER_RECORD_ACCOUNTS)[number]; /** Caller-facing filters for {@link LedgerProvider.getLedgerRecordsByFilters}. */ export type LedgerRecordsFiltersParams = { fromInvoiceDate?: TimelessDateString | null; toInvoiceDate?: TimelessDateString | null; fromValueDate?: TimelessDateString | null; toValueDate?: TimelessDateString | null; fromAnyDate?: TimelessDateString | null; toAnyDate?: TimelessDateString | null; financialEntityIds?: readonly string[] | null; financialEntityAccounts?: readonly LedgerRecordAccount[] | null; ownerIds?: readonly string[] | null; chargeIds?: readonly string[] | null; limit?: number | null; }; export declare class LedgerProvider { private db; private adminContextProvider; constructor(db: TenantAwareDBClient, adminContextProvider: AdminContextProvider); private batchLedgerRecordsByIds; getLedgerRecordsByIdLoader: DataLoader<string, import("../types.js").IGetLedgerRecordsByIdsResult | undefined, string>; private batchLedgerRecordsByChargesIds; getLedgerRecordsByChargesIdLoader: DataLoader<string, import("../types.js").IGetLedgerRecordsByChargesIdsResult[], string>; private batchLedgerRecordsByFinancialEntityIds; getLedgerRecordsByFinancialEntityIdLoader: DataLoader<string, import("../types.js").IGetLedgerRecordsByFinancialEntityIdsResult[], string>; getLedgerRecordsByDates(params: IGetLedgerRecordsByDatesParams): Promise<import("../types.js").IGetLedgerRecordsByDatesResult[]>; getLedgerRecordsByFilters(params: LedgerRecordsFiltersParams): Promise<import("../types.js").IGetLedgerRecordsByFiltersResult[]>; getLedgerBalanceToDate(date: TimelessDateString): Promise<import("../types.js").IGetLedgerBalanceToDateResult[]>; updateLedgerRecord(params: IUpdateLedgerRecordParams): Promise<import("../types.js").IUpdateLedgerRecordResult[]>; insertLedgerRecords(params: IInsertLedgerRecordsParams): Promise<import("../types.js").IInsertLedgerRecordsResult[]>; private deleteLedgerRecordsByIds; deleteLedgerRecordsByIdLoader: DataLoader<string, undefined, string>; private deleteLedgerRecordsByChargeIds; deleteLedgerRecordsByChargeIdLoader: DataLoader<string, undefined, string>; replaceLedgerRecordsChargeId(params: IReplaceLedgerRecordsChargeIdParams): Promise<import("../types.js").IReplaceLedgerRecordsChargeIdResult[]>; lockLedgerRecords(date: TimelessDateString): Promise<import("../types.js").ILockLedgerRecordsResult[]>; clearCache(): void; }