Skip to content

Commit

Permalink
chore: add control_sub_account to control account cala account set
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard committed Jan 24, 2025
1 parent ba78b62 commit 3c70c57
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
19 changes: 16 additions & 3 deletions core/chart-of-accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ where
&self,
id: impl Into<LedgerAccountSetId> + std::fmt::Debug,
chart_id: impl Into<ChartId> + std::fmt::Debug,
control_account: ControlAccountPath,
control_account: ControlAccountDetails,
name: String,
reference: String,
) -> Result<ControlSubAccountDetails, CoreChartOfAccountsError> {
Expand All @@ -276,8 +276,13 @@ where

let mut chart = self.repo.find_by_id(chart_id).await?;

let control_sub_account =
chart.create_control_sub_account(id, control_account, name, reference, audit_info)?;
let control_sub_account = chart.create_control_sub_account(
id,
control_account.path,
name,
reference,
audit_info,
)?;

self.repo.update_in_op(&mut op, &mut chart).await?;

Expand All @@ -294,6 +299,14 @@ where
.account_sets()
.create_in_op(&mut op, new_account_set)
.await?;
self.cala
.account_sets()
.add_member_in_op(
&mut op,
control_account.account_set_id,
control_sub_account.account_set_id,
)
.await?;

op.commit().await?;

Expand Down
2 changes: 1 addition & 1 deletion core/chart-of-accounts/tests/chart_of_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async fn create_and_populate() -> anyhow::Result<()> {
.create_control_sub_account(
LedgerAccountSetId::new(),
chart_id,
control_account.path,
control_account.clone(),
control_sub_account_name.to_string(),
"fixed-term-credit-facilities-receivable".to_string(),
)
Expand Down
2 changes: 1 addition & 1 deletion core/deposit/tests/deposit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ async fn deposit() -> anyhow::Result<()> {
.create_control_sub_account(
LedgerAccountSetId::new(),
chart_id,
control_account.path,
control_account,
"User Deposits".to_string(),
"user-deposits".to_string(),
)
Expand Down
2 changes: 1 addition & 1 deletion core/deposit/tests/withdraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ async fn overdraw_and_cancel_withdrawal() -> anyhow::Result<()> {
.create_control_sub_account(
LedgerAccountSetId::new(),
chart_id,
control_account.path,
control_account,
"User Deposits".to_string(),
"user-deposits".to_string(),
)
Expand Down
2 changes: 1 addition & 1 deletion lana/app/src/accounting_init/seed/charts_of_accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ async fn create_control_sub_account(
.create_control_sub_account(
id,
chart_id,
control_account.path,
control_account.clone(),
sub_name,
sub_reference,
)
Expand Down

0 comments on commit 3c70c57

Please sign in to comment.