db/specs/models/legal/contract.v
Mahmoud-Emad 970299b1a4 feat: Add reminder functionality to ContractSigner model
- Added `last_reminder_mail_sent_at` field to track reminder
  timestamps.
- Implemented `can_send_reminder` to check if a reminder can be
  sent based on a 30-minute cooldown.
- Added `reminder_cooldown_remaining` to get remaining cooldown
  time.
- Added `mark_reminder_sent` to update reminder timestamp.
- Added example demonstrating reminder functionality in
  `legal_contract_example.rs`.
- Added tests for reminder functionality in
  `test_reminder_functionality.rs`.
- Updated Rhai scripts to include reminder-related functions and
  tests.
- Improved formatting and clarity in example code.
2025-06-10 15:41:49 +03:00

68 lines
2.1 KiB
V

module contract
import base
import freeflowuniverse.herolib.data.ourtime
// Contract represents a legal agreement
pub struct Contract {
base.Base // Base struct for common fields
pub mut:
id string // Unique ID for the contract (UUID string)
title string
description string
contract_type string // service, employment, nda, sla, partnership, distribution, license, membership, other
status ContractStatus
created_at ourtime.OurTime
updated_at ourtime.OurTime
created_by string // User ID or name of the creator
terms_and_conditions string // JSON string or markdown
start_date ourtime.OurTime // Optional
end_date ourtime.OurTime // Optional
renewal_period_days int // Optional (0 if not applicable)
next_renewal_date ourtime.OurTime // Optional
signers []ContractSigner
revisions []ContractRevision
current_version u32
last_signed_date ourtime.OurTime // Optional
}
// ContractRevision represents a version of the contract content
pub struct ContractRevision {
// base.Base // If applicable
pub mut:
version u32
content string // The actual content of the contract revision
created_at ourtime.OurTime
created_by string // User ID or name of the creator
comments string // Optional in Rust, string can be empty
}
// ContractStatus defines the possible statuses of a contract
pub enum ContractStatus {
draft
pending_signatures
signed
active
expired
cancelled
}
// ContractSigner represents a party involved in signing a contract
pub struct ContractSigner {
pub mut:
id string // Unique ID for the signer (UUID string)
name string
email string
status SignerStatus
signed_at ourtime.OurTime // Optional in Rust, OurTime can be zero
comments string // Optional in Rust, string can be empty
last_reminder_mail_sent_at ourtime.OurTime // Unix timestamp of last reminder sent
}
// SignerStatus defines the status of a contract signer
pub enum SignerStatus {
pending
signed
rejected
}