Call Detail Records (CDRs) & Usage Analytics Module Documentation
Module Code:
billing/client/cdrs
Route:/portal/cdrs
Backend Service:clientService.ts(ring2all-billing-api)
Database Table:cdrs_rated
Brand Purity: 100% White-Label Compliant (Ring2All Billing)
Table of Contents
Section titled βTable of Contentsβ- Executive Summary & Commercial Transparency
- Technical Architecture & Rating Pipeline
- π― User Roles & Key Capabilities
- Visual Interface & Screen Breakdown
- Itemized CDR Metrics & Hangup Cause Analytics
- RFC 4180 CSV Data Export Engine
- Database Schema & Data Dictionary
- Diagnostic CLI & Operational Playbooks
- Domain Glossary
1. Executive Summary & Commercial Transparency
Section titled β1. Executive Summary & Commercial TransparencyβThe Call Detail Records (CDRs) module empowers subscribers with complete, itemized visibility into every inbound and outbound telephone session handled across their PBX domains and wholesale SIP trunks.
+-------------------------------------------------------------------------------+| COMMERCIAL & OPERATIONAL IMPACT |+-------------------------------------------------------------------------------+| β’ Dispute Elimination: Complete transparency regarding call timestamps, || destination rate tiers, billed seconds, and precise dollar costs. || β’ Sub-Minute Telecom Billing: Verifies exact initial block and step rounding || rules applied to every completed destination. || β’ Granular Exporting: Instantly downloads raw records to CSV for integration || into enterprise ERPs, spreadsheets, and internal cost centers. || β’ Multi-Tenant Data Isolation: All queries are strictly scoped by || authenticated customer ID at the SQL layer. |+-------------------------------------------------------------------------------+2. Technical Architecture & Rating Pipeline
Section titled β2. Technical Architecture & Rating PipelineβWhen an active call terminates on Telephony Server or Kamailio SBC, the Online Charging System (OCS) calculates destination pricing, applies rate card tiers, and commits the finalized record to cdrs_rated:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Telephony Termination Engine β β Telephony Server 1.11 / Kamailio 6.1 β βββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ β CDR Event Hook βΌ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Ring2All Online Charging System (OCS) Engine β β β’ Resolves Effective Customer Rate Card β β β’ Calculates Initial Block (e.g. 30s) + Step (6s) β β β’ Computes: Cost = (BilledSeconds / 60) * RatePerMin β βββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ β βΌ SQL INSERT ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β PostgreSQL 17 Storage (public.cdrs_rated) β β WHERE customer_id = $authCustomerId β βββββββββββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββ β GET /api/client/cdrs βΌ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Client Self-Care Portal UI (CdrsPage.tsx) β β Real-Time Live Search, Dispositions & CSV Exporter β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ3. π― User Roles & Key Capabilities
Section titled β3. π― User Roles & Key CapabilitiesβAccess to CDR data is restricted strictly to authorized customer representatives:
| User Role | Access Level | Primary Operational Capabilities |
|---|---|---|
| Enterprise Telecom Administrator | Full Audit | Searches all extension calls, verifies call completion rates, identifies anomalous calling spikes. |
| Corporate Controller / CFO | Financial Reconciliation | Audits itemized usage against monthly invoices and prepaid wallet debits; verifies rate card accuracy. |
| Call Center Operations Lead | Operational Analytics | Evaluates call durations, identifies failed or busy destinations, analyzes talk-time efficiency. |
| Compliance Officer | Audit & Legal | Exports unalterable call history logs with standardized UTC timestamps and international prefixes. |
4. Visual Interface & Screen Breakdown
Section titled β4. Visual Interface & Screen Breakdownβ4.1 Real-Time CDR Data Grid Overview
Section titled β4.1 Real-Time CDR Data Grid OverviewβThe CDRs interface provides a clean, responsive layout optimized for high-volume record analysis:

- Toolbar Controls: Dynamic destination/source search bar, instant refresh button, and one-click CSV export action.
- Timestamp & Extension: Accurate local date/time display alongside the calling SIP extension or source CLI.
- Destination Details: Destination number, resolved carrier country/region name, and dialed prefix.
- Duration Metrics: Breakdown of physical connection duration (seconds) versus billable time (minutes).
- Cost & Status: Calculated charge in USD with visual badges for
Billed,Completed, orFailed.
5. Itemized CDR Metrics & Hangup Cause Analytics
Section titled β5. Itemized CDR Metrics & Hangup Cause AnalyticsβThe portal parses standard Q.850 / SIP termination codes into human-readable dispositions:
| Hangup Cause Code | SIP Response Code | Portal Status Badge | Operational Meaning |
|---|---|---|---|
NORMAL_CLEARING |
200 OK (BYE) |
Completed (Green) |
Call ended cleanly by either calling or called party. |
USER_BUSY |
486 Busy Here |
Busy (Amber) |
Remote terminal was engaged in another call. |
NO_ANSWER |
408 Request Timeout |
No Answer (Amber) |
Remote endpoint rang until timeout without answering. |
ORIGINATOR_CANCEL |
487 Request Terminated |
Cancelled (Gray) |
Calling party hung up prior to call answer. |
CALL_REJECTED |
603 Decline |
Rejected (Red) |
Destination terminal explicitly declined incoming INVITE. |
6. RFC 4180 CSV Data Export Engine
Section titled β6. RFC 4180 CSV Data Export EngineβThe client-side export generator compiles filtered records into standardized CSV format:
- MIME Type:
data:text/csv;charset=utf-8 - Column Headers:
Call Date, Source, Destination, Duration (sec), Billed (min), Cost ($), Status, Hangup Cause - Automatic Naming:
cdrs_YYYY-MM-DD.csvfor clean archiving.
7. Database Schema & Data Dictionary
Section titled β7. Database Schema & Data DictionaryβTable: public.cdrs_rated
Section titled βTable: public.cdrs_ratedβCREATE TABLE public.cdrs_rated ( id BIGSERIAL PRIMARY KEY, uuid UUID NOT NULL DEFAULT gen_random_uuid(), call_uuid VARCHAR(64) NOT NULL UNIQUE, customer_id BIGINT REFERENCES customers(id) ON DELETE SET NULL, sip_account_id VARCHAR(100), source_number VARCHAR(50) NOT NULL, destination_number VARCHAR(50) NOT NULL, prefix VARCHAR(32), destination_name VARCHAR(255), duration_seconds INTEGER NOT NULL, billed_seconds INTEGER NOT NULL, rate_per_minute NUMERIC(10,6) NOT NULL, connection_fee NUMERIC(10,6) NOT NULL DEFAULT 0.000000, cost NUMERIC(10,4) NOT NULL, call_start TIMESTAMPTZ NOT NULL, call_end TIMESTAMPTZ NOT NULL, hangup_cause VARCHAR(50), status VARCHAR(20) NOT NULL DEFAULT 'billed', carrier_name VARCHAR(100), created_at TIMESTAMPTZ NOT NULL DEFAULT NOW());
-- High-performance query index for customer portalCREATE INDEX idx_cdrs_customer_time ON cdrs_rated (customer_id, call_start DESC);8. Diagnostic CLI & Operational Playbooks
Section titled β8. Diagnostic CLI & Operational PlaybooksβQuery Customer CDRs via PostgreSQL
Section titled βQuery Customer CDRs via PostgreSQLβ# Execute on Billing DB hostsu - postgres -c "psql -d ss_billing -c \"SELECT call_start, source_number, destination_number, destination_name, duration_seconds, billed_seconds, cost, statusFROM cdrs_ratedWHERE customer_id = 5ORDER BY call_start DESC LIMIT 5;\""9. Domain Glossary
Section titled β9. Domain Glossaryβ- ASR (Answer-Seizure Ratio): Percentage of attempted calls that are successfully answered.
- Billed Seconds: Total duration after applying initial connect blocks and billing increment steps.
- CLI (Calling Line Identification): Originating caller ID transmitted during call setup.
- OCS (Online Charging System): Engine responsible for real-time rating and credit control.

