pub mod pos_closing_entry;
pub mod pos_invoice;
pub mod pos_invoice_item;
pub mod pos_payment;
pub mod pos_profile;
pub mod pos_opening_entry;
pub mod pos_cash_movement;
pub mod pos_discount;
pub mod pos_manager_pin;
pub mod pos_floor_plan;
pub mod pos_table;
pub mod pos_closing_status;
pub mod pos_invoice_status;
pub mod pos_payment_method;
pub mod pos_cash_rounding_strategy;
pub mod pos_profile_status;
pub mod pos_session_status;
pub mod pos_cash_movement_type;
pub use pos_closing_entry::PosClosingEntry;
pub use pos_closing_entry::PosClosingEntryBuilder;
pub use pos_closing_entry::PosClosingEntryId;
pub use pos_invoice::PosInvoice;
pub use pos_invoice::PosInvoiceBuilder;
pub use pos_invoice::PosInvoiceId;
pub use pos_invoice_item::PosInvoiceItem;
pub use pos_invoice_item::PosInvoiceItemBuilder;
pub use pos_invoice_item::PosInvoiceItemId;
pub use pos_payment::PosPayment;
pub use pos_payment::PosPaymentBuilder;
pub use pos_payment::PosPaymentId;
pub use pos_profile::PosProfile;
pub use pos_profile::PosProfileBuilder;
pub use pos_profile::PosProfileId;
pub use pos_opening_entry::PosOpeningEntry;
pub use pos_opening_entry::PosOpeningEntryBuilder;
pub use pos_opening_entry::PosOpeningEntryId;
pub use pos_cash_movement::PosCashMovement;
pub use pos_cash_movement::PosCashMovementBuilder;
pub use pos_cash_movement::PosCashMovementId;
pub use pos_discount::PosDiscount;
pub use pos_discount::PosDiscountBuilder;
pub use pos_discount::PosDiscountId;
pub use pos_manager_pin::PosManagerPin;
pub use pos_manager_pin::PosManagerPinBuilder;
pub use pos_manager_pin::PosManagerPinId;
pub use pos_floor_plan::PosFloorPlan;
pub use pos_floor_plan::PosFloorPlanBuilder;
pub use pos_floor_plan::PosFloorPlanId;
pub use pos_table::PosTable;
pub use pos_table::PosTableBuilder;
pub use pos_table::PosTableId;
pub use pos_closing_status::PosClosingStatus;
pub use pos_invoice_status::PosInvoiceStatus;
pub use pos_payment_method::PosPaymentMethod;
pub use pos_cash_rounding_strategy::PosCashRoundingStrategy;
pub use pos_profile_status::PosProfileStatus;
pub use pos_session_status::PosSessionStatus;
pub use pos_cash_movement_type::PosCashMovementType;
use std::fmt::Debug;
pub trait Entity: Debug + Clone {
type Id: Debug + Clone + PartialEq;
fn entity_id(&self) -> &Self::Id;
fn entity_type() -> &'static str;
}
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use uuid::Uuid;
#[cfg(feature = "openapi")]
use utoipa::ToSchema;
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
#[cfg_attr(feature = "openapi", derive(ToSchema))]
pub struct AuditMetadata {
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub deleted_at: Option<DateTime<Utc>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<Uuid>,
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_by: Option<Uuid>,
#[serde(skip_serializing_if = "Option::is_none")]
pub deleted_by: Option<Uuid>,
}
impl AuditMetadata {
pub fn new() -> Self {
Self {
created_at: Some(Utc::now()),
..Default::default()
}
}
pub fn with_creator(creator_id: Uuid) -> Self {
Self {
created_at: Some(Utc::now()),
created_by: Some(creator_id),
..Default::default()
}
}
pub fn touch(&mut self) {
self.updated_at = Some(Utc::now());
}
pub fn touch_by(&mut self, updater_id: Uuid) {
self.updated_at = Some(Utc::now());
self.updated_by = Some(updater_id);
}
pub fn soft_delete(&mut self) {
self.deleted_at = Some(Utc::now());
}
pub fn soft_delete_by(&mut self, deleter_id: Uuid) {
self.deleted_at = Some(Utc::now());
self.deleted_by = Some(deleter_id);
}
pub fn restore(&mut self) {
self.deleted_at = None;
self.deleted_by = None;
}
pub fn is_deleted(&self) -> bool {
self.deleted_at.is_some()
}
pub fn is_active(&self) -> bool {
self.deleted_at.is_none()
}
}