From 3c70c577300719d0d2669f5d7ea4f60d8f4cf903 Mon Sep 17 00:00:00 2001 From: vindard <17693119+vindard@users.noreply.github.com> Date: Fri, 24 Jan 2025 14:08:41 -0400 Subject: [PATCH] chore: add control_sub_account to control account cala account set --- core/chart-of-accounts/src/lib.rs | 19 ++++++++++++++++--- .../tests/chart_of_accounts.rs | 2 +- core/deposit/tests/deposit.rs | 2 +- core/deposit/tests/withdraw.rs | 2 +- .../seed/charts_of_accounts.rs | 2 +- 5 files changed, 20 insertions(+), 7 deletions(-) diff --git a/core/chart-of-accounts/src/lib.rs b/core/chart-of-accounts/src/lib.rs index 2ff513725..3d38f8aa0 100644 --- a/core/chart-of-accounts/src/lib.rs +++ b/core/chart-of-accounts/src/lib.rs @@ -255,7 +255,7 @@ where &self, id: impl Into + std::fmt::Debug, chart_id: impl Into + std::fmt::Debug, - control_account: ControlAccountPath, + control_account: ControlAccountDetails, name: String, reference: String, ) -> Result { @@ -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?; @@ -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?; diff --git a/core/chart-of-accounts/tests/chart_of_accounts.rs b/core/chart-of-accounts/tests/chart_of_accounts.rs index 0f6a70449..dd195a1c7 100644 --- a/core/chart-of-accounts/tests/chart_of_accounts.rs +++ b/core/chart-of-accounts/tests/chart_of_accounts.rs @@ -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(), ) diff --git a/core/deposit/tests/deposit.rs b/core/deposit/tests/deposit.rs index 10f70a60e..54bbcb326 100644 --- a/core/deposit/tests/deposit.rs +++ b/core/deposit/tests/deposit.rs @@ -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(), ) diff --git a/core/deposit/tests/withdraw.rs b/core/deposit/tests/withdraw.rs index 82fd7ec11..b9ba5fce3 100644 --- a/core/deposit/tests/withdraw.rs +++ b/core/deposit/tests/withdraw.rs @@ -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(), ) diff --git a/lana/app/src/accounting_init/seed/charts_of_accounts.rs b/lana/app/src/accounting_init/seed/charts_of_accounts.rs index 89c54e827..121e10cc2 100644 --- a/lana/app/src/accounting_init/seed/charts_of_accounts.rs +++ b/lana/app/src/accounting_init/seed/charts_of_accounts.rs @@ -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, )