Skip to content

Commit

Permalink
refactor: rename 'ChartCategoryPath'
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Jan 13, 2025
1 parent deb75a3 commit 35505aa
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 89 deletions.
40 changes: 20 additions & 20 deletions core/chart-of-accounts/src/chart_of_accounts/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ pub struct Chart {
}

impl Chart {
fn next_control_account(&self, category: ChartCategoryPath) -> Result<ChartPath, ChartError> {
fn next_control_account(&self, category: ChartCategory) -> Result<ChartPath, ChartError> {
Ok(self
.events
.iter_all()
Expand Down Expand Up @@ -82,7 +82,7 @@ impl Chart {

pub fn create_control_account(
&mut self,
category: ChartCategoryPath,
category: ChartCategory,
name: String,
reference: String,
audit_info: AuditInfo,
Expand Down Expand Up @@ -281,7 +281,7 @@ impl IntoEvents<ChartEvent> for NewChart {

#[cfg(test)]
mod tests {
use crate::path::{AccountIdx, ChartCategoryPath};
use crate::path::{AccountIdx, ChartCategory};

use super::*;

Expand Down Expand Up @@ -332,15 +332,15 @@ mod tests {
let mut chart = init_chart_of_events();
match chart
.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
dummy_audit_info(),
)
.unwrap()
{
ChartPath::ControlAccount { category, index } => {
assert_eq!(category, ChartCategoryPath::Assets);
assert_eq!(category, ChartCategory::Assets);
assert_eq!(index, AccountIdx::FIRST);
}
other => panic!("Expected FIRST control account, got {:?}", other),
Expand All @@ -352,15 +352,15 @@ mod tests {
let mut chart = init_chart_of_events();
chart
.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"Assets #1".to_string(),
"assets".to_string(),
dummy_audit_info(),
)
.unwrap();

match chart.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"Assets #2".to_string(),
"assets".to_string(),
dummy_audit_info(),
Expand All @@ -379,7 +379,7 @@ mod tests {
let mut chart = init_chart_of_events();
let control_account = chart
.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
dummy_audit_info(),
Expand All @@ -400,7 +400,7 @@ mod tests {
control_index,
index,
} => {
assert_eq!(category, ChartCategoryPath::Assets);
assert_eq!(category, ChartCategory::Assets);
assert_eq!(control_index, AccountIdx::FIRST);
assert_eq!(index, AccountIdx::FIRST);
}
Expand All @@ -413,7 +413,7 @@ mod tests {
let mut chart = init_chart_of_events();
let control_account = chart
.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
dummy_audit_info(),
Expand Down Expand Up @@ -451,7 +451,7 @@ mod tests {
let mut chart = init_chart_of_events();
let control_account = chart
.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
dummy_audit_info(),
Expand Down Expand Up @@ -488,7 +488,7 @@ mod tests {
},
..
} => {
assert_eq!(category, ChartCategoryPath::Assets);
assert_eq!(category, ChartCategory::Assets);
assert_eq!(control_index, AccountIdx::FIRST);
assert_eq!(control_sub_index, AccountIdx::FIRST);
assert_eq!(index, AccountIdx::FIRST);
Expand All @@ -503,7 +503,7 @@ mod tests {

chart
.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"First".to_string(),
"assets-01".to_string(),
dummy_audit_info(),
Expand All @@ -512,15 +512,15 @@ mod tests {

match chart
.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"Second".to_string(),
"assets-02".to_string(),
dummy_audit_info(),
)
.unwrap()
{
ChartPath::ControlAccount { category, index } => {
assert_eq!(category, ChartCategoryPath::Assets);
assert_eq!(category, ChartCategory::Assets);
assert_eq!(index, AccountIdx::FIRST.next());
}
other => panic!("Expected SECOND control account, got {:?}", other),
Expand All @@ -532,7 +532,7 @@ mod tests {
let mut chart = init_chart_of_events();
let control_account = chart
.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
dummy_audit_info(),
Expand Down Expand Up @@ -562,7 +562,7 @@ mod tests {
control_index,
index,
} => {
assert_eq!(category, ChartCategoryPath::Assets);
assert_eq!(category, ChartCategory::Assets);
assert_eq!(control_index, AccountIdx::FIRST);
assert_eq!(index, AccountIdx::FIRST.next());
}
Expand All @@ -575,7 +575,7 @@ mod tests {
let mut chart = init_chart_of_events();
let control_account = chart
.create_control_account(
ChartCategoryPath::Assets,
ChartCategory::Assets,
"Assets".to_string(),
"assets".to_string(),
dummy_audit_info(),
Expand Down Expand Up @@ -624,7 +624,7 @@ mod tests {
},
..
} => {
assert_eq!(category, ChartCategoryPath::Assets);
assert_eq!(category, ChartCategory::Assets);
assert_eq!(control_index, AccountIdx::FIRST);
assert_eq!(control_sub_index, AccountIdx::FIRST);
assert_eq!(index, AccountIdx::FIRST.next());
Expand All @@ -638,7 +638,7 @@ mod tests {
let mut chart = init_chart_of_events();
let audit_info = dummy_audit_info();

let category = ChartCategoryPath::Assets;
let category = ChartCategory::Assets;
let control_account = chart
.create_control_account(
category,
Expand Down
2 changes: 1 addition & 1 deletion core/chart-of-accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ where
pub async fn create_control_account(
&self,
chart_id: impl Into<ChartId>,
category: CategoryPath,
category: ChartCategory,
name: String,
reference: String,
) -> Result<ChartPath, CoreChartOfAccountsError> {
Expand Down
12 changes: 6 additions & 6 deletions core/chart-of-accounts/src/path/error.rs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
use thiserror::Error;

use crate::path::{AccountIdx, ChartCategoryPath};
use crate::path::{AccountIdx, ChartCategory};

#[derive(Error, Debug)]
pub enum ChartPathError {
#[error("ChartError - ParseIntError: {0}")]
ParseIntError(#[from] std::num::ParseIntError),
#[error("ChartError - InvalidCategoryPathForNewControlAccount")]
InvalidCategoryPathForNewControlAccount,
#[error("ChartError - InvalidCategoryForNewControlAccount")]
InvalidCategoryForNewControlAccount,
#[error("ChartError - InvalidControlAccountPathForNewControlSubAccount")]
InvalidControlAccountPathForNewControlSubAccount,
#[error("ChartError - InvalidSubControlAccountPathForNewTransactionAccount")]
InvalidSubControlAccountPathForNewTransactionAccount,
#[error("ChartError - ControlIndexOverflowForCategory: Category '{0}'")]
ControlIndexOverflowForCategory(ChartCategoryPath),
ControlIndexOverflowForCategory(ChartCategory),
#[error(
"ChartError - ControlSubIndexOverflowForControlAccount: Category '{0}' / Control '{1}'"
)]
ControlSubIndexOverflowForControlAccount(ChartCategoryPath, AccountIdx),
ControlSubIndexOverflowForControlAccount(ChartCategory, AccountIdx),
#[error("ChartError - TransactionIndexOverflowForControlSubAccount: Category '{0}' / Control '{1}' / Sub-control '{2}'")]
TransactionIndexOverflowForControlSubAccount(ChartCategoryPath, AccountIdx, AccountIdx),
TransactionIndexOverflowForControlSubAccount(ChartCategory, AccountIdx, AccountIdx),
#[error("ChartError - InvalidCodeLength: {0}")]
InvalidCodeLength(String),
#[error("ChartError - InvalidCategoryNumber: {0}")]
Expand Down
Loading

0 comments on commit 35505aa

Please sign in to comment.