//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.19

use sea_orm::entity::prelude::*;
use serde::{Deserialize, Serialize};

#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
#[sea_orm(table_name = "orders")]
pub struct Model {
    pub created_at: DateTimeWithTimeZone,
    pub updated_at: DateTimeWithTimeZone,
    #[sea_orm(primary_key)]
    pub id: i32,
    #[sea_orm(unique)]
    pub order_number: String,
    pub email: String,
    pub customer_name: Option<String>,
    pub status: String,
    pub total_cents: i64,
    pub address: Option<String>,
    pub city: Option<String>,
    pub zip: Option<String>,
    pub country: Option<String>,
    #[sea_orm(column_type = "Text", nullable)]
    pub note: Option<String>,
    pub payment_method: Option<String>,
    pub carrier_code: Option<String>,
    pub carrier_name: Option<String>,
    pub shipping_cents: i64,
    pub pickup_point_id: Option<String>,
    pub pickup_point_name: Option<String>,
    pub tracking_number: Option<String>,
    pub shipment_id: Option<String>,
    pub label_url: Option<String>,
    pub phone: Option<String>,
    pub account_type: String,
    pub company_name: Option<String>,
    pub company_id: Option<String>,
    pub tax_id: Option<String>,
    pub vat_id: Option<String>,
    pub user_id: Option<i32>,
    pub residence_address: Option<String>,
    pub residence_city: Option<String>,
    pub residence_zip: Option<String>,
    pub residence_country: Option<String>,
}

#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
    #[sea_orm(has_many = "super::order_items::Entity")]
    OrderItems,
}

impl Related<super::order_items::Entity> for Entity {
    fn to() -> RelationDef {
        Relation::OrderItems.def()
    }
}
