Predictive Billing AI in Telecom/Energy Running on Oracle Solaris

June 25, 20262 min read
Machine LearningSolarisSAP HANAPython

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, fed by a read-only extract 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 stability and advanced virtualization features (like Solaris Zones). We kept the Python script running natively in an isolated zone on the same SAP HANA data subnet, to shorten the network path and limit who can reach the database. Sub-millisecond latency is not a property of the zone: it depends on the distance to the HANA host.

The Predictive Pipeline

The Python script performs the following key operations:

  1. Two extracts: training reads closed invoices (DocStatus = 'C'). Scoring reads only open ones (DocStatus = 'O'). Both come from OINV, through a read-only user. The training label for lateness comes from accounts receivable, not from the invoice header alone.
  2. Feature Engineering: Grouping by variables of historical days late, current invoice value, and past punctuality.
  3. Classification via Machine Learning: A RandomForestClassifier retrained periodically on the payment history.
  4. Probability Calculator (Risk Score): For each open invoice, the probability of default (predict_proba) is generated.
from sklearn.ensemble import RandomForestClassifier

# Model retrained periodically on paid and late invoice history
clf = RandomForestClassifier(n_estimators=100, random_state=42)
clf.fit(X_train, y_train)
risk_score = clf.predict_proba(X_open)[:, 1]

Extract on HANA, schedule in the zone

The classifier does not see OINV directly. A read-only user returns two slices, and the Solaris zone cron runs the score before business hours.

-- Training: invoices already closed. Real delay comes from the receipt, not this date.
SELECT "CardCode", "DocEntry", "DocTotal", "DocDueDate"
FROM "SBO_PROD"."OINV"
WHERE "DocStatus" = 'C';

-- Score: only what is still open.
SELECT "CardCode", "DocEntry", "DocTotal",
       DAYS_BETWEEN("DocDueDate", CURRENT_DATE) AS "DelayDays"
FROM "SBO_PROD"."OINV"
WHERE "DocStatus" = 'O';
# Solaris zone crontab, 06:15
15 6 * * * /opt/billing/venv/bin/python /opt/billing/score_invoices.py

score_invoices.py writes only the CardCode and Risk_Score of invoices scoring 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 threshold configured for this case (85%), the ERP API sends a preventive notice by email or WhatsApp. On the portfolio I measured, accounts receivable improved by about 35%. That figure belongs to that book of invoices, not to the algorithm.

Related Articles