use crate::DateTimeUtc; use sea_orm::entity::prelude::*; use serde::{Deserialize, Serialize}; use uuid::Uuid; /// Persisted billing error that requires user attention. /// Created when an AI request fails due to insufficient balance or quota. /// Front-end reads unresolved errors to show warning banners. #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)] #[sea_orm(table_name = "billing_error")] pub struct Model { #[sea_orm(primary_key, auto_increment = false)] pub id: Uuid, /// "user" or "project" #[sea_orm(column_type = "Text")] pub scope: String, /// user_uuid or project_uuid pub scope_id: Uuid, /// "insufficient_balance" or "over_quota" #[sea_orm(column_type = "Text")] pub error_type: String, #[sea_orm(column_type = "Text")] pub message: String, pub details: Option, #[sea_orm(default_value = false)] pub resolved: bool, pub created_at: DateTimeUtc, } #[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] pub enum Relation {} impl ActiveModelBehavior for ActiveModel {}