151 lines
3.1 KiB
Rust
151 lines
3.1 KiB
Rust
use std::{any::TypeId, ops::Deref};
|
|
|
|
use egui::TextBuffer;
|
|
use sqlx::types::{BigDecimal, chrono::DateTime};
|
|
|
|
#[derive(Clone, Hash, sqlx::FromRow, PartialEq)]
|
|
pub struct Position {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub wage: BigDecimal,
|
|
}
|
|
impl Default for Position {
|
|
fn default() -> Self {
|
|
Self {
|
|
id: 1,
|
|
name: "".into(),
|
|
wage: 0.into(),
|
|
}
|
|
}
|
|
}
|
|
#[derive(Default, Clone, Hash)]
|
|
pub struct Worker {
|
|
pub id: i32,
|
|
pub full_name: String,
|
|
pub hire_date: DateTime<chrono::Local>,
|
|
pub position: Position,
|
|
pub is_fired: bool,
|
|
}
|
|
#[derive(sqlx::FromRow, sqlx::Decode)]
|
|
pub struct WorkerRow {
|
|
pub id: i32,
|
|
pub full_name: String,
|
|
pub hire_date: DateTime<chrono::Local>,
|
|
pub position_id: i32,
|
|
pub is_fired: bool,
|
|
}
|
|
pub struct Salary {
|
|
id: i32,
|
|
worker: Worker,
|
|
salary_size: rust_decimal::Decimal,
|
|
salary_date: chrono::DateTime<chrono::Local>,
|
|
}
|
|
|
|
#[derive(Default, Clone, Hash)]
|
|
pub struct Equipment {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub inv_number: String,
|
|
pub maintenance_date: chrono::DateTime<chrono::Local>,
|
|
pub worker: Worker,
|
|
}
|
|
#[derive(sqlx::FromRow)]
|
|
pub struct EquipmentRow {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub inv_number: String,
|
|
pub maintenance_date: chrono::DateTime<chrono::Local>,
|
|
pub worker_id: i32,
|
|
}
|
|
#[derive(Clone)]
|
|
pub struct Material {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub quantity: i32,
|
|
pub category: MaterialCategory,
|
|
}
|
|
#[derive(sqlx::FromRow)]
|
|
pub struct MaterialRow {
|
|
pub id: i32,
|
|
pub name: String,
|
|
pub quantity: i32,
|
|
pub category_id: i32,
|
|
}
|
|
#[derive(sqlx::FromRow, Default, Clone, PartialEq)]
|
|
pub struct MaterialCategory {
|
|
pub id: i32,
|
|
pub name: String,
|
|
}
|
|
pub struct RecipeElement {
|
|
id: i32,
|
|
material: Material,
|
|
equipment: Equipment,
|
|
quantity: i32,
|
|
}
|
|
pub struct Recipe {
|
|
id: i32,
|
|
name: String,
|
|
elements: std::vec::Vec<RecipeElement>,
|
|
}
|
|
pub struct Client {
|
|
id: i32,
|
|
name: String,
|
|
address: String,
|
|
}
|
|
pub struct Order<'a> {
|
|
id: i32,
|
|
client: Client,
|
|
order_date: chrono::DateTime<chrono::Local>,
|
|
total_amount: rust_decimal::Decimal,
|
|
elements: std::vec::Vec<OrderElement<'a>>,
|
|
}
|
|
pub struct OrderElement<'a> {
|
|
id: i32,
|
|
product: Product<'a>,
|
|
quantity: i32,
|
|
total_amount: rust_decimal::Decimal,
|
|
}
|
|
pub struct Product<'a> {
|
|
id: i32,
|
|
recipe: &'a Recipe,
|
|
volume: f64,
|
|
price_per_unit: rust_decimal::Decimal,
|
|
}
|
|
#[derive(Default)]
|
|
pub struct User {
|
|
login: String,
|
|
is_admin: bool,
|
|
worker: Worker,
|
|
}
|
|
#[derive(Default)]
|
|
pub struct ModalWinState {
|
|
pub is_open: bool,
|
|
pub can_finish: bool,
|
|
pub data: std::collections::HashMap<String, String>,
|
|
pub status: ModalStatus,
|
|
}
|
|
|
|
#[derive(Default, PartialEq)]
|
|
pub enum ModalStatus {
|
|
#[default]
|
|
Add,
|
|
Edit,
|
|
Remove,
|
|
}
|
|
|
|
#[derive(Default)]
|
|
pub struct LoginModalState<'a> {
|
|
pub is_open: bool,
|
|
pub data: std::collections::HashMap<&'a str, String>,
|
|
pub status: LoginStatus,
|
|
pub fail: bool,
|
|
pub fail_message: String,
|
|
}
|
|
|
|
#[derive(Default, PartialEq)]
|
|
pub enum LoginStatus {
|
|
#[default]
|
|
Login,
|
|
Finished,
|
|
}
|