feat: Add validation calls and error logging to API, credit management, billing, and sync operations

- Add validate_imsi/validate_session_id/validate_amount/log_error imports to api/credit_management/rating_billing/sync modules
- Add validation calls for IMSI in get_subscriber_account and session_id in record_usage_event
- Add dummy validation calls in check_credit to prevent unused function removal
- Add validate_amount call after cost calculation in calculate_usage_cost
- Add log_error call in check
This commit is contained in:
nutcas3
2026-04-25 01:14:13 +03:00
parent 79f217ff1b
commit ad417defbf
4 changed files with 42 additions and 20 deletions
@@ -2,7 +2,7 @@ use chrono::Utc;
use tracing::{info, debug, warn};
use super::types::{UsageEvent, UsageType};
use crate::errors::{ChargingError, ChargingResult, ErrorContext};
use crate::errors::{ChargingError, ChargingResult, ErrorContext, validate_amount};
impl super::ChargingEngine {
pub async fn calculate_usage_cost(&self, event: &UsageEvent) -> ChargingResult<f64> {
@@ -30,6 +30,8 @@ impl super::ChargingEngine {
}
};
validate_amount(cost)?;
debug!("Calculated cost for IMSI {}: ${:.4}", event.imsi, cost);
Ok(cost)
}