Skip to content

Commit

Permalink
chore: reduce account code width
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Jan 16, 2025
1 parent ef407b3 commit 8f21921
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions core/chart-of-accounts/src/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
use super::primitives::{ChartId, DebitOrCredit};
use error::*;

const ENCODED_PATH_WIDTH: usize = 8;
const ENCODED_PATH_WIDTH: usize = 5;

#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Hash, Deserialize)]
pub struct AccountIdx(u64);
Expand All @@ -25,7 +25,6 @@ impl From<u32> for AccountIdx {
impl AccountIdx {
pub const FIRST: Self = Self(1);
pub const MAX_TWO_DIGIT: Self = Self(99);
pub const MAX_THREE_DIGIT: Self = Self(999);

pub const fn next(&self) -> Self {
Self(self.0 + 1)
Expand Down Expand Up @@ -178,7 +177,7 @@ mod tests {
#[test]
fn test_category_formatting() {
let path = ChartCategory::Assets;
assert_eq!(path.to_string(), "10000000");
assert_eq!(path.to_string(), "10000");
}

#[test]
Expand All @@ -187,7 +186,7 @@ mod tests {
category: ChartCategory::Liabilities,
index: 1.into(),
};
assert_eq!(path.to_string(), "20100000");
assert_eq!(path.to_string(), "20100");
}

#[test]
Expand All @@ -197,7 +196,7 @@ mod tests {
control_index: 1.into(),
index: 2.into(),
};
assert_eq!(path.to_string(), "30102000");
assert_eq!(path.to_string(), "30102");
}
}

Expand Down

0 comments on commit 8f21921

Please sign in to comment.