39 lines
1.4 KiB
Rust
39 lines
1.4 KiB
Rust
use crate::{DateTimeUtc, ProjectId, UserId};
|
|
use sea_orm::entity::prelude::*;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
/// Per-project billing account holding the current balance.
|
|
/// First project per user gets $20; subsequent projects get $0.
|
|
#[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>,
|
|
/// Whether the initial credit (first project $20 bonus) was granted.
|
|
#[sea_orm(default_value = false)]
|
|
pub initial_credit_granted: bool,
|
|
/// Whether this project belongs to a pro user (monthly quota applies).
|
|
#[sea_orm(default_value = false)]
|
|
pub is_pro: bool,
|
|
#[sea_orm(column_type = "Decimal(Some((20, 4)))", default_value = 0)]
|
|
pub monthly_quota: Decimal,
|
|
#[sea_orm(column_type = "Decimal(Some((20, 4)))", default_value = 0)]
|
|
pub month_used: Decimal,
|
|
pub cycle_start: Option<DateTimeUtc>,
|
|
pub cycle_end: Option<DateTimeUtc>,
|
|
pub updated_at: DateTimeUtc,
|
|
pub created_at: DateTimeUtc,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
|
pub enum Relation {}
|
|
|
|
impl ActiveModelBehavior for ActiveModel {}
|