UNPKG

@accounter/server

Version:
77 lines (65 loc) 1.98 kB
import type { YogaInitialContext } from 'graphql-yoga'; import pg from 'pg'; import type { CorporateTaxRulingComplianceReport } from '../../__generated__/types.js'; import type { env } from '../../environment.js'; import type { IGetChargesByIdsResult } from '../../modules/charges/types.js'; import type { RawAuth } from '../../plugins/auth-plugin.js'; import type { Currency } from '../../shared/enums.js'; export type Environment = typeof env; export type CurrencySum = { credit: number; debit: number; total: number; }; export type RawBusinessTransactionsSum = Record<Currency, CurrencySum> & { businessId: string; }; export type VatExtendedCharge = IGetChargesByIdsResult & { vatAfterDeduction: number; amountBeforeVAT: number; amountBeforeFullVAT: number; }; export type CorporateTaxRulingComplianceReportProto = Omit< CorporateTaxRulingComplianceReport, 'differences' > & { chargeIds: Set<string>; }; export interface DocumentSuggestionsProto { ownerId?: string; counterpartyId?: string; amount?: { amount: number; currency: Currency; }; isIncome?: boolean; } export type BusinessTransactionProto = { amount: number; businessId: string; counterAccountId?: string; currency: Currency; details?: string; isCredit: boolean; ownerID: string; foreignAmount: number; date: Date; reference?: string; chargeId: string; }; export type AccounterContext = YogaInitialContext & { env: Environment; pool: pg.Pool; rawAuth?: RawAuth; dbClientsToDispose?: { dispose: () => Promise<void> }[]; }; type addZero<T> = T | 0; type oneToFour = 1 | 2 | 3 | 4; type oneToNine = oneToFour | 5 | 6 | 7 | 8 | 9; type d = addZero<oneToNine>; type YYYY = `20${addZero<oneToFour>}${d}`; type MM = `0${oneToNine}` | `1${0 | 1 | 2}`; type DD = `${0}${oneToNine}` | `${1 | 2}${d}` | `3${0 | 1}`; export declare type TimelessDateString = `${YYYY}-${MM}-${DD}`; export type * from './ledger.js'; export type * from './utils.js';