@burdenoff/microfe-billing 2026.515.4 → 2026.515.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"InvoicesListPage.d.ts","sourceRoot":"","sources":["../../../../../src/billing/modules/billing/pages/InvoicesListPage.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAwC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAwBtE,eAAO,MAAM,gBAAgB,EAAE,EAgV9B,CAAC"}
1
+ {"version":3,"file":"InvoicesListPage.d.ts","sourceRoot":"","sources":["../../../../../src/billing/modules/billing/pages/InvoicesListPage.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAwC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAwBtE,eAAO,MAAM,gBAAgB,EAAE,EAmV9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"InvoicesListPage.js","names":[],"sources":["../../../../../src/billing/modules/billing/pages/InvoicesListPage.tsx"],"sourcesContent":["/**\n * Billing Module - Invoices List Page\n * Displays all invoices for the current tenant\n */\n\nimport { useEffect, useState, useMemo, useRef, type FC } from 'react';\nimport { useSearchParams } from 'react-router-dom';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { usePaginatedInvoices } from '../hooks/useInvoices';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport {\n formatCurrency,\n formatDate,\n formatInvoiceStatus,\n formatInvoiceNumber,\n} from '../../../shared/utils/format';\nimport { withBillingAccountId } from '../../../shared/utils/navigation';\nimport { getInvoiceStatusColor, getStatusBadgeClasses } from '../../../shared/utils/status';\nimport type { Invoice, InvoiceStatus } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\ntype FilterStatus = 'all' | InvoiceStatus;\n\nexport const InvoicesListPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n const [searchParams] = useSearchParams();\n const urlBillingAccountId = searchParams.get('billingAccountId') ?? undefined;\n\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({ fetchPolicy: 'cache-first' });\n const billingAccounts = accountsData?.getBillingAccountsByOrg ?? [];\n\n // undefined = user hasn't explicitly chosen yet → auto-pick default\n // null = user explicitly chose \"All Accounts\"\n // string = user explicitly chose a specific account\n const [explicitAccountId, setExplicitAccountId] = useState<string | null | undefined>(\n urlBillingAccountId\n );\n\n useEffect(() => {\n setExplicitAccountId(urlBillingAccountId);\n }, [urlBillingAccountId]);\n\n const defaultAccountId = useMemo(\n () =>\n (billingAccounts.find((a: BillingAccountItem) => a.isDefault) ?? billingAccounts[0])?.id ??\n undefined,\n [billingAccounts]\n );\n\n // Resolved selection: explicit choice wins; before any choice, use the default\n const selectedAccountId: string | null =\n explicitAccountId !== undefined ? explicitAccountId : (defaultAccountId ?? null);\n\n const [filterStatus, setFilterStatus] = useState<FilterStatus>('all');\n const [searchQuery, setSearchQuery] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n const [page, setPage] = useState(1);\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n debounceTimer.current = setTimeout(() => {\n setDebouncedSearch(searchQuery);\n setPage(1);\n }, 400);\n return () => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n };\n }, [searchQuery]);\n\n const { invoices, totalPages, isLoading, error, refetch } = usePaginatedInvoices({\n billingAccountId: selectedAccountId ?? undefined,\n status: filterStatus !== 'all' ? (filterStatus as InvoiceStatus) : undefined,\n search: debouncedSearch || undefined,\n page,\n pageSize: 20,\n });\n\n // Permission check\n if (!permissions.canViewInvoices) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"w-12 h-12 mx-auto rounded-full bg-muted flex items-center justify-center\">\n <svg\n className=\"w-6 h-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">\n {tr('billing.accessDenied.title', 'Access Denied')}\n </h2>\n <p className=\"text-sm text-muted-foreground max-w-sm\">\n {tr('billing.invoices.noViewPermission', \"You don't have permission to view invoices.\")}\n </p>\n </div>\n </div>\n );\n }\n\n // Loading state\n if (isLoading && invoices.length === 0) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-muted animate-pulse rounded\" />\n <div className=\"space-y-3\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"border border-border rounded-lg p-4\">\n <div className=\"flex items-center gap-4\">\n <div className=\"h-10 w-10 bg-muted animate-pulse rounded\" />\n <div className=\"flex-1 space-y-2\">\n <div className=\"h-4 w-32 bg-muted animate-pulse rounded\" />\n <div className=\"h-3 w-48 bg-muted animate-pulse rounded\" />\n </div>\n </div>\n </div>\n ))}\n </div>\n </div>\n );\n }\n\n // Error state\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <div className=\"w-12 h-12 mx-auto rounded-full bg-destructive/10 flex items-center justify-center\">\n <svg\n className=\"w-6 h-6 text-destructive\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">\n {tr('billing.invoices.failedToLoad', 'Failed to load invoices')}\n </h2>\n <p className=\"text-sm text-muted-foreground\">{error.message}</p>\n <button\n onClick={() => refetch()}\n className=\"px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors\"\n >\n Try Again\n </button>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n {/* Header */}\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <h1 className=\"text-2xl font-bold text-foreground\">\n {tr('billing.invoices.title', 'Invoices')}\n </h1>\n <p className=\"text-sm text-muted-foreground mt-1\">\n {tr('billing.invoices.subtitle', 'View and manage your billing invoices')}\n </p>\n </div>\n {billingAccounts.length > 1 && (\n <div className=\"flex items-center gap-2\">\n <label className=\"text-sm text-muted-foreground whitespace-nowrap\">\n Billing Account\n </label>\n <select\n value={selectedAccountId ?? ''}\n onChange={(e) => setExplicitAccountId(e.target.value || null)}\n className=\"text-sm border border-border rounded-md bg-background text-foreground px-3 py-2 focus:outline-none focus:ring-2 focus:ring-primary\"\n >\n <option value=\"\">All Accounts</option>\n {billingAccounts.map((account: BillingAccountItem) => (\n <option key={account.id ?? ''} value={account.id ?? ''}>\n {account.name ?? account.email ?? account.id}\n {account.isDefault ? ' (Default)' : ''}\n </option>\n ))}\n </select>\n </div>\n )}\n </div>\n\n {/* Filters */}\n <div className=\"flex flex-wrap items-center gap-4 pb-4 border-b border-border\">\n {/* Status Filter */}\n <div className=\"inline-flex rounded-lg border border-border p-1 bg-muted/50 flex-wrap\">\n {(['all', 'OPEN', 'PAID', 'DRAFT', 'VOID'] as FilterStatus[]).map((status) => (\n <button\n key={status}\n onClick={() => { setFilterStatus(status); setPage(1); }}\n className={`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${\n filterStatus === status\n ? 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground'\n }`}\n >\n {status === 'all' ? 'All' : formatInvoiceStatus(status as InvoiceStatus)}\n </button>\n ))}\n </div>\n\n {/* Search */}\n <div className=\"relative flex-1 min-w-[200px] max-w-md\">\n <svg\n className=\"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z\"\n />\n </svg>\n <input\n type=\"text\"\n placeholder={tr('billing.invoices.searchPlaceholder', 'Search by invoice number...')}\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-4 py-2 text-sm border border-border rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n </div>\n </div>\n\n {/* Invoices Table */}\n {!isLoading && invoices.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg\">\n <div className=\"w-12 h-12 rounded-full bg-muted flex items-center justify-center mb-4\">\n <svg\n className=\"w-6 h-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z\"\n />\n </svg>\n </div>\n <h3 className=\"text-lg font-medium text-foreground\">\n {tr('billing.invoices.noInvoicesFound', 'No invoices found')}\n </h3>\n <p className=\"text-sm text-muted-foreground mt-1\">\n {filterStatus !== 'all' || debouncedSearch\n ? tr('billing.invoices.noInvoicesFiltered', 'No invoices match your filters.')\n : tr('billing.invoices.noInvoicesYet', \"You don't have any invoices yet.\")}\n </p>\n </div>\n ) : (\n <>\n <div className=\"border border-border rounded-lg overflow-hidden\">\n <table className=\"w-full\">\n <thead className=\"bg-muted/50\">\n <tr>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground\">\n Invoice\n </th>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground\">\n Status\n </th>\n {!selectedAccountId && billingAccounts.length > 1 && (\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden lg:table-cell\">\n Account\n </th>\n )}\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden sm:table-cell\">\n Date\n </th>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden md:table-cell\">\n Due Date\n </th>\n <th className=\"text-right px-4 py-3 text-sm font-medium text-muted-foreground\">\n Amount\n </th>\n <th className=\"text-right px-4 py-3 text-sm font-medium text-muted-foreground\">\n Actions\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border\">\n {invoices.map((invoice) => (\n <InvoiceRow\n key={invoice.id}\n invoice={invoice}\n onView={() =>\n navigateTo(\n withBillingAccountId(`/invoices/${invoice.id}`, invoice.billingAccountId)\n )\n }\n canPay={permissions.canPayInvoice}\n canVoid={permissions.canVoidInvoice}\n showAccount={!selectedAccountId && billingAccounts.length > 1}\n accountName={\n billingAccounts.find(\n (a: BillingAccountItem) => a.id === invoice.billingAccountId\n )?.name ?? null\n }\n />\n ))}\n </tbody>\n </table>\n </div>\n\n {totalPages > 1 && (\n <div className=\"flex items-center justify-between pt-2\">\n <p className=\"text-sm text-muted-foreground\">\n Page {page} of {totalPages}\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n onClick={() => setPage((p) => Math.max(1, p - 1))}\n disabled={page <= 1}\n className=\"px-3 py-1.5 text-sm font-medium border border-border rounded-md bg-background text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n Previous\n </button>\n <button\n onClick={() => setPage((p) => Math.min(totalPages, p + 1))}\n disabled={page >= totalPages}\n className=\"px-3 py-1.5 text-sm font-medium border border-border rounded-md bg-background text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n Next\n </button>\n </div>\n </div>\n )}\n </>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Invoice Row Component\n// ============================================================================\n\ninterface InvoiceRowProps {\n invoice: Invoice;\n onView: () => void;\n canPay: boolean;\n canVoid: boolean;\n showAccount?: boolean;\n accountName?: string | null;\n}\n\nconst InvoiceRow: FC<InvoiceRowProps> = ({\n invoice,\n onView,\n canPay,\n canVoid,\n showAccount = false,\n accountName,\n}) => {\n const statusColor = getInvoiceStatusColor(invoice.status);\n const isOpen = invoice.status === ('OPEN' as InvoiceStatus);\n const isDraft = invoice.status === ('DRAFT' as InvoiceStatus);\n\n return (\n <tr className=\"hover:bg-muted/30 transition-colors\">\n <td className=\"px-4 py-4\">\n <button\n onClick={onView}\n className=\"font-medium text-foreground hover:text-primary transition-colors\"\n >\n {formatInvoiceNumber(invoice.invoiceNumber)}\n </button>\n {(invoice.itemDescription ?? invoice.subscription?.plan?.name) && (\n <p className=\"text-sm text-muted-foreground mt-0.5\">\n {invoice.itemDescription ?? invoice.subscription?.plan?.name}\n </p>\n )}\n </td>\n <td className=\"px-4 py-4\">\n <span\n className={`inline-flex px-2 py-1 text-xs font-medium rounded ${getStatusBadgeClasses(statusColor)}`}\n >\n {formatInvoiceStatus(invoice.status)}\n </span>\n </td>\n {showAccount && (\n <td className=\"px-4 py-4 hidden lg:table-cell\">\n {accountName ? (\n <span className=\"inline-flex items-center px-2 py-0.5 text-xs font-medium rounded-full bg-muted text-muted-foreground border border-border\">\n {accountName}\n </span>\n ) : (\n <span className=\"text-sm text-muted-foreground\">—</span>\n )}\n </td>\n )}\n <td className=\"px-4 py-4 text-sm text-muted-foreground hidden sm:table-cell\">\n {formatDate(invoice.createdAt, 'short')}\n </td>\n <td className=\"px-4 py-4 text-sm text-muted-foreground hidden md:table-cell\">\n {invoice.dueDate ? formatDate(invoice.dueDate, 'short') : '—'}\n </td>\n <td className=\"px-4 py-4 text-right font-medium text-foreground\">\n {formatCurrency(invoice.total, invoice.currency)}\n </td>\n <td className=\"px-4 py-4 text-right\">\n <div className=\"flex items-center justify-end gap-2\">\n {invoice.invoiceUrl ? (\n <a\n href={invoice.invoiceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors\"\n >\n View\n </a>\n ) : (\n <button\n onClick={onView}\n className=\"px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors\"\n >\n View\n </button>\n )}\n {invoice.pdfUrl && (\n <a\n href={invoice.pdfUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-primary hover:bg-primary/10 rounded-md transition-colors\"\n >\n PDF\n </a>\n )}\n {isOpen && canPay && (\n <button className=\"px-3 py-1.5 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors\">\n Pay\n </button>\n )}\n {(isOpen || isDraft) && canVoid && (\n <button className=\"px-3 py-1.5 text-sm font-medium text-destructive hover:bg-destructive/10 rounded-md transition-colors\">\n Void\n </button>\n )}\n </div>\n </td>\n </tr>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA6BA,IAAa,UAA6B;CACxC,IAAM,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAA6B;EACpD,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe,IAAM,IAAW;IAEnC,IAAa,GAAo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;IACJ,CAAA;GACJ,KACC,kBAAC,MAAD;IAAI,WAAU;cACX,IACC,kBAAC,QAAD;KAAM,WAAU;eACb;KACI,CAAA,GAEP,kBAAC,QAAD;KAAM,WAAU;eAAgC;KAAQ,CAAA;IAEvD,CAAA;GAEP,kBAAC,MAAD;IAAI,WAAU;cACX,EAAW,EAAQ,WAAW,QAAQ;IACpC,CAAA;GACL,kBAAC,MAAD;IAAI,WAAU;cACX,EAAQ,UAAU,EAAW,EAAQ,SAAS,QAAQ,GAAG;IACvD,CAAA;GACL,kBAAC,MAAD;IAAI,WAAU;cACX,EAAe,EAAQ,OAAO,EAAQ,SAAS;IAC7C,CAAA;GACL,kBAAC,MAAD;IAAI,WAAU;cACZ,kBAAC,OAAD;KAAK,WAAU;eAAf;MACG,EAAQ,aACP,kBAAC,KAAD;OACE,MAAM,EAAQ;OACd,QAAO;OACP,KAAI;OACJ,WAAU;iBACX;OAEG,CAAA,GAEJ,kBAAC,UAAD;OACE,SAAS;OACT,WAAU;iBACX;OAEQ,CAAA;MAEV,EAAQ,UACP,kBAAC,KAAD;OACE,MAAM,EAAQ;OACd,QAAO;OACP,KAAI;OACJ,WAAU;iBACX;OAEG,CAAA;MAEL,KAAU,KACT,kBAAC,UAAD;OAAQ,WAAU;iBAAsH;OAE/H,CAAA;OAET,KAAU,MAAY,KACtB,kBAAC,UAAD;OAAQ,WAAU;iBAAwG;OAEjH,CAAA;MAEP;;IACH,CAAA;GACF"}
1
+ {"version":3,"file":"InvoicesListPage.js","names":[],"sources":["../../../../../src/billing/modules/billing/pages/InvoicesListPage.tsx"],"sourcesContent":["/**\n * Billing Module - Invoices List Page\n * Displays all invoices for the current tenant\n */\n\nimport { useEffect, useState, useMemo, useRef, type FC } from 'react';\nimport { useSearchParams } from 'react-router-dom';\nimport { useBillingNavigate } from '../../../hooks/useBillingNavigate';\nimport { usePaginatedInvoices } from '../hooks/useInvoices';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n useGetBillingAccountsByOrgQuery,\n type GetBillingAccountsByOrgQuery,\n} from '../../../../generated/global-operations';\n\ntype BillingAccountItem = GetBillingAccountsByOrgQuery['getBillingAccountsByOrg'][number];\nimport {\n formatCurrency,\n formatDate,\n formatInvoiceStatus,\n formatInvoiceNumber,\n} from '../../../shared/utils/format';\nimport { withBillingAccountId } from '../../../shared/utils/navigation';\nimport { getInvoiceStatusColor, getStatusBadgeClasses } from '../../../shared/utils/status';\nimport type { Invoice, InvoiceStatus } from '../../../shared/types';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\ntype FilterStatus = 'all' | InvoiceStatus;\n\nexport const InvoicesListPage: FC = () => {\n const { t } = useI18n();\n const tr = (key: string, fallback: string): string => {\n const translated = t(key);\n return translated === key ? fallback : translated;\n };\n const navigateTo = useBillingNavigate();\n const permissions = useBillingPermissions();\n const [searchParams] = useSearchParams();\n const urlBillingAccountId = searchParams.get('billingAccountId') ?? undefined;\n\n const { data: accountsData } = useGetBillingAccountsByOrgQuery({ fetchPolicy: 'cache-first' });\n const billingAccounts = accountsData?.getBillingAccountsByOrg ?? [];\n\n // undefined = user hasn't explicitly chosen yet → auto-pick default\n // null = user explicitly chose \"All Accounts\"\n // string = user explicitly chose a specific account\n const [explicitAccountId, setExplicitAccountId] = useState<string | null | undefined>(\n urlBillingAccountId\n );\n\n useEffect(() => {\n setExplicitAccountId(urlBillingAccountId);\n }, [urlBillingAccountId]);\n\n const defaultAccountId = useMemo(\n () =>\n (billingAccounts.find((a: BillingAccountItem) => a.isDefault) ?? billingAccounts[0])?.id ??\n undefined,\n [billingAccounts]\n );\n\n // Resolved selection: explicit choice wins; before any choice, use the default\n const selectedAccountId: string | null =\n explicitAccountId !== undefined ? explicitAccountId : (defaultAccountId ?? null);\n\n const [filterStatus, setFilterStatus] = useState<FilterStatus>('all');\n const [searchQuery, setSearchQuery] = useState('');\n const [debouncedSearch, setDebouncedSearch] = useState('');\n const [page, setPage] = useState(1);\n const debounceTimer = useRef<ReturnType<typeof setTimeout> | null>(null);\n\n useEffect(() => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n debounceTimer.current = setTimeout(() => {\n setDebouncedSearch(searchQuery);\n setPage(1);\n }, 400);\n return () => {\n if (debounceTimer.current) clearTimeout(debounceTimer.current);\n };\n }, [searchQuery]);\n\n const { invoices, totalPages, isLoading, error, refetch } = usePaginatedInvoices({\n billingAccountId: selectedAccountId ?? undefined,\n status: filterStatus !== 'all' ? (filterStatus as InvoiceStatus) : undefined,\n search: debouncedSearch || undefined,\n page,\n pageSize: 20,\n });\n\n // Permission check\n if (!permissions.canViewInvoices) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"w-12 h-12 mx-auto rounded-full bg-muted flex items-center justify-center\">\n <svg\n className=\"w-6 h-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">\n {tr('billing.accessDenied.title', 'Access Denied')}\n </h2>\n <p className=\"text-sm text-muted-foreground max-w-sm\">\n {tr('billing.invoices.noViewPermission', \"You don't have permission to view invoices.\")}\n </p>\n </div>\n </div>\n );\n }\n\n // Loading state\n if (isLoading && invoices.length === 0) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-48 bg-muted animate-pulse rounded\" />\n <div className=\"space-y-3\">\n {[1, 2, 3, 4, 5].map((i) => (\n <div key={i} className=\"border border-border rounded-lg p-4\">\n <div className=\"flex items-center gap-4\">\n <div className=\"h-10 w-10 bg-muted animate-pulse rounded\" />\n <div className=\"flex-1 space-y-2\">\n <div className=\"h-4 w-32 bg-muted animate-pulse rounded\" />\n <div className=\"h-3 w-48 bg-muted animate-pulse rounded\" />\n </div>\n </div>\n </div>\n ))}\n </div>\n </div>\n );\n }\n\n // Error state\n if (error) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-4\">\n <div className=\"w-12 h-12 mx-auto rounded-full bg-destructive/10 flex items-center justify-center\">\n <svg\n className=\"w-6 h-6 text-destructive\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">\n {tr('billing.invoices.failedToLoad', 'Failed to load invoices')}\n </h2>\n <p className=\"text-sm text-muted-foreground\">{error.message}</p>\n <button\n onClick={() => refetch()}\n className=\"px-4 py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors\"\n >\n Try Again\n </button>\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-6\">\n {/* Header */}\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <h1 className=\"text-2xl font-bold text-foreground\">\n {tr('billing.invoices.title', 'Invoices')}\n </h1>\n <p className=\"text-sm text-muted-foreground mt-1\">\n {tr('billing.invoices.subtitle', 'View and manage your billing invoices')}\n </p>\n </div>\n {billingAccounts.length > 1 && (\n <div className=\"flex items-center gap-2\">\n <label className=\"text-sm text-muted-foreground whitespace-nowrap\">\n Billing Account\n </label>\n <select\n value={selectedAccountId ?? ''}\n onChange={(e) => setExplicitAccountId(e.target.value || null)}\n className=\"text-sm border border-border rounded-md bg-background text-foreground px-3 py-2 focus:outline-none focus:ring-2 focus:ring-primary\"\n >\n <option value=\"\">All Accounts</option>\n {billingAccounts.map((account: BillingAccountItem) => (\n <option key={account.id ?? ''} value={account.id ?? ''}>\n {account.name ?? account.email ?? account.id}\n {account.isDefault ? ' (Default)' : ''}\n </option>\n ))}\n </select>\n </div>\n )}\n </div>\n\n {/* Filters */}\n <div className=\"flex flex-wrap items-center gap-4 pb-4 border-b border-border\">\n {/* Status Filter */}\n <div className=\"inline-flex rounded-lg border border-border p-1 bg-muted/50 flex-wrap\">\n {(['all', 'OPEN', 'PAID', 'DRAFT', 'VOID'] as FilterStatus[]).map((status) => (\n <button\n key={status}\n onClick={() => {\n setFilterStatus(status);\n setPage(1);\n }}\n className={`px-3 py-1.5 text-sm font-medium rounded-md transition-colors ${\n filterStatus === status\n ? 'bg-background text-foreground shadow-sm'\n : 'text-muted-foreground hover:text-foreground'\n }`}\n >\n {status === 'all' ? 'All' : formatInvoiceStatus(status as InvoiceStatus)}\n </button>\n ))}\n </div>\n\n {/* Search */}\n <div className=\"relative flex-1 min-w-[200px] max-w-md\">\n <svg\n className=\"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z\"\n />\n </svg>\n <input\n type=\"text\"\n placeholder={tr('billing.invoices.searchPlaceholder', 'Search by invoice number...')}\n value={searchQuery}\n onChange={(e) => setSearchQuery(e.target.value)}\n className=\"w-full pl-[3.25rem] pr-4 py-2 text-sm border border-border rounded-md bg-background text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-primary focus:border-transparent\"\n />\n </div>\n </div>\n\n {/* Invoices Table */}\n {!isLoading && invoices.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-12 border border-dashed border-border rounded-lg\">\n <div className=\"w-12 h-12 rounded-full bg-muted flex items-center justify-center mb-4\">\n <svg\n className=\"w-6 h-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z\"\n />\n </svg>\n </div>\n <h3 className=\"text-lg font-medium text-foreground\">\n {tr('billing.invoices.noInvoicesFound', 'No invoices found')}\n </h3>\n <p className=\"text-sm text-muted-foreground mt-1\">\n {filterStatus !== 'all' || debouncedSearch\n ? tr('billing.invoices.noInvoicesFiltered', 'No invoices match your filters.')\n : tr('billing.invoices.noInvoicesYet', \"You don't have any invoices yet.\")}\n </p>\n </div>\n ) : (\n <>\n <div className=\"border border-border rounded-lg overflow-hidden\">\n <table className=\"w-full\">\n <thead className=\"bg-muted/50\">\n <tr>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground\">\n Invoice\n </th>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground\">\n Status\n </th>\n {!selectedAccountId && billingAccounts.length > 1 && (\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden lg:table-cell\">\n Account\n </th>\n )}\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden sm:table-cell\">\n Date\n </th>\n <th className=\"text-left px-4 py-3 text-sm font-medium text-muted-foreground hidden md:table-cell\">\n Due Date\n </th>\n <th className=\"text-right px-4 py-3 text-sm font-medium text-muted-foreground\">\n Amount\n </th>\n <th className=\"text-right px-4 py-3 text-sm font-medium text-muted-foreground\">\n Actions\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border\">\n {invoices.map((invoice) => (\n <InvoiceRow\n key={invoice.id}\n invoice={invoice}\n onView={() =>\n navigateTo(\n withBillingAccountId(`/invoices/${invoice.id}`, invoice.billingAccountId)\n )\n }\n canPay={permissions.canPayInvoice}\n canVoid={permissions.canVoidInvoice}\n showAccount={!selectedAccountId && billingAccounts.length > 1}\n accountName={\n billingAccounts.find(\n (a: BillingAccountItem) => a.id === invoice.billingAccountId\n )?.name ?? null\n }\n />\n ))}\n </tbody>\n </table>\n </div>\n\n {totalPages > 1 && (\n <div className=\"flex items-center justify-between pt-2\">\n <p className=\"text-sm text-muted-foreground\">\n Page {page} of {totalPages}\n </p>\n <div className=\"flex items-center gap-2\">\n <button\n onClick={() => setPage((p) => Math.max(1, p - 1))}\n disabled={page <= 1}\n className=\"px-3 py-1.5 text-sm font-medium border border-border rounded-md bg-background text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n Previous\n </button>\n <button\n onClick={() => setPage((p) => Math.min(totalPages, p + 1))}\n disabled={page >= totalPages}\n className=\"px-3 py-1.5 text-sm font-medium border border-border rounded-md bg-background text-foreground hover:bg-muted disabled:opacity-40 disabled:cursor-not-allowed transition-colors\"\n >\n Next\n </button>\n </div>\n </div>\n )}\n </>\n )}\n </div>\n );\n};\n\n// ============================================================================\n// Invoice Row Component\n// ============================================================================\n\ninterface InvoiceRowProps {\n invoice: Invoice;\n onView: () => void;\n canPay: boolean;\n canVoid: boolean;\n showAccount?: boolean;\n accountName?: string | null;\n}\n\nconst InvoiceRow: FC<InvoiceRowProps> = ({\n invoice,\n onView,\n canPay,\n canVoid,\n showAccount = false,\n accountName,\n}) => {\n const statusColor = getInvoiceStatusColor(invoice.status);\n const isOpen = invoice.status === ('OPEN' as InvoiceStatus);\n const isDraft = invoice.status === ('DRAFT' as InvoiceStatus);\n\n return (\n <tr className=\"hover:bg-muted/30 transition-colors\">\n <td className=\"px-4 py-4\">\n <button\n onClick={onView}\n className=\"font-medium text-foreground hover:text-primary transition-colors\"\n >\n {formatInvoiceNumber(invoice.invoiceNumber)}\n </button>\n {(invoice.itemDescription ?? invoice.subscription?.plan?.name) && (\n <p className=\"text-sm text-muted-foreground mt-0.5\">\n {invoice.itemDescription ?? invoice.subscription?.plan?.name}\n </p>\n )}\n </td>\n <td className=\"px-4 py-4\">\n <span\n className={`inline-flex px-2 py-1 text-xs font-medium rounded ${getStatusBadgeClasses(statusColor)}`}\n >\n {formatInvoiceStatus(invoice.status)}\n </span>\n </td>\n {showAccount && (\n <td className=\"px-4 py-4 hidden lg:table-cell\">\n {accountName ? (\n <span className=\"inline-flex items-center px-2 py-0.5 text-xs font-medium rounded-full bg-muted text-muted-foreground border border-border\">\n {accountName}\n </span>\n ) : (\n <span className=\"text-sm text-muted-foreground\">—</span>\n )}\n </td>\n )}\n <td className=\"px-4 py-4 text-sm text-muted-foreground hidden sm:table-cell\">\n {formatDate(invoice.createdAt, 'short')}\n </td>\n <td className=\"px-4 py-4 text-sm text-muted-foreground hidden md:table-cell\">\n {invoice.dueDate ? formatDate(invoice.dueDate, 'short') : '—'}\n </td>\n <td className=\"px-4 py-4 text-right font-medium text-foreground\">\n {formatCurrency(invoice.total, invoice.currency)}\n </td>\n <td className=\"px-4 py-4 text-right\">\n <div className=\"flex items-center justify-end gap-2\">\n {invoice.invoiceUrl ? (\n <a\n href={invoice.invoiceUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors\"\n >\n View\n </a>\n ) : (\n <button\n onClick={onView}\n className=\"px-3 py-1.5 text-sm font-medium text-foreground hover:bg-muted rounded-md transition-colors\"\n >\n View\n </button>\n )}\n {invoice.pdfUrl && (\n <a\n href={invoice.pdfUrl}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"px-3 py-1.5 text-sm font-medium text-primary hover:bg-primary/10 rounded-md transition-colors\"\n >\n PDF\n </a>\n )}\n {isOpen && canPay && (\n <button className=\"px-3 py-1.5 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors\">\n Pay\n </button>\n )}\n {(isOpen || isDraft) && canVoid && (\n <button className=\"px-3 py-1.5 text-sm font-medium text-destructive hover:bg-destructive/10 rounded-md transition-colors\">\n Void\n </button>\n )}\n </div>\n </td>\n </tr>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA6BA,IAAa,UAA6B;CACxC,IAAM,EAAE,SAAM,GAAS,EACjB,KAAM,GAAa,MAA6B;EACpD,IAAM,IAAa,EAAE,EAAI;AACzB,SAAO,MAAe,IAAM,IAAW;IAEnC,IAAa,GAAoB,EACjC,IAAc,GAAuB,EACrC,CAAC,KAAgB,GAAiB,EAClC,IAAsB,EAAa,IAAI,mBAAmB,IAAI,KAAA,GAE9D,EAAE,MAAM,MAAiB,EAAgC,EAAE,aAAa,eAAe,CAAC,EACxF,IAAkB,GAAc,2BAA2B,EAAE,EAK7D,CAAC,GAAmB,KAAwB,EAChD,EACD;AAED,SAAgB;AACd,IAAqB,EAAoB;IACxC,CAAC,EAAoB,CAAC;CAEzB,IAAM,IAAmB,SAEpB,EAAgB,MAAM,MAA0B,EAAE,UAAU,IAAI,EAAgB,KAAK,MACtF,KAAA,GACF,CAAC,EAAgB,CAClB,EAGK,IACJ,MAAsB,KAAA,IAAiC,KAAoB,OAAzC,GAE9B,CAAC,GAAc,KAAmB,EAAuB,MAAM,EAC/D,CAAC,GAAa,KAAkB,EAAS,GAAG,EAC5C,CAAC,GAAiB,KAAsB,EAAS,GAAG,EACpD,CAAC,GAAM,KAAW,EAAS,EAAE,EAC7B,IAAgB,EAA6C,KAAK;AAExE,UACM,EAAc,WAAS,aAAa,EAAc,QAAQ,EAC9D,EAAc,UAAU,iBAAiB;AAEvC,EADA,EAAmB,EAAY,EAC/B,EAAQ,EAAE;IACT,IAAI,QACM;AACX,EAAI,EAAc,WAAS,aAAa,EAAc,QAAQ;KAE/D,CAAC,EAAY,CAAC;CAEjB,IAAM,EAAE,aAAU,eAAY,cAAW,UAAO,eAAY,EAAqB;EAC/E,kBAAkB,KAAqB,KAAA;EACvC,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34,12 @@ export interface PayoutAccount {
34
34
  country?: string | null;
35
35
  currency: string;
36
36
  isDefault: boolean;
37
+ accountDetails?: Record<string, unknown> | null;
37
38
  }
38
39
  export interface PayoutRequest {
39
40
  id: string;
41
+ billingAccountId?: string | null;
42
+ requesterUserId?: string | null;
40
43
  requestedAmount: number;
41
44
  approvedAmount?: number | null;
42
45
  currency: string;
@@ -127,5 +130,6 @@ export declare function fetchAdminPayoutRequests(context: GatewayContext): Promi
127
130
  export declare function approvePayoutRequest(id: string, notes: string | null, context: GatewayContext): Promise<void>;
128
131
  export declare function rejectPayoutRequest(id: string, reason: string, context: GatewayContext): Promise<void>;
129
132
  export declare function processPayoutRequest(id: string, context: GatewayContext): Promise<void>;
133
+ export declare function markPayoutPaid(id: string, externalReference: string | null, notes: string | null, context: GatewayContext): Promise<void>;
130
134
  export {};
131
135
  //# sourceMappingURL=api.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/billing/modules/earnings/api.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,eAAe;IAC9B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,KAAK,CAAC;QACxB,QAAQ,EAAE,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC;QAC1C,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC,CAAC;CACJ;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,WAAW,GAAG,OAAO,GAAG,OAAO,CAAC;IAChD,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,WA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,wBAAsB,mBAAmB,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,iBAW5F;AAED,wBAAsB,oBAAoB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,iBAW7E;AAED,wBAAsB,cAAc,CAClC,EAAE,EAAE,MAAM,EACV,iBAAiB,EAAE,MAAM,GAAG,IAAI,EAChC,KAAK,EAAE,MAAM,GAAG,IAAI,EACpB,OAAO,EAAE,cAAc,iBAUxB"}
@@ -1,7 +1,7 @@
1
1
  import { gatewayGraphqlRequest as e } from "../../shared/utils/gatewayGraphql.js";
2
2
  import { directBillingGraphqlRequest as t } from "../../shared/utils/directBillingGraphql.js";
3
3
  import "../../shared/utils/index.js";
4
- import { AddPayoutAccountDocument as n, AdminPayoutRequestsDocument as r, AdminPayoutSummaryDocument as i, ApprovePayoutRequestDocument as a, ArchivePayoutAccountDocument as o, BillingDeveloperPortalRevenueDocument as s, MyEarningsEntriesDocument as c, MyEarningsSummaryDocument as l, MyPayoutAccountsDocument as u, MyPayoutRequestsDocument as d, ProcessPayoutRequestDocument as f, RejectPayoutRequestDocument as p, SetDefaultPayoutAccountDocument as m, UpdatePayoutAccountDocument as h } from "../../../generated/global-operations.js";
4
+ import { AddPayoutAccountDocument as n, AdminPayoutRequestsDocument as r, AdminPayoutSummaryDocument as i, ApprovePayoutRequestDocument as a, ArchivePayoutAccountDocument as o, BillingDeveloperPortalRevenueDocument as s, MarkPayoutPaidDocument as c, MyEarningsEntriesDocument as l, MyEarningsSummaryDocument as u, MyPayoutAccountsDocument as d, MyPayoutRequestsDocument as f, RejectPayoutRequestDocument as p, SetDefaultPayoutAccountDocument as m, UpdatePayoutAccountDocument as h } from "../../../generated/global-operations.js";
5
5
  //#region src/billing/modules/earnings/api.ts
6
6
  async function g(t, n) {
7
7
  let r = await e({
@@ -18,28 +18,28 @@ async function g(t, n) {
18
18
  async function _(e, n) {
19
19
  return (await t({
20
20
  ...n,
21
- query: l,
21
+ query: u,
22
22
  variables: { billingAccountId: e }
23
23
  })).myEarningsSummary;
24
24
  }
25
25
  async function v(e, n) {
26
26
  return (await t({
27
27
  ...n,
28
- query: c,
28
+ query: l,
29
29
  variables: { billingAccountId: e }
30
30
  })).myEarningsEntries.items;
31
31
  }
32
32
  async function y(e, n) {
33
33
  return (await t({
34
34
  ...n,
35
- query: u,
35
+ query: d,
36
36
  variables: { billingAccountId: e }
37
37
  })).myPayoutAccounts;
38
38
  }
39
39
  async function b(e, n) {
40
40
  return (await t({
41
41
  ...n,
42
- query: d,
42
+ query: f,
43
43
  variables: { billingAccountId: e }
44
44
  })).myPayoutRequests.items;
45
45
  }
@@ -109,14 +109,18 @@ async function k(e, n, r) {
109
109
  }
110
110
  });
111
111
  }
112
- async function A(e, n) {
112
+ async function A(e, n, r, i) {
113
113
  await t({
114
- ...n,
115
- query: f,
116
- variables: { id: e }
114
+ ...i,
115
+ query: c,
116
+ variables: {
117
+ id: e,
118
+ externalReference: n,
119
+ notes: r
120
+ }
117
121
  });
118
122
  }
119
123
  //#endregion
120
- export { x as addPayoutAccount, O as approvePayoutRequest, w as archivePayoutAccount, D as fetchAdminPayoutRequests, E as fetchAdminPayoutSummary, g as fetchDeveloperPortalRevenueDashboard, v as fetchEarningsEntries, _ as fetchEarningsSummary, y as fetchPayoutAccounts, b as fetchPayoutRequests, A as processPayoutRequest, k as rejectPayoutRequest, T as requestPayout, C as setDefaultPayoutAccount, S as updatePayoutAccount };
124
+ export { x as addPayoutAccount, O as approvePayoutRequest, w as archivePayoutAccount, D as fetchAdminPayoutRequests, E as fetchAdminPayoutSummary, g as fetchDeveloperPortalRevenueDashboard, v as fetchEarningsEntries, _ as fetchEarningsSummary, y as fetchPayoutAccounts, b as fetchPayoutRequests, A as markPayoutPaid, k as rejectPayoutRequest, T as requestPayout, C as setDefaultPayoutAccount, S as updatePayoutAccount };
121
125
 
122
126
  //# sourceMappingURL=api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","names":[],"sources":["../../../../src/billing/modules/earnings/api.ts"],"sourcesContent":["import { directBillingGraphqlRequest } from '../../shared/utils';\nimport { gatewayGraphqlRequest } from '../../shared/utils/gatewayGraphql';\nimport {\n AddPayoutAccountDocument,\n AdminPayoutRequestsDocument,\n AdminPayoutSummaryDocument,\n ApprovePayoutRequestDocument,\n ArchivePayoutAccountDocument,\n BillingDeveloperPortalRevenueDocument,\n MyEarningsEntriesDocument,\n MyEarningsSummaryDocument,\n MyPayoutAccountsDocument,\n MyPayoutRequestsDocument,\n ProcessPayoutRequestDocument,\n RejectPayoutRequestDocument,\n SetDefaultPayoutAccountDocument,\n UpdatePayoutAccountDocument,\n} from '../../../generated/global-operations';\n\nexport interface EarningsSummary {\n totalLifetimeAmount: number;\n availableAmount: number;\n reservedAmount: number;\n paidAmount: number;\n pendingAmount: number;\n moneyAmount: number;\n creditsAmount: number;\n categoryBreakdown?: Array<{\n category: 'AFFILIATE' | 'STORE' | 'OTHER';\n amount: number;\n count: number;\n }>;\n}\n\nexport interface EarningsEntry {\n id: string;\n sourceCategory: 'AFFILIATE' | 'STORE' | 'OTHER';\n sourceSubcategory?: string | null;\n description?: string | null;\n unitType: 'MONEY' | 'CREDITS';\n amount: number;\n currency: string;\n status: 'AVAILABLE' | 'RESERVED' | 'PAID' | 'REVERSED';\n createdAt: string;\n}\n\nexport interface PayoutAccount {\n id: string;\n label: string;\n type: 'BANK_ACCOUNT' | 'UPI' | 'WALLET';\n providerPreference: 'AUTO' | 'STRIPE' | 'RAZORPAY' | 'MANUAL';\n status: 'PENDING_VERIFICATION' | 'ACTIVE' | 'FAILED_VERIFICATION' | 'ARCHIVED';\n displayName?: string | null;\n accountLast4?: string | null;\n country?: string | null;\n currency: string;\n isDefault: boolean;\n}\n\nexport interface PayoutRequest {\n id: string;\n requestedAmount: number;\n approvedAmount?: number | null;\n currency: string;\n provider: 'AUTO' | 'STRIPE' | 'RAZORPAY' | 'MANUAL';\n status: 'REQUESTED' | 'APPROVED' | 'REJECTED' | 'PROCESSING' | 'PAID' | 'FAILED' | 'CANCELED';\n externalReference?: string | null;\n failureReason?: string | null;\n internalNotes?: string | null;\n userNotes?: string | null;\n createdAt: string;\n processedAt?: string | null;\n paidAt?: string | null;\n payoutAccount?: PayoutAccount | null;\n}\n\nexport interface PayoutAdminSummary {\n totalRequestedAmount: number;\n totalProcessingAmount: number;\n totalPaidAmount: number;\n pendingCount: number;\n failedCount: number;\n statusBreakdown?: Array<{ status: string; count: number; totalAmount: number }>;\n providerBreakdown?: Array<{ provider: string; count: number; totalAmount: number }>;\n}\n\nexport interface DeveloperPortalRevenueSummary {\n totalGrossRevenue: number;\n totalNetRevenue: number;\n totalPlatformFees: number;\n totalRefunds: number;\n totalRefundsCount: number;\n totalSales: number;\n pendingBalance: number;\n nextPayoutDate?: string | null;\n nextPayoutAmount?: number | null;\n}\n\nexport interface DeveloperPortalRevenueSale {\n id: string;\n grossAmount: number;\n netAmount: number;\n currency: string;\n pricingModel: string;\n status: string;\n purchasedAt: string;\n application?: {\n id: string;\n name: string;\n slug: string;\n } | null;\n}\n\nexport interface DeveloperPortalRevenuePayout {\n id: string;\n periodLabel?: string | null;\n netAmount: number;\n currency: string;\n status: string;\n scheduledAt?: string | null;\n completedAt?: string | null;\n}\n\nexport interface DeveloperPortalRevenueDashboard {\n summary: DeveloperPortalRevenueSummary | null;\n sales: DeveloperPortalRevenueSale[];\n payouts: DeveloperPortalRevenuePayout[];\n}\n\ninterface GatewayContext {\n apiGatewayUrl?: string;\n authToken?: string;\n orgId?: string;\n}\n\nexport async function fetchDeveloperPortalRevenueDashboard(\n organizationId: string,\n context: GatewayContext\n): Promise<DeveloperPortalRevenueDashboard> {\n type RevenueQueryResult = {\n developerOrgRevenueSummary: DeveloperPortalRevenueSummary | null;\n developerOrgSales: { edges: Array<{ node: DeveloperPortalRevenueSale }> };\n developerOrgPayouts: { edges: Array<{ node: DeveloperPortalRevenuePayout }> };\n };\n\n const data = await gatewayGraphqlRequest<RevenueQueryResult, { organizationId: string }>({\n ...context,\n query: BillingDeveloperPortalRevenueDocument,\n variables: { organizationId },\n });\n\n return {\n summary: data.developerOrgRevenueSummary,\n sales: data.developerOrgSales.edges.map((edge) => edge.node),\n payouts: data.developerOrgPayouts.edges.map((edge) => edge.node),\n };\n}\n\nexport async function fetchEarningsSummary(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myEarningsSummary: EarningsSummary;\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyEarningsSummaryDocument,\n variables: { billingAccountId },\n });\n\n return data.myEarningsSummary;\n}\n\nexport async function fetchEarningsEntries(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myEarningsEntries: { items: EarningsEntry[] };\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyEarningsEntriesDocument,\n variables: { billingAccountId },\n });\n\n return data.myEarningsEntries.items;\n}\n\nexport async function fetchPayoutAccounts(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myPayoutAccounts: PayoutAccount[];\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyPayoutAccountsDocument,\n variables: { billingAccountId },\n });\n\n return data.myPayoutAccounts;\n}\n\nexport async function fetchPayoutRequests(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myPayoutRequests: { items: PayoutRequest[] };\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyPayoutRequestsDocument,\n variables: { billingAccountId },\n });\n\n return data.myPayoutRequests.items;\n}\n\nexport async function addPayoutAccount(input: Record<string, unknown>, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n addPayoutAccount: { id: string };\n },\n { input: Record<string, unknown> }\n >({\n ...context,\n query: AddPayoutAccountDocument,\n variables: { input },\n });\n}\n\nexport async function updatePayoutAccount(\n id: string,\n input: Record<string, unknown>,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n { updatePayoutAccount: { id: string } },\n { id: string; input: Record<string, unknown> }\n >({\n ...context,\n query: UpdatePayoutAccountDocument,\n variables: { id, input },\n });\n}\n\nexport async function setDefaultPayoutAccount(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<{ setDefaultPayoutAccount: { id: string } }, { id: string }>({\n ...context,\n query: SetDefaultPayoutAccountDocument,\n variables: { id },\n });\n}\n\nexport async function archivePayoutAccount(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<{ archivePayoutAccount: boolean }, { id: string }>({\n ...context,\n query: ArchivePayoutAccountDocument,\n variables: { id },\n });\n}\n\nexport async function requestPayout(_input: Record<string, unknown>, _context: GatewayContext) {\n throw new Error('Payout request not yet implemented');\n}\n\nexport async function fetchAdminPayoutSummary(context: GatewayContext) {\n const data = await directBillingGraphqlRequest<{\n adminPayoutSummary: PayoutAdminSummary;\n }>({\n ...context,\n query: AdminPayoutSummaryDocument,\n });\n\n return data.adminPayoutSummary;\n}\n\nexport async function fetchAdminPayoutRequests(context: GatewayContext) {\n const data = await directBillingGraphqlRequest<{\n adminPayoutRequests: { items: PayoutRequest[] };\n }>({\n ...context,\n query: AdminPayoutRequestsDocument,\n });\n\n return data.adminPayoutRequests.items;\n}\n\nexport async function approvePayoutRequest(\n id: string,\n notes: string | null,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n {\n approvePayoutRequest: { id: string };\n },\n { id: string; notes: string | null }\n >({\n ...context,\n query: ApprovePayoutRequestDocument,\n variables: { id, notes },\n });\n}\n\nexport async function rejectPayoutRequest(id: string, reason: string, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n rejectPayoutRequest: { id: string };\n },\n { id: string; reason: string }\n >({\n ...context,\n query: RejectPayoutRequestDocument,\n variables: { id, reason },\n });\n}\n\nexport async function processPayoutRequest(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n processPayoutRequest: { id: string };\n },\n { id: string }\n >({\n ...context,\n query: ProcessPayoutRequestDocument,\n variables: { id },\n });\n}\n"],"m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AAO;EACP,WAAW,EAAE,OAAI;EAClB,CAAC;;AAGJ,eAAsB,EAAc,GAAiC,GAA0B;AAC7F,OAAU,MAAM,qCAAqC;;AAGvD,eAAsB,EAAwB,GAAyB;AAQrE,SAPa,MAAM,EAEhB;EACD,GAAG;EACH,OAAO;EACR,CAAC,EAEU;;AAGd,eAAsB,EAAyB,GAAyB;AAQtE,SAPa,MAAM,EAEhB;EACD,GAAG;EACH,OAAO;EACR,CAAC,EAEU,oBAAoB;;AAGlC,eAAsB,EACpB,GACA,GACA,GACA;AACA,OAAM,EAKJ;EACA,GAAG;EACH,OAAO;EACP,WAAW;GAAE;GAAI;GAAO;EACzB,CAAC;;AAGJ,eAAsB,EAAoB,GAAY,GAAgB,GAAyB;AAC7F,OAAM,EAKJ;EACA,GAAG;EACH,OAAO;EACP,WAAW;GAAE;GAAI;GAAQ;EAC1B,CAAC;;AAGJ,eAAsB,EAAqB,GAAY,GAAyB;AAC9E,OAAM,EAKJ;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,OAAI;EAClB,CAAC"}
1
+ {"version":3,"file":"api.js","names":[],"sources":["../../../../src/billing/modules/earnings/api.ts"],"sourcesContent":["import { directBillingGraphqlRequest } from '../../shared/utils';\nimport { gatewayGraphqlRequest } from '../../shared/utils/gatewayGraphql';\nimport {\n AddPayoutAccountDocument,\n AdminPayoutRequestsDocument,\n AdminPayoutSummaryDocument,\n ApprovePayoutRequestDocument,\n ArchivePayoutAccountDocument,\n BillingDeveloperPortalRevenueDocument,\n MarkPayoutPaidDocument,\n MyEarningsEntriesDocument,\n MyEarningsSummaryDocument,\n MyPayoutAccountsDocument,\n MyPayoutRequestsDocument,\n ProcessPayoutRequestDocument,\n RejectPayoutRequestDocument,\n SetDefaultPayoutAccountDocument,\n UpdatePayoutAccountDocument,\n} from '../../../generated/global-operations';\n\nexport interface EarningsSummary {\n totalLifetimeAmount: number;\n availableAmount: number;\n reservedAmount: number;\n paidAmount: number;\n pendingAmount: number;\n moneyAmount: number;\n creditsAmount: number;\n categoryBreakdown?: Array<{\n category: 'AFFILIATE' | 'STORE' | 'OTHER';\n amount: number;\n count: number;\n }>;\n}\n\nexport interface EarningsEntry {\n id: string;\n sourceCategory: 'AFFILIATE' | 'STORE' | 'OTHER';\n sourceSubcategory?: string | null;\n description?: string | null;\n unitType: 'MONEY' | 'CREDITS';\n amount: number;\n currency: string;\n status: 'AVAILABLE' | 'RESERVED' | 'PAID' | 'REVERSED';\n createdAt: string;\n}\n\nexport interface PayoutAccount {\n id: string;\n label: string;\n type: 'BANK_ACCOUNT' | 'UPI' | 'WALLET';\n providerPreference: 'AUTO' | 'STRIPE' | 'RAZORPAY' | 'MANUAL';\n status: 'PENDING_VERIFICATION' | 'ACTIVE' | 'FAILED_VERIFICATION' | 'ARCHIVED';\n displayName?: string | null;\n accountLast4?: string | null;\n country?: string | null;\n currency: string;\n isDefault: boolean;\n accountDetails?: Record<string, unknown> | null;\n}\n\nexport interface PayoutRequest {\n id: string;\n billingAccountId?: string | null;\n requesterUserId?: string | null;\n requestedAmount: number;\n approvedAmount?: number | null;\n currency: string;\n provider: 'AUTO' | 'STRIPE' | 'RAZORPAY' | 'MANUAL';\n status: 'REQUESTED' | 'APPROVED' | 'REJECTED' | 'PROCESSING' | 'PAID' | 'FAILED' | 'CANCELED';\n externalReference?: string | null;\n failureReason?: string | null;\n internalNotes?: string | null;\n userNotes?: string | null;\n createdAt: string;\n processedAt?: string | null;\n paidAt?: string | null;\n payoutAccount?: PayoutAccount | null;\n}\n\nexport interface PayoutAdminSummary {\n totalRequestedAmount: number;\n totalProcessingAmount: number;\n totalPaidAmount: number;\n pendingCount: number;\n failedCount: number;\n statusBreakdown?: Array<{ status: string; count: number; totalAmount: number }>;\n providerBreakdown?: Array<{ provider: string; count: number; totalAmount: number }>;\n}\n\nexport interface DeveloperPortalRevenueSummary {\n totalGrossRevenue: number;\n totalNetRevenue: number;\n totalPlatformFees: number;\n totalRefunds: number;\n totalRefundsCount: number;\n totalSales: number;\n pendingBalance: number;\n nextPayoutDate?: string | null;\n nextPayoutAmount?: number | null;\n}\n\nexport interface DeveloperPortalRevenueSale {\n id: string;\n grossAmount: number;\n netAmount: number;\n currency: string;\n pricingModel: string;\n status: string;\n purchasedAt: string;\n application?: {\n id: string;\n name: string;\n slug: string;\n } | null;\n}\n\nexport interface DeveloperPortalRevenuePayout {\n id: string;\n periodLabel?: string | null;\n netAmount: number;\n currency: string;\n status: string;\n scheduledAt?: string | null;\n completedAt?: string | null;\n}\n\nexport interface DeveloperPortalRevenueDashboard {\n summary: DeveloperPortalRevenueSummary | null;\n sales: DeveloperPortalRevenueSale[];\n payouts: DeveloperPortalRevenuePayout[];\n}\n\ninterface GatewayContext {\n apiGatewayUrl?: string;\n authToken?: string;\n orgId?: string;\n}\n\nexport async function fetchDeveloperPortalRevenueDashboard(\n organizationId: string,\n context: GatewayContext\n): Promise<DeveloperPortalRevenueDashboard> {\n type RevenueQueryResult = {\n developerOrgRevenueSummary: DeveloperPortalRevenueSummary | null;\n developerOrgSales: { edges: Array<{ node: DeveloperPortalRevenueSale }> };\n developerOrgPayouts: { edges: Array<{ node: DeveloperPortalRevenuePayout }> };\n };\n\n const data = await gatewayGraphqlRequest<RevenueQueryResult, { organizationId: string }>({\n ...context,\n query: BillingDeveloperPortalRevenueDocument,\n variables: { organizationId },\n });\n\n return {\n summary: data.developerOrgRevenueSummary,\n sales: data.developerOrgSales.edges.map((edge) => edge.node),\n payouts: data.developerOrgPayouts.edges.map((edge) => edge.node),\n };\n}\n\nexport async function fetchEarningsSummary(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myEarningsSummary: EarningsSummary;\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyEarningsSummaryDocument,\n variables: { billingAccountId },\n });\n\n return data.myEarningsSummary;\n}\n\nexport async function fetchEarningsEntries(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myEarningsEntries: { items: EarningsEntry[] };\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyEarningsEntriesDocument,\n variables: { billingAccountId },\n });\n\n return data.myEarningsEntries.items;\n}\n\nexport async function fetchPayoutAccounts(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myPayoutAccounts: PayoutAccount[];\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyPayoutAccountsDocument,\n variables: { billingAccountId },\n });\n\n return data.myPayoutAccounts;\n}\n\nexport async function fetchPayoutRequests(billingAccountId: string, context: GatewayContext) {\n const data = await directBillingGraphqlRequest<\n {\n myPayoutRequests: { items: PayoutRequest[] };\n },\n { billingAccountId: string }\n >({\n ...context,\n query: MyPayoutRequestsDocument,\n variables: { billingAccountId },\n });\n\n return data.myPayoutRequests.items;\n}\n\nexport async function addPayoutAccount(input: Record<string, unknown>, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n addPayoutAccount: { id: string };\n },\n { input: Record<string, unknown> }\n >({\n ...context,\n query: AddPayoutAccountDocument,\n variables: { input },\n });\n}\n\nexport async function updatePayoutAccount(\n id: string,\n input: Record<string, unknown>,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n { updatePayoutAccount: { id: string } },\n { id: string; input: Record<string, unknown> }\n >({\n ...context,\n query: UpdatePayoutAccountDocument,\n variables: { id, input },\n });\n}\n\nexport async function setDefaultPayoutAccount(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<{ setDefaultPayoutAccount: { id: string } }, { id: string }>({\n ...context,\n query: SetDefaultPayoutAccountDocument,\n variables: { id },\n });\n}\n\nexport async function archivePayoutAccount(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<{ archivePayoutAccount: boolean }, { id: string }>({\n ...context,\n query: ArchivePayoutAccountDocument,\n variables: { id },\n });\n}\n\nexport async function requestPayout(_input: Record<string, unknown>, _context: GatewayContext) {\n throw new Error('Payout request not yet implemented');\n}\n\nexport async function fetchAdminPayoutSummary(context: GatewayContext) {\n const data = await directBillingGraphqlRequest<{\n adminPayoutSummary: PayoutAdminSummary;\n }>({\n ...context,\n query: AdminPayoutSummaryDocument,\n });\n\n return data.adminPayoutSummary;\n}\n\nexport async function fetchAdminPayoutRequests(context: GatewayContext) {\n const data = await directBillingGraphqlRequest<{\n adminPayoutRequests: { items: PayoutRequest[] };\n }>({\n ...context,\n query: AdminPayoutRequestsDocument,\n });\n\n return data.adminPayoutRequests.items;\n}\n\nexport async function approvePayoutRequest(\n id: string,\n notes: string | null,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n {\n approvePayoutRequest: { id: string };\n },\n { id: string; notes: string | null }\n >({\n ...context,\n query: ApprovePayoutRequestDocument,\n variables: { id, notes },\n });\n}\n\nexport async function rejectPayoutRequest(id: string, reason: string, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n rejectPayoutRequest: { id: string };\n },\n { id: string; reason: string }\n >({\n ...context,\n query: RejectPayoutRequestDocument,\n variables: { id, reason },\n });\n}\n\nexport async function processPayoutRequest(id: string, context: GatewayContext) {\n await directBillingGraphqlRequest<\n {\n processPayoutRequest: { id: string };\n },\n { id: string }\n >({\n ...context,\n query: ProcessPayoutRequestDocument,\n variables: { id },\n });\n}\n\nexport async function markPayoutPaid(\n id: string,\n externalReference: string | null,\n notes: string | null,\n context: GatewayContext\n) {\n await directBillingGraphqlRequest<\n { markPayoutPaid: { id: string } },\n { id: string; externalReference: string | null; notes: string | null }\n >({\n ...context,\n query: MarkPayoutPaidDocument,\n variables: { id, externalReference, notes },\n });\n}\n"],"mappings":";;;;;AA2IA,eAAsB,EACpB,GACA,GAC0C;CAO1C,IAAM,IAAO,MAAM,EAAsE;EACvF,GAAG;EACH,OAAO;EACP,WAAW,EAAE,mBAAgB;EAC9B,CAAC;AAEF,QAAO;EACL,SAAS,EAAK;EACd,OAAO,EAAK,kBAAkB,MAAM,KAAK,MAAS,EAAK,KAAK;EAC5D,SAAS,EAAK,oBAAoB,MAAM,KAAK,MAAS,EAAK,KAAK;EACjE;;A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EAEU,oBAAoB;;AAGlC,eAAsB,EACpB,GACA,GACA,GACA;AACA,OAAM,EAKJ;EACA,GAAG;EACH,OAAO;EACP,WAAW;GAAE;GAAI;GAAO;EACzB,CAAC;;AAGJ,eAAsB,EAAoB,GAAY,GAAgB,GAAyB;AAC7F,OAAM,EAKJ;EACA,GAAG;EACH,OAAO;EACP,WAAW;GAAE;GAAI;GAAQ;EAC1B,CAAC;;AAgBJ,eAAsB,EACpB,GACA,GACA,GACA,GACA;AACA,OAAM,EAGJ;EACA,GAAG;EACH,OAAO;EACP,WAAW;GAAE;GAAI;GAAmB;GAAO;EAC5C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"PayoutAdminPage.d.ts","sourceRoot":"","sources":["../../../../../src/billing/modules/earnings/pages/PayoutAdminPage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAwB9D,eAAO,MAAM,eAAe,EAAE,EA2P7B,CAAC"}
1
+ {"version":3,"file":"PayoutAdminPage.d.ts","sourceRoot":"","sources":["../../../../../src/billing/modules/earnings/pages/PayoutAdminPage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AA6b9D,eAAO,MAAM,eAAe,EAAE,EA+O7B,CAAC"}