@accounter/server
Version:
Accounter GraphQL server
57 lines (56 loc) • 2.8 kB
TypeScript
import { Injector } from 'graphql-modules';
import type { FinancialAmount } from '../../../__generated__/types.js';
import { Currency } from '../../../shared/enums.js';
import type { IGetChargesByFiltersResult, IGetChargesByIdsResult } from '../types.js';
/**
* Charge reference accepted by the meta helpers: a charge id (resolved via the
* by-id loader) or an already-loaded charge row. Passing the row from
* `getChargesByFilters` unlocks the enriched fast path — the aggregates were
* already computed by that query, so no child-table loads are needed.
*/
export type ChargeRef = string | IGetChargesByIdsResult;
/**
* Whether this charge row came from `getChargesByFilters` and carries the
* precomputed per-charge aggregates. `abs_event_amount` is selected only by
* that query, so it doubles as the marker. The `js_*`-derived columns mirror
* the JS meta helpers exactly (fee-aware amounts, debit_timestamp-based dates,
* debtor-sign document sums), so serving them from the row is
* behavior-preserving.
*/
export declare function isEnrichedFilteredCharge(charge: IGetChargesByIdsResult): charge is IGetChargesByIdsResult & IGetChargesByFiltersResult;
export declare function calculateTotalAmount(chargeRef: ChargeRef, injector: Injector, defaultLocalCurrency: Currency): Promise<FinancialAmount | null>;
export declare function getChargeBusinesses(chargeRef: ChargeRef, injector: Injector): Promise<{
allBusinessIds: import("../types.js").stringArray;
mainBusinessId: string | null;
}>;
export declare function getChargeDocumentsMeta(chargeRef: ChargeRef, injector: Injector): Promise<{
receiptAmount: number;
receiptCount: number;
invoiceAmount: number;
invoiceCount: number;
documentsAmount: number | null;
documentsVatAmount: number | null;
documentsCount: number;
documentsCurrency: Currency | null;
invalidDocuments: boolean;
documentsMinDate: Date | null;
documentsMaxDate: Date | null;
}>;
export declare function getChargeTransactionsMeta(chargeRef: ChargeRef, injector: Injector): Promise<{
transactionsCount: number;
transactionsAmount: number | null;
transactionsCurrencies: Currency[];
transactionsCurrency: Currency | null;
invalidTransactions: boolean;
transactionsMinDebitDate: Date | null;
transactionsMinEventDate: Date | null;
transactionsMaxDebitDate: Date | null;
transactionsMaxEventDate: Date | null;
}>;
export declare function getChargeLedgerMeta(chargeRef: ChargeRef, injector: Injector): Promise<{
ledgerMinValueDate: Date | null;
ledgerMinInvoiceDate: Date | null;
ledgerMaxValueDate: Date | null;
ledgerMaxInvoiceDate: Date | null;
}>;
export declare function getChargeTaxCategoryId(chargeRef: ChargeRef, injector: Injector): Promise<string | null>;