1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! Audit scope model (ISA 220 / ISA 300 planning).
//!
//! An [`AuditScope`] defines the boundaries of an audit engagement:
//! which entity is in scope, which financial statement areas are covered,
//! and what the applicable materiality threshold is.
//!
//! Each scope record links to an [`AuditEngagement`] and is referenced
//! by [`CombinedRiskAssessment`] records to indicate the planning boundary.
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};
/// Minimal audit scope record describing what the engagement covers.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AuditScope {
/// Unique scope identifier (e.g. "SCOPE-AUD-2025-001-C001").
pub id: String,
/// Engagement this scope belongs to (FK → AuditEngagement.engagement_id).
pub engagement_id: String,
/// Entity / company code in scope.
pub entity_code: String,
/// Financial statement areas / audit focus areas covered by this scope.
pub scope_areas: Vec<String>,
/// Planning materiality threshold applicable to this scope.
pub materiality: Decimal,
}
impl AuditScope {
/// Standard scope areas used when no specific areas are configured.
pub const DEFAULT_SCOPE_AREAS: &'static [&'static str] = &[
"Revenue",
"Accounts Receivable",
"Inventory",
"Property Plant & Equipment",
"Accounts Payable",
"Payroll",
"Cash & Bank",
"Financial Reporting Close",
];
/// Create a new `AuditScope` with default scope areas.
pub fn new(
id: impl Into<String>,
engagement_id: impl Into<String>,
entity_code: impl Into<String>,
materiality: Decimal,
) -> Self {
Self {
id: id.into(),
engagement_id: engagement_id.into(),
entity_code: entity_code.into(),
scope_areas: Self::DEFAULT_SCOPE_AREAS
.iter()
.map(|s| s.to_string())
.collect(),
materiality,
}
}
/// Create an `AuditScope` with explicit scope areas.
pub fn with_areas(
id: impl Into<String>,
engagement_id: impl Into<String>,
entity_code: impl Into<String>,
scope_areas: Vec<String>,
materiality: Decimal,
) -> Self {
Self {
id: id.into(),
engagement_id: engagement_id.into(),
entity_code: entity_code.into(),
scope_areas,
materiality,
}
}
}