Predictive Billing AI in Telecom/Energy Running on Oracle Solaris
In the Distributed Generation and recurring billing sector, customer default (both corporate and residential) is one of the main factors affecting operational cash flow. Identifying which customers are most likely to delay their invoice payments even before the due date allows for the automation of friendly reminders and preemptive renegotiations.
In this article, I detail the implementation of a predictive model based on the RandomForestClassifier algorithm, integrated directly with tables from the SAP Business One ERP on the SAP Hana database, executed on a schedule within a robust Oracle Solaris UNIX environment.
Choice of Environment
Oracle Solaris is renowned for its unmatched stability and advanced virtualization features (like Solaris Zones). We kept the Python script running natively in an isolated zone directly connected to the SAP Hana data subnet to ensure security and sub-millisecond network latency.
The Predictive Pipeline
The Python script performs the following key operations:
- Extraction of Open Invoices: Queries in the SAP Hana database looking for customer payment history (table
OINV). - Feature Engineering: Grouping by variables of historical days late, current invoice value, and past punctuality.
- Classification via Machine Learning:
-
from sklearn.ensemble import RandomForestClassifier - # Periodically trained model
- clf = RandomForestClassifier(n_estimators=100, random_state=42)
- clf.fit(X_train, y_train)
- ``
- Probability Calculator (Risk Score): For each open invoice, the probability of default (predict_proba
) is generated.
Extract on HANA, schedule in the zone
The classifier does not see OINV directly. A read-only user returns the open invoices, and the Solaris zone cron runs the score before business hours.
sql
SELECT "CardCode", "DocEntry", "DocTotal",
DAYS_BETWEEN("DocDueDate", CURRENT_DATE) AS "DelayDays"
FROM "OINV"
WHERE "DocStatus" = 'O';
bash
Solaris zone crontab, 06:15
15 6 * /opt/billing/venv/bin/python /opt/billing/score_invoices.py `
score_invoices.py writes only CardCode and a Risk_Score` above 0.85. The ERP sends the notice. The model does not need a route to the internet.
Business Integration
When the risk score exceeds the configured threshold (typically 85%), the system automatically triggers the ERP API to send a preventive notification via email or WhatsApp, optimizing accounts receivable by up to 35%.
Related Articles
UNIX Level 3 Administration: HP-UX, Solaris, and AIX in the Modern Data Center
A retrospective and best practices on administering mission-critical UNIX systems in large corporations, covering LVM, Solaris Zones, and stability.
Optimizing Complex Queries in SAP HANA for Real-Time Analytics
Learn how to analyze and optimize SQL routines in the SAP HANA Database, reducing compilation time and enabling much more performant BI pipelines.