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

/// Per-project billing account holding the current balance.
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "project_billing")]
pub struct Model {
    #[sea_orm(primary_key)]
    #[sea_orm(column_name = "project_uuid")]
    pub project: ProjectId,
    #[sea_orm(column_type = "Decimal(Some((20, 4)))")]
    pub balance: Decimal,
    #[sea_orm(column_type = "Text")]
    pub currency: String,
    #[sea_orm(column_name = "user_uuid")]
    pub user: Option<UserId>,
    pub updated_at: DateTimeUtc,
    pub created_at: DateTimeUtc,
}

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

impl ActiveModelBehavior for ActiveModel {}
