use crate::{DateTimeUtc, Decimal, UserId, WorkspaceId};
use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "workspace_billing_history")]
pub struct Model {
    #[sea_orm(primary_key, column_name = "uid")]
    pub uid: Uuid,
    #[sea_orm(column_name = "workspace_id")]
    pub workspace_id: WorkspaceId,
    #[sea_orm(column_name = "user_id")]
    pub user_id: Option<UserId>,
    #[sea_orm(column_type = "Decimal(Some((20, 4)))")]
    pub amount: Decimal,
    #[sea_orm(column_type = "Text")]
    pub currency: String,
    #[sea_orm(column_type = "Text")]
    pub reason: String,
    pub extra: Option<serde_json::Value>,
    pub created_at: DateTimeUtc,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

impl ActiveModelBehavior for ActiveModel {}
