Skip to content

Commit c60e304

Browse files
committed
refactor: nest seed_path configs under new 'accounting_init' parent
1 parent 9d92289 commit c60e304

File tree

8 files changed

+17
-64
lines changed

8 files changed

+17
-64
lines changed

core/credit/src/config.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::path::PathBuf;
2-
31
use serde::{Deserialize, Serialize};
42

53
use crate::primitives::CVLPct;
@@ -10,16 +8,13 @@ pub struct CreditConfig {
108
pub upgrade_buffer_cvl_pct: CVLPct,
119
#[serde(default = "default_customer_active_check_enabled")]
1210
pub customer_active_check_enabled: bool,
13-
#[serde(default = "default_chart_of_accounts_config_path")]
14-
pub chart_of_accounts_config_path: Option<PathBuf>,
1511
}
1612

1713
impl Default for CreditConfig {
1814
fn default() -> Self {
1915
CreditConfig {
2016
upgrade_buffer_cvl_pct: default_upgrade_buffer_cvl_pct(),
2117
customer_active_check_enabled: default_customer_active_check_enabled(),
22-
chart_of_accounts_config_path: default_chart_of_accounts_config_path(),
2318
}
2419
}
2520
}
@@ -31,7 +26,3 @@ fn default_upgrade_buffer_cvl_pct() -> CVLPct {
3126
fn default_customer_active_check_enabled() -> bool {
3227
true
3328
}
34-
35-
fn default_chart_of_accounts_config_path() -> Option<PathBuf> {
36-
None
37-
}

core/deposit/src/config.rs

Lines changed: 0 additions & 21 deletions
This file was deleted.

core/deposit/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
mod account;
55
mod chart_of_accounts_integration;
6-
mod config;
76
mod deposit;
87
mod deposit_account_balance;
98
pub mod error;
@@ -33,7 +32,6 @@ use account::*;
3332
pub use chart_of_accounts_integration::{
3433
ChartOfAccountsIntegrationConfig, ChartOfAccountsIntegrationConfigBuilderError,
3534
};
36-
pub use config::*;
3735
use deposit::*;
3836
pub use deposit::{Deposit, DepositsByCreatedAtCursor};
3937
pub use deposit_account_balance::DepositAccountBalance;

lana/app/src/accounting_init/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ mod seed;
44
pub mod error;
55

66
use crate::{
7-
accounting::ChartOfAccounts, app::ChartOfAccountsSeedPathsConfig, balance_sheet::BalanceSheets,
7+
accounting::ChartOfAccounts, app::AccountingInitConfig, balance_sheet::BalanceSheets,
88
credit::Credit, deposit::Deposits, primitives::CalaJournalId,
99
profit_and_loss::ProfitAndLossStatements, trial_balance::TrialBalances,
1010
};
@@ -46,14 +46,14 @@ impl ChartsInit {
4646
trial_balances: &TrialBalances,
4747
credit: &Credit,
4848
deposit: &Deposits,
49-
seed_paths_config: ChartOfAccountsSeedPathsConfig,
49+
accounting_init_config: AccountingInitConfig,
5050
) -> Result<(), AccountingInitError> {
5151
seed::charts_of_accounts::init(
5252
chart_of_accounts,
5353
trial_balances,
5454
credit,
5555
deposit,
56-
seed_paths_config,
56+
accounting_init_config,
5757
)
5858
.await
5959
}

lana/app/src/accounting_init/seed/charts_of_accounts.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ pub(crate) async fn init(
1414
trial_balances: &TrialBalances,
1515
credit: &Credit,
1616
deposit: &Deposits,
17-
seed_paths_config: ChartOfAccountsSeedPathsConfig,
17+
accounting_init_config: AccountingInitConfig,
1818
) -> Result<(), AccountingInitError> {
1919
let chart_id = create_chart_of_accounts(chart_of_accounts).await?;
2020

21-
if let Some(path) = seed_paths_config.clone().chart_of_accounts_seed_path {
21+
if let Some(path) = accounting_init_config.clone().chart_of_accounts_seed_path {
2222
seed_chart_of_accounts(
2323
chart_of_accounts,
2424
trial_balances,
2525
credit,
2626
deposit,
2727
chart_id,
2828
path,
29-
seed_paths_config,
29+
accounting_init_config,
3030
)
3131
.await?;
3232
}
@@ -57,14 +57,14 @@ async fn seed_chart_of_accounts(
5757
deposit: &Deposits,
5858
chart_id: ChartId,
5959
chart_of_accounts_seed_path: PathBuf,
60-
seed_paths_config: ChartOfAccountsSeedPathsConfig,
60+
accounting_init_config: AccountingInitConfig,
6161
) -> Result<(), AccountingInitError> {
62-
let ChartOfAccountsSeedPathsConfig {
62+
let AccountingInitConfig {
6363
credit_config_path,
6464
deposit_config_path,
6565

6666
chart_of_accounts_seed_path: _,
67-
} = seed_paths_config;
67+
} = accounting_init_config;
6868

6969
let data = std::fs::read_to_string(chart_of_accounts_seed_path)?;
7070
if let Some(new_account_set_ids) = chart_of_accounts

lana/app/src/app/config.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ use std::path::PathBuf;
44

55
use crate::{
66
applicant::SumsubConfig, credit::CreditConfig, customer_sync::CustomerSyncConfig,
7-
deposit::DepositConfig, job::JobExecutorConfig, report::ReportConfig,
8-
service_account::ServiceAccountConfig, storage::config::StorageConfig,
9-
user_onboarding::UserOnboardingConfig,
7+
job::JobExecutorConfig, report::ReportConfig, service_account::ServiceAccountConfig,
8+
storage::config::StorageConfig, user_onboarding::UserOnboardingConfig,
109
};
1110

1211
#[derive(Clone, Default, Debug, Deserialize, Serialize)]
@@ -20,8 +19,6 @@ pub struct AppConfig {
2019
#[serde(default)]
2120
pub credit: CreditConfig,
2221
#[serde(default)]
23-
pub deposit: DepositConfig,
24-
#[serde(default)]
2522
pub service_account: ServiceAccountConfig,
2623
#[serde(default)]
2724
pub report: ReportConfig,
@@ -32,7 +29,7 @@ pub struct AppConfig {
3229
#[serde(default)]
3330
pub customer_sync: CustomerSyncConfig,
3431
#[serde(default)]
35-
pub chart_of_accounts_seed_path: Option<PathBuf>,
32+
pub accounting_init: AccountingInitConfig,
3633
}
3734

3835
#[derive(Clone, Default, Debug, Deserialize, Serialize)]
@@ -42,21 +39,11 @@ pub struct UserConfig {
4239
}
4340

4441
#[derive(Clone, Default, Debug, Deserialize, Serialize)]
45-
pub struct ChartOfAccountsSeedPathsConfig {
42+
pub struct AccountingInitConfig {
4643
#[serde(default)]
4744
pub chart_of_accounts_seed_path: Option<PathBuf>,
4845
#[serde(default)]
4946
pub deposit_config_path: Option<PathBuf>,
5047
#[serde(default)]
5148
pub credit_config_path: Option<PathBuf>,
5249
}
53-
54-
impl From<AppConfig> for ChartOfAccountsSeedPathsConfig {
55-
fn from(config: AppConfig) -> Self {
56-
Self {
57-
chart_of_accounts_seed_path: config.chart_of_accounts_seed_path,
58-
credit_config_path: config.credit.chart_of_accounts_config_path,
59-
deposit_config_path: config.deposit.chart_of_accounts_config_path,
60-
}
61-
}
62-
}

lana/app/src/app/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ impl LanaApp {
6060
pub async fn run(pool: PgPool, config: AppConfig) -> Result<Self, ApplicationError> {
6161
sqlx::migrate!().run(&pool).await?;
6262

63-
let seed_config = ChartOfAccountsSeedPathsConfig::from(config.clone());
64-
6563
let mut jobs = Jobs::new(&pool, config.job_execution);
6664
let audit = Audit::new(&pool);
6765
let authz = init_authz(&pool, &audit).await?;
@@ -133,7 +131,7 @@ impl LanaApp {
133131
accounting.trial_balances(),
134132
&credit,
135133
&deposits,
136-
seed_config,
134+
config.accounting_init,
137135
)
138136
.await?;
139137

lana/app/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ pub mod audit {
8080
pub mod deposit {
8181
pub use deposit::{
8282
error, ChartOfAccountsIntegrationConfig, CoreDepositEvent, Deposit, DepositAccount,
83-
DepositAccountBalance, DepositAccountHistoryCursor, DepositAccountHistoryEntry,
84-
DepositConfig, DepositId, DepositsByCreatedAtCursor, Withdrawal, WithdrawalId,
85-
WithdrawalStatus, WithdrawalsByCreatedAtCursor,
83+
DepositAccountBalance, DepositAccountHistoryCursor, DepositAccountHistoryEntry, DepositId,
84+
DepositsByCreatedAtCursor, Withdrawal, WithdrawalId, WithdrawalStatus,
85+
WithdrawalsByCreatedAtCursor,
8686
};
8787

8888
pub type Deposits =

0 commit comments

Comments
 (0)