/** * Fragment payout ledger — the bot author's accounting surface. * * Fragment Corp redeems your accumulated XTR balance into TON paid to * the configured wallet. That payout is the **income event** for * Spanish autónomo IRPF purposes (CLAUDE.md §4); the per-charge log on * Telegram's side is informational. We persist each payout you receive * here, optionally tagged with the Spanish factura number, and provide * an `export()` helper that joins charges falling in the payout's time * window — that's what your gestor needs. * * Calling pattern (called by the bot author, NOT from inside an event * handler): * * import { Bot } from 'gramio' * const bot = new Bot(token); await bot.start() * * // After confirming a Fragment payout to your TON wallet: * await payments.payouts.record(bot, { * ton: 12.34, * eurAtReceipt: 47.20, * fromMs: Date.parse('2026-05-01'), * toMs: Date.parse('2026-06-01'), * }) * * // For the monthly gestor export: * const data = await payments.payouts.exportForUsers(bot, userIds, { * from: Date.parse('2026-05-01'), * to: Date.parse('2026-06-01'), * }) * * Fragment doesn't tag payouts with specific charges, so the join is * **time-windowed**: payouts get `{ fromMs, toMs }` and the export * pulls every `ChargeRecord` whose `receivedAt` falls inside. */ import type { AnyBot } from "gramio"; import type { PaymentsStores } from "./stores.js"; import type { ChargeRecord, PayoutRecord } from "./types.js"; export type RecordPayoutInput = { /** Amount of TON received from Fragment. */ ton: number; /** EUR value at receipt time (snapshot — exchange rates move). */ eurAtReceipt: number; /** Window covered by this payout, lower bound (ms since epoch). */ fromMs: number; /** Window covered by this payout, upper bound (ms since epoch). */ toMs: number; /** Optional Spanish factura number issued for this payout. */ facturaNumber?: string; /** Override the auto-generated batchId. Default: `payout_${toMs}`. */ batchId?: string; }; export declare const recordPayout: (bot: AnyBot, stores: PaymentsStores, input: RecordPayoutInput) => Promise; export declare const listPayouts: (bot: AnyBot, stores: PaymentsStores) => Promise; export type ExportInput = { /** Window lower bound, ms since epoch. */ from: number; /** Window upper bound, ms since epoch. */ to: number; }; export type ExportResult = { payouts: PayoutRecord[]; charges: ChargeRecord[]; }; /** * Build the payout-only dataset for a time window. Returns every * `PayoutRecord` whose `[fromMs, toMs]` overlaps the requested window. * * The `charges` field is empty: charge indexes are per user, so no * single call can enumerate everybody's. Use `exportPayoutsForUsers` * with an explicit user-id list. */ export declare const exportPayouts: (bot: AnyBot, stores: PaymentsStores, input: ExportInput) => Promise; /** * Same as `exportPayouts` but with an explicit user-id list to scan. * Pulls every NON-refunded `ChargeRecord` whose `receivedAt` falls in * the requested window, joined by time rather than payout identity * (Fragment doesn't expose that mapping). */ export declare const exportPayoutsForUsers: (bot: AnyBot, stores: PaymentsStores, userIds: ReadonlyArray, input: ExportInput) => Promise; export type PayoutsApi = { record: (bot: AnyBot, input: RecordPayoutInput) => Promise; list: (bot: AnyBot) => Promise; export: (bot: AnyBot, input: ExportInput) => Promise; exportForUsers: (bot: AnyBot, userIds: ReadonlyArray, input: ExportInput) => Promise; }; export declare const buildPayoutsApi: (stores: PaymentsStores) => PayoutsApi; //# sourceMappingURL=payouts.d.ts.map