2026-05-08 18:39:49 +03:00
|
|
|
|
/**
|
|
|
|
|
|
* Mock-данные для BillingView. Заменятся на API-fetch:
|
|
|
|
|
|
* GET /api/billing/wallet — баланс ₽ + леды + tariff.
|
|
|
|
|
|
* GET /api/billing/transactions?type={all|topup|charge|refund} — `balance_transactions`.
|
|
|
|
|
|
* GET /api/billing/invoices — `invoices` table (счета + УПД).
|
|
|
|
|
|
*
|
|
|
|
|
|
* Mock-структуры соответствуют схеме v8.7:
|
|
|
|
|
|
* - balance_transactions (§4.4): type ∈ {topup, lead_charge, refund, tariff_charge, manager_addon}.
|
|
|
|
|
|
* - invoices (§4.5): type ∈ {invoice, upd}, format ∈ {pdf, xml_1c83}.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2026-05-14 08:28:44 +03:00
|
|
|
|
type TxType = 'topup' | 'lead_charge' | 'refund' | 'tariff_charge';
|
2026-05-08 18:39:49 +03:00
|
|
|
|
export type TxStatus = 'pending' | 'completed' | 'rejected';
|
|
|
|
|
|
|
|
|
|
|
|
export interface BillingTransaction {
|
|
|
|
|
|
id: number;
|
|
|
|
|
|
code: string; // 'TX-89421'
|
|
|
|
|
|
when: string; // '07.05 · 14:21'
|
|
|
|
|
|
type: TxType;
|
|
|
|
|
|
description: string;
|
|
|
|
|
|
status: TxStatus;
|
|
|
|
|
|
amount: number; // signed (+ topup/refund, − charge)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const MOCK_TRANSACTIONS: BillingTransaction[] = [
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 89421,
|
|
|
|
|
|
code: 'TX-89421',
|
|
|
|
|
|
when: '07.05 · 14:21',
|
|
|
|
|
|
type: 'topup',
|
|
|
|
|
|
description: 'Пополнение через ЮKassa',
|
|
|
|
|
|
status: 'pending',
|
|
|
|
|
|
amount: 5000,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 89384,
|
|
|
|
|
|
code: 'TX-89384',
|
|
|
|
|
|
when: '07.05 · 11:14',
|
|
|
|
|
|
type: 'lead_charge',
|
|
|
|
|
|
description: 'Списание · 3 лида проект «Окна Москва»',
|
|
|
|
|
|
status: 'completed',
|
|
|
|
|
|
amount: -6600,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 89370,
|
|
|
|
|
|
code: 'TX-89370',
|
|
|
|
|
|
when: '07.05 · 09:48',
|
|
|
|
|
|
type: 'refund',
|
|
|
|
|
|
description: 'Возврат лида #1018 · дубликат',
|
|
|
|
|
|
status: 'completed',
|
|
|
|
|
|
amount: 2200,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 89312,
|
|
|
|
|
|
code: 'TX-89312',
|
|
|
|
|
|
when: '06.05 · 22:06',
|
|
|
|
|
|
type: 'topup',
|
|
|
|
|
|
description: 'Пополнение через ЮKassa',
|
|
|
|
|
|
status: 'completed',
|
|
|
|
|
|
amount: 10000,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 89286,
|
|
|
|
|
|
code: 'TX-89286',
|
|
|
|
|
|
when: '06.05 · 18:32',
|
|
|
|
|
|
type: 'lead_charge',
|
|
|
|
|
|
description: 'Списание · 5 лидов проект «Натяжные потолки»',
|
|
|
|
|
|
status: 'completed',
|
|
|
|
|
|
amount: -9250,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 89108,
|
|
|
|
|
|
code: 'TX-89108',
|
|
|
|
|
|
when: '05.05 · 12:00',
|
|
|
|
|
|
type: 'tariff_charge',
|
|
|
|
|
|
description: 'Списание абонентской платы тарифа «Команда»',
|
|
|
|
|
|
status: 'completed',
|
|
|
|
|
|
amount: -990,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 88937,
|
|
|
|
|
|
code: 'TX-88937',
|
|
|
|
|
|
when: '04.05 · 16:42',
|
|
|
|
|
|
type: 'topup',
|
|
|
|
|
|
description: 'Попытка пополнения через банковский перевод',
|
|
|
|
|
|
status: 'rejected',
|
|
|
|
|
|
amount: 0,
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 88714,
|
|
|
|
|
|
code: 'TX-88714',
|
|
|
|
|
|
when: '03.05 · 09:18',
|
|
|
|
|
|
type: 'refund',
|
|
|
|
|
|
description: 'Возврат лида #998 · спам',
|
|
|
|
|
|
status: 'completed',
|
|
|
|
|
|
amount: 1850,
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
export interface BillingTab {
|
|
|
|
|
|
id: 'all' | 'topup' | 'lead_charge' | 'refund';
|
|
|
|
|
|
label: string;
|
|
|
|
|
|
types: TxType[] | null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const BILLING_TABS: BillingTab[] = [
|
|
|
|
|
|
{ id: 'all', label: 'Все', types: null },
|
|
|
|
|
|
{ id: 'topup', label: 'Пополнения', types: ['topup'] },
|
|
|
|
|
|
{ id: 'lead_charge', label: 'Списания', types: ['lead_charge', 'tariff_charge'] },
|
|
|
|
|
|
{ id: 'refund', label: 'Возвраты', types: ['refund'] },
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
export type InvoiceFormat = 'pdf' | 'xml_1c83';
|
|
|
|
|
|
|
|
|
|
|
|
export interface Invoice {
|
|
|
|
|
|
id: number;
|
|
|
|
|
|
when: string; // '07.05.2026'
|
|
|
|
|
|
title: string; // 'Счёт № 2026-0512'
|
|
|
|
|
|
sub: string; // 'Тариф «Команда» · май 2026'
|
|
|
|
|
|
amountRub: number;
|
|
|
|
|
|
format: InvoiceFormat;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const MOCK_INVOICES: Invoice[] = [
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 1,
|
|
|
|
|
|
when: '07.05.2026',
|
|
|
|
|
|
title: 'Счёт № 2026-0512',
|
|
|
|
|
|
sub: 'Тариф «Команда» · май 2026',
|
|
|
|
|
|
amountRub: 990,
|
|
|
|
|
|
format: 'pdf',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 2,
|
|
|
|
|
|
when: '06.05.2026',
|
|
|
|
|
|
title: 'УПД № УПД-2026-0492',
|
|
|
|
|
|
sub: 'Списания за апрель · 18 лидов',
|
|
|
|
|
|
amountRub: 29850,
|
|
|
|
|
|
format: 'xml_1c83',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 3,
|
|
|
|
|
|
when: '05.05.2026',
|
|
|
|
|
|
title: 'УПД № УПД-2026-0488',
|
|
|
|
|
|
sub: 'Списания за март · 24 лида',
|
|
|
|
|
|
amountRub: 38100,
|
|
|
|
|
|
format: 'xml_1c83',
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
id: 4,
|
|
|
|
|
|
when: '01.04.2026',
|
|
|
|
|
|
title: 'Счёт № 2026-0498',
|
|
|
|
|
|
sub: 'Тариф «Команда» · апрель 2026',
|
|
|
|
|
|
amountRub: 990,
|
|
|
|
|
|
format: 'pdf',
|
|
|
|
|
|
},
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
export interface PendingPayment {
|
|
|
|
|
|
code: string;
|
|
|
|
|
|
amount: number;
|
|
|
|
|
|
method: string; // 'ЮKassa'
|
|
|
|
|
|
startedAt: string; // '14:21'
|
|
|
|
|
|
autoCancelAt: string; // '14:51'
|
|
|
|
|
|
timeoutMinutes: number;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const MOCK_PENDING: PendingPayment | null = {
|
|
|
|
|
|
code: 'TX-89421',
|
|
|
|
|
|
amount: 5000,
|
|
|
|
|
|
method: 'ЮKassa',
|
|
|
|
|
|
startedAt: '14:21',
|
|
|
|
|
|
autoCancelAt: '14:51',
|
|
|
|
|
|
timeoutMinutes: 30,
|
|
|
|
|
|
};
|