...
This commit is contained in:
@@ -6,6 +6,7 @@ use crate::models::gov::{
|
||||
Company, Shareholder, Meeting, User, Vote, Resolution,
|
||||
Committee, ComplianceRequirement, ComplianceDocument, ComplianceAudit
|
||||
};
|
||||
use crate::models::circle::{Circle, Member, Name, Wallet, Asset};
|
||||
|
||||
// Implement model-specific methods for Product
|
||||
impl_model_methods!(Product, product, products);
|
||||
@@ -59,4 +60,16 @@ impl_model_methods!(ComplianceRequirement, compliance_requirement, compliance_re
|
||||
impl_model_methods!(ComplianceDocument, compliance_document, compliance_documents);
|
||||
|
||||
// Implement model-specific methods for ComplianceAudit
|
||||
impl_model_methods!(ComplianceAudit, compliance_audit, compliance_audits);
|
||||
impl_model_methods!(ComplianceAudit, compliance_audit, compliance_audits);
|
||||
|
||||
// Implement model-specific methods for Circle
|
||||
impl_model_methods!(Circle, circle, circles);
|
||||
|
||||
// Implement model-specific methods for Member
|
||||
impl_model_methods!(Member, member, members);
|
||||
|
||||
// Implement model-specific methods for Name
|
||||
impl_model_methods!(Name, name, names);
|
||||
|
||||
// Implement model-specific methods for Wallet
|
||||
impl_model_methods!(Wallet, wallet, wallets);
|
@@ -235,6 +235,10 @@ impl ContractBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Storable for Contract {}
|
||||
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Contract {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
use crate::db::model::{Model, Storable};
|
||||
use crate::db::model::Model;
|
||||
use crate::db::{Storable, DbError, DbResult};
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use rhai::{CustomType, EvalAltResult, TypeBuilder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -72,6 +73,9 @@ impl CurrencyBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Storable trait
|
||||
impl Storable for Currency {}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Currency {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -133,6 +133,9 @@ impl CustomerBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Storable for Customer {}
|
||||
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Customer {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -91,6 +91,9 @@ impl ExchangeRateBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl Storable for ExchangeRate {}
|
||||
// Implement Model trait
|
||||
impl Model for ExchangeRate {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -500,6 +500,8 @@ impl InvoiceBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Storable for Invoice {}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Invoice {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
use crate::db::model::{Model, Storable};
|
||||
use crate::db::model::Model;
|
||||
use crate::db::Storable;
|
||||
use chrono::{DateTime, Duration, Utc};
|
||||
use rhai::{CustomType, EvalAltResult, TypeBuilder, export_module};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -342,6 +343,9 @@ impl ProductBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Storable trait
|
||||
impl Storable for Product {}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Product {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -1,4 +1,4 @@
|
||||
use crate::db::{Model, Storable};
|
||||
use crate::db::{Model, Storable, DbError, DbResult};
|
||||
use crate::models::biz::Currency; // Use crate:: for importing from the module
|
||||
// use super::db::Model; // Removed old Model trait import
|
||||
use chrono::{DateTime, Utc};
|
||||
@@ -566,6 +566,9 @@ impl SaleBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Storable trait
|
||||
impl Storable for Sale {}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Sale {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
use crate::models::biz::Currency; // Use crate:: for importing from the module
|
||||
use crate::db::{Model, Storable}; // Import Model trait from db module
|
||||
use crate::db::{Model, Storable, DbError, DbResult}; // Import Model trait from db module
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -491,6 +491,10 @@ impl ServiceBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Storable trait
|
||||
impl Storable for Service {
|
||||
}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Service {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::db::{Model, Storable};
|
||||
use crate::db::{Model, Storable, DbError, DbResult};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Circle represents a collection of members (users or other circles)
|
||||
@@ -28,6 +28,9 @@ impl Circle {
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Storable trait
|
||||
impl Storable for Circle {}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Circle {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::db::{Model, Storable};
|
||||
use crate::db::{Model, Storable, DbError, DbResult};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Role represents the role of a member in a circle
|
||||
@@ -67,6 +67,10 @@ impl Member {
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Storable trait
|
||||
impl Storable for Member {
|
||||
}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Member {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::db::{Model, Storable};
|
||||
use crate::db::{Model, Storable, DbError, DbResult};
|
||||
|
||||
/// Record types for a DNS record
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -57,6 +57,10 @@ impl Name {
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Storable trait
|
||||
impl Storable for Name {
|
||||
}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Name {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::db::{Model, Storable};
|
||||
use crate::db::{Model, Storable, DbError, DbResult};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Asset represents a cryptocurrency asset in a wallet
|
||||
@@ -70,7 +70,8 @@ impl Wallet {
|
||||
}
|
||||
|
||||
// Implement Storable trait
|
||||
impl Storable for Wallet {}
|
||||
impl Storable for Wallet {
|
||||
}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Wallet {
|
||||
|
@@ -1,5 +1,7 @@
|
||||
use crate::db::{Model, Storable, DbError, DbResult};
|
||||
use crate::db::{Model, Storable, DbResult};
|
||||
use crate::db::db::DB;
|
||||
use super::shareholder::Shareholder; // Use super:: for sibling module
|
||||
use super::Resolution;
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fmt::Debug;
|
||||
@@ -87,7 +89,7 @@ pub struct Company {
|
||||
// Removed shareholders property
|
||||
}
|
||||
|
||||
|
||||
impl Storable for Company{}
|
||||
|
||||
// Model requires get_id and db_prefix
|
||||
impl Model for Company {
|
||||
@@ -150,24 +152,22 @@ impl Company {
|
||||
}
|
||||
|
||||
/// Link this company to a Circle for access control
|
||||
pub fn link_to_circle(&mut self, circle_id: u32) -> DbResult<()> {
|
||||
pub fn link_to_circle(&mut self, circle_id: u32) {
|
||||
// Implementation would involve updating a mapping in a separate database
|
||||
// For now, we'll just update the timestamp to indicate the change
|
||||
self.updated_at = Utc::now();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Link this company to a Customer in the biz module
|
||||
pub fn link_to_customer(&mut self, customer_id: u32) -> DbResult<()> {
|
||||
pub fn link_to_customer(&mut self, customer_id: u32) {
|
||||
// Implementation would involve updating a mapping in a separate database
|
||||
// For now, we'll just update the timestamp to indicate the change
|
||||
self.updated_at = Utc::now();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get all resolutions for this company
|
||||
pub fn get_resolutions(&self, db: &DB) -> DbResult<Vec<super::Resolution>> {
|
||||
let all_resolutions = db.list::<super::Resolution>()?;
|
||||
pub fn get_resolutions(&self, db: &DB) -> DbResult<Vec<Resolution>> {
|
||||
let all_resolutions = db.list::<Resolution>()?;
|
||||
let company_resolutions = all_resolutions
|
||||
.into_iter()
|
||||
.filter(|resolution| resolution.company_id == self.id)
|
||||
|
@@ -1,207 +0,0 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use crate::db::{Model, Storable, DB, DbError, DbResult};
|
||||
use crate::models::gov::Company;
|
||||
|
||||
/// ComplianceRequirement represents a regulatory requirement
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct ComplianceRequirement {
|
||||
pub id: u32,
|
||||
pub company_id: u32,
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub regulation: String,
|
||||
pub authority: String,
|
||||
pub deadline: DateTime<Utc>,
|
||||
pub status: String,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
/// ComplianceDocument represents a compliance document
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct ComplianceDocument {
|
||||
pub id: u32,
|
||||
pub requirement_id: u32,
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub file_path: String,
|
||||
pub file_type: String,
|
||||
pub uploaded_by: u32, // User ID
|
||||
pub uploaded_at: DateTime<Utc>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
/// ComplianceAudit represents a compliance audit
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct ComplianceAudit {
|
||||
pub id: u32,
|
||||
pub company_id: u32,
|
||||
pub title: String,
|
||||
pub description: String,
|
||||
pub auditor: String,
|
||||
pub start_date: DateTime<Utc>,
|
||||
pub end_date: DateTime<Utc>,
|
||||
pub status: String,
|
||||
pub findings: String,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
impl ComplianceRequirement {
|
||||
/// Create a new compliance requirement with default values
|
||||
pub fn new(
|
||||
id: u32,
|
||||
company_id: u32,
|
||||
title: String,
|
||||
description: String,
|
||||
regulation: String,
|
||||
authority: String,
|
||||
deadline: DateTime<Utc>,
|
||||
) -> Self {
|
||||
let now = Utc::now();
|
||||
Self {
|
||||
id,
|
||||
company_id,
|
||||
title,
|
||||
description,
|
||||
regulation,
|
||||
authority,
|
||||
deadline,
|
||||
status: "Pending".to_string(),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the status of the requirement
|
||||
pub fn update_status(&mut self, status: String) {
|
||||
self.status = status;
|
||||
self.updated_at = Utc::now();
|
||||
}
|
||||
|
||||
/// Get the company associated with this requirement
|
||||
pub fn get_company(&self, db: &DB) -> DbResult<Company> {
|
||||
db.get::<Company>(self.company_id)
|
||||
}
|
||||
|
||||
/// Get all documents associated with this requirement
|
||||
pub fn get_documents(&self, db: &DB) -> DbResult<Vec<ComplianceDocument>> {
|
||||
let all_documents = db.list::<ComplianceDocument>()?;
|
||||
let requirement_documents = all_documents
|
||||
.into_iter()
|
||||
.filter(|doc| doc.requirement_id == self.id)
|
||||
.collect();
|
||||
|
||||
Ok(requirement_documents)
|
||||
}
|
||||
}
|
||||
|
||||
impl ComplianceDocument {
|
||||
/// Create a new compliance document with default values
|
||||
pub fn new(
|
||||
id: u32,
|
||||
requirement_id: u32,
|
||||
title: String,
|
||||
description: String,
|
||||
file_path: String,
|
||||
file_type: String,
|
||||
uploaded_by: u32,
|
||||
) -> Self {
|
||||
let now = Utc::now();
|
||||
Self {
|
||||
id,
|
||||
requirement_id,
|
||||
title,
|
||||
description,
|
||||
file_path,
|
||||
file_type,
|
||||
uploaded_by,
|
||||
uploaded_at: now,
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the requirement associated with this document
|
||||
pub fn get_requirement(&self, db: &DB) -> DbResult<ComplianceRequirement> {
|
||||
db.get::<ComplianceRequirement>(self.requirement_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl ComplianceAudit {
|
||||
/// Create a new compliance audit with default values
|
||||
pub fn new(
|
||||
id: u32,
|
||||
company_id: u32,
|
||||
title: String,
|
||||
description: String,
|
||||
auditor: String,
|
||||
start_date: DateTime<Utc>,
|
||||
end_date: DateTime<Utc>,
|
||||
) -> Self {
|
||||
let now = Utc::now();
|
||||
Self {
|
||||
id,
|
||||
company_id,
|
||||
title,
|
||||
description,
|
||||
auditor,
|
||||
start_date,
|
||||
end_date,
|
||||
status: "Planned".to_string(),
|
||||
findings: String::new(),
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
}
|
||||
}
|
||||
|
||||
/// Update the status of the audit
|
||||
pub fn update_status(&mut self, status: String) {
|
||||
self.status = status;
|
||||
self.updated_at = Utc::now();
|
||||
}
|
||||
|
||||
/// Update the findings of the audit
|
||||
pub fn update_findings(&mut self, findings: String) {
|
||||
self.findings = findings;
|
||||
self.updated_at = Utc::now();
|
||||
}
|
||||
|
||||
/// Get the company associated with this audit
|
||||
pub fn get_company(&self, db: &DB) -> DbResult<Company> {
|
||||
db.get::<Company>(self.company_id)
|
||||
}
|
||||
}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for ComplianceRequirement {
|
||||
fn get_id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn db_prefix() -> &'static str {
|
||||
"compliance_requirement"
|
||||
}
|
||||
}
|
||||
|
||||
impl Model for ComplianceDocument {
|
||||
fn get_id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn db_prefix() -> &'static str {
|
||||
"compliance_document"
|
||||
}
|
||||
}
|
||||
|
||||
impl Model for ComplianceAudit {
|
||||
fn get_id(&self) -> u32 {
|
||||
self.id
|
||||
}
|
||||
|
||||
fn db_prefix() -> &'static str {
|
||||
"compliance_audit"
|
||||
}
|
||||
}
|
@@ -175,6 +175,7 @@ impl Meeting {
|
||||
}
|
||||
}
|
||||
|
||||
impl Storable for Meeting{}
|
||||
// Implement Model trait
|
||||
impl Model for Meeting {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -6,7 +6,6 @@ pub mod vote;
|
||||
pub mod resolution;
|
||||
// All modules:
|
||||
pub mod committee;
|
||||
pub mod compliance;
|
||||
|
||||
// Re-export all model types for convenience
|
||||
pub use company::{Company, CompanyStatus, BusinessType};
|
||||
@@ -16,7 +15,6 @@ pub use user::User;
|
||||
pub use vote::{Vote, VoteOption, Ballot, VoteStatus};
|
||||
pub use resolution::{Resolution, ResolutionStatus, Approval};
|
||||
pub use committee::{Committee, CommitteeMember, CommitteeRole};
|
||||
pub use compliance::{ComplianceRequirement, ComplianceDocument, ComplianceAudit};
|
||||
|
||||
// Re-export database components from db module
|
||||
pub use crate::db::{DB, DBBuilder, Model, Storable, DbError, DbResult};
|
@@ -180,6 +180,9 @@ impl Resolution {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
impl Storable for Resolution{}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Resolution {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -63,6 +63,8 @@ impl Shareholder {
|
||||
}
|
||||
}
|
||||
|
||||
impl Storable for Shareholder{}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for Shareholder {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -42,6 +42,8 @@ impl User {
|
||||
}
|
||||
}
|
||||
|
||||
impl Storable for User{}
|
||||
|
||||
// Implement Model trait
|
||||
impl Model for User {
|
||||
fn get_id(&self) -> u32 {
|
||||
|
@@ -51,7 +51,7 @@ pub struct Ballot {
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
|
||||
// Removed old Model trait implementation
|
||||
impl Storable for Vote{}
|
||||
|
||||
impl Vote {
|
||||
/// Create a new vote with default timestamps
|
||||
|
Reference in New Issue
Block a user