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

/// Billing transaction history for a project.
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Serialize, Deserialize)]
#[sea_orm(table_name = "project_billing_history")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub uid: Uuid,
    pub project: ProjectId,
    pub user: 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,
    #[sea_orm(column_type = "JsonBinary", nullable)]
    pub extra: Option<Json>,
    pub created_at: DateTimeUtc,
}

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

impl ActiveModelBehavior for ActiveModel {}
