Skip to content

feat: seed module configs #2010

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions apps/admin-panel/cypress/e2e/modules.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ describe("Modules Configuration", () => {
cy.takeScreenshot("1_modules_configuration")

cy.contains(t(Modules + ".deposit.title")).should("be.visible")
cy.contains(t(Modules + ".deposit.setTitle")).click()

cy.takeScreenshot("2_deposit_configuration")
})

it("should configure deposit module", () => {
cy.visit("/modules")
cy.contains(t(Modules + ".credit.title")).should("be.visible")
cy.contains(t(Modules + ".credit.setTitle")).click()

cy.takeScreenshot("3_credit_configuration")
})
Expand Down
6 changes: 3 additions & 3 deletions apps/admin-panel/cypress/e2e/trial-balance.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ describe(t(TB + ".title"), () => {

it("should render trial balance with accounts and their balances", () => {
cy.graphqlRequest<{ data: GetTrialBalanceQuery }>(print(GetTrialBalanceDocument), {
from: lastMonthDate.toISOString().split('T')[0],
until: currentDate.toISOString().split('T')[0],
from: lastMonthDate.toISOString().split("T")[0],
until: currentDate.toISOString().split("T")[0],
first: 10,
}).then((response) => {
response.data.trialBalance?.accounts.edges.forEach(({ node: account }) => {
Expand All @@ -33,7 +33,7 @@ describe(t(TB + ".title"), () => {
.contains(new RegExp(`^${account.name}$`))
.parent("tr")
.within(() => {
cy.get("td").should("have.length", 5)
cy.get("td").should("have.length", 6)
})
})
})
Expand Down
27 changes: 21 additions & 6 deletions bats/coa.csv → bats/accounting-init/coa.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@
,,,,,
,02,,Receivables,,
,,,,,
,,0201,Accounts Receivable,,
,,0201,Interest Receivable,,
,,,,,
,,0202,Notes Receivable,,
,,0202,Loans Receivable,,
,,,,,
,,0203,Overdue Loans Receivable,,
,,,,,
,03,,Inventory,,
,,,,,
Expand Down Expand Up @@ -44,9 +46,11 @@
,,,,,
,01,,Accounts Payable,,
,,,,,
,,0101,Trade Payables,,
,,0101,Deposits Payable,,
,,,,,
,,0102,Trade Payable,,
,,,,,
,,0102,Accrued Expenses,,
,,0103,Accrued Expenses,,
,,,,,
,02,,Short-term Loans,,
,,,,,
Expand Down Expand Up @@ -122,10 +126,21 @@
,,,,,
,01,,Interest Income,,
,,,,,
,02,,Gain on Sale of Assets,,
,02,,Fee Income,,
,,,,,
,03,,Gain on Sale of Assets,,
,,,,,
62,,,Other Expenses,,
,,,,,
,01,,Loss on Sale of Assets,,
,,,,,
,02,,Foreign Exchange Loss,,
,02,,Foreign Exchange Loss,,
,,,,,
7,,,Memorandum,,
,,,,,
71,,,Other Obligations,,
,,,,,
,01,,Facility Obligations,,
,,,,,
,02,,Collateral Obligations,,
,,,,,
43 changes: 43 additions & 0 deletions bats/accounting-init/credit-module-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"facility_omnibus_parent_code": "71.01",
"collateral_omnibus_parent_code": "71.02",
"facility_parent_code": "71.01",
"collateral_parent_code": "71.02",
"interest_income_parent_code": "61.01",
"fee_income_parent_code": "61.02",
"short_term_individual_interest_receivable_parent_code": "11.02.0201",
"short_term_government_entity_interest_receivable_parent_code": "11.02.0201",
"short_term_private_company_interest_receivable_parent_code": "11.02.0201",
"short_term_bank_interest_receivable_parent_code": "11.02.0201",
"short_term_financial_institution_interest_receivable_parent_code": "11.02.0201",
"short_term_foreign_agency_or_subsidiary_interest_receivable_parent_code": "11.02.0201",
"short_term_non_domiciled_company_interest_receivable_parent_code": "11.02.0201",
"long_term_individual_interest_receivable_parent_code": "11.02.0201",
"long_term_government_entity_interest_receivable_parent_code": "11.02.0201",
"long_term_private_company_interest_receivable_parent_code": "11.02.0201",
"long_term_bank_interest_receivable_parent_code": "11.02.0201",
"long_term_financial_institution_interest_receivable_parent_code": "11.02.0201",
"long_term_foreign_agency_or_subsidiary_interest_receivable_parent_code": "11.02.0201",
"long_term_non_domiciled_company_interest_receivable_parent_code": "11.02.0201",
"short_term_individual_disbursed_receivable_parent_code": "11.02.0202",
"short_term_government_entity_disbursed_receivable_parent_code": "11.02.0202",
"short_term_private_company_disbursed_receivable_parent_code": "11.02.0202",
"short_term_bank_disbursed_receivable_parent_code": "11.02.0202",
"short_term_financial_institution_disbursed_receivable_parent_code": "11.02.0202",
"short_term_foreign_agency_or_subsidiary_disbursed_receivable_parent_code": "11.02.0202",
"short_term_non_domiciled_company_disbursed_receivable_parent_code": "11.02.0202",
"long_term_individual_disbursed_receivable_parent_code": "11.02.0202",
"long_term_government_entity_disbursed_receivable_parent_code": "11.02.0202",
"long_term_private_company_disbursed_receivable_parent_code": "11.02.0202",
"long_term_bank_disbursed_receivable_parent_code": "11.02.0202",
"long_term_financial_institution_disbursed_receivable_parent_code": "11.02.0202",
"long_term_foreign_agency_or_subsidiary_disbursed_receivable_parent_code": "11.02.0202",
"long_term_non_domiciled_company_disbursed_receivable_parent_code": "11.02.0202",
"overdue_individual_disbursed_receivable_parent_code": "11.02.0202",
"overdue_government_entity_disbursed_receivable_parent_code": "11.02.0202",
"overdue_private_company_disbursed_receivable_parent_code": "11.02.0202",
"overdue_bank_disbursed_receivable_parent_code": "11.02.0202",
"overdue_financial_institution_disbursed_receivable_parent_code": "11.02.0202",
"overdue_foreign_agency_or_subsidiary_disbursed_receivable_parent_code": "11.02.0202",
"overdue_non_domiciled_company_disbursed_receivable_parent_code": "11.02.0202"
}
9 changes: 9 additions & 0 deletions bats/accounting-init/deposit-module-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"omnibus_parent_code": "11.01.0101",
"individual_deposit_accounts_parent_code": "21.01.0101",
"government_entity_deposit_accounts_parent_code": "21.01.0101",
"private_company_deposit_accounts_parent_code": "21.01.0101",
"bank_deposit_accounts_parent_code": "21.01.0101",
"financial_institution_deposit_accounts_parent_code": "21.01.0101",
"non_domiciled_individual_deposit_accounts_parent_code": "21.01.0101"
}
12 changes: 12 additions & 0 deletions bats/accounting.bats
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ teardown_file() {
[[ "$assets_code" -eq "1" ]] || exit 1
}

@test "accounting: imported credit module config from seed into chart of accounts" {
exec_admin_graphql 'credit-config'
omnibus_code=$(graphql_output '.data.creditConfig.chartOfAccountFacilityOmnibusParentCode')
[[ "$omnibus_code" == "71.01" ]] || exit 1
}

@test "accounting: imported deposit module config from seed into chart of accounts" {
exec_admin_graphql 'deposit-config'
omnibus_code=$(graphql_output '.data.depositConfig.chartOfAccountsOmnibusParentCode')
[[ "$omnibus_code" == "11.01.0101" ]] || exit 1
}

@test "accounting: can import CSV file into chart of accounts" {
exec_admin_graphql 'chart-of-accounts'
chart_id=$(graphql_output '.data.chartOfAccounts.chartId')
Expand Down
45 changes: 45 additions & 0 deletions bats/admin-gql/credit-config.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
query creditConfig {
creditConfig {
chartOfAccountFacilityOmnibusParentCode
chartOfAccountCollateralOmnibusParentCode
chartOfAccountFacilityParentCode
chartOfAccountCollateralParentCode
chartOfAccountInterestIncomeParentCode
chartOfAccountFeeIncomeParentCode
chartOfAccountShortTermIndividualDisbursedReceivableParentCode
chartOfAccountShortTermGovernmentEntityDisbursedReceivableParentCode
chartOfAccountShortTermPrivateCompanyDisbursedReceivableParentCode
chartOfAccountShortTermBankDisbursedReceivableParentCode
chartOfAccountShortTermFinancialInstitutionDisbursedReceivableParentCode
chartOfAccountShortTermForeignAgencyOrSubsidiaryDisbursedReceivableParentCode
chartOfAccountShortTermNonDomiciledCompanyDisbursedReceivableParentCode
chartOfAccountLongTermIndividualDisbursedReceivableParentCode
chartOfAccountLongTermGovernmentEntityDisbursedReceivableParentCode
chartOfAccountLongTermPrivateCompanyDisbursedReceivableParentCode
chartOfAccountLongTermBankDisbursedReceivableParentCode
chartOfAccountLongTermFinancialInstitutionDisbursedReceivableParentCode
chartOfAccountLongTermForeignAgencyOrSubsidiaryDisbursedReceivableParentCode
chartOfAccountLongTermNonDomiciledCompanyDisbursedReceivableParentCode
chartOfAccountShortTermIndividualInterestReceivableParentCode
chartOfAccountShortTermGovernmentEntityInterestReceivableParentCode
chartOfAccountShortTermPrivateCompanyInterestReceivableParentCode
chartOfAccountShortTermBankInterestReceivableParentCode
chartOfAccountShortTermFinancialInstitutionInterestReceivableParentCode
chartOfAccountShortTermForeignAgencyOrSubsidiaryInterestReceivableParentCode
chartOfAccountShortTermNonDomiciledCompanyInterestReceivableParentCode
chartOfAccountLongTermIndividualInterestReceivableParentCode
chartOfAccountLongTermGovernmentEntityInterestReceivableParentCode
chartOfAccountLongTermPrivateCompanyInterestReceivableParentCode
chartOfAccountLongTermBankInterestReceivableParentCode
chartOfAccountLongTermFinancialInstitutionInterestReceivableParentCode
chartOfAccountLongTermForeignAgencyOrSubsidiaryInterestReceivableParentCode
chartOfAccountLongTermNonDomiciledCompanyInterestReceivableParentCode
chartOfAccountOverdueIndividualDisbursedReceivableParentCode
chartOfAccountOverdueGovernmentEntityDisbursedReceivableParentCode
chartOfAccountOverduePrivateCompanyDisbursedReceivableParentCode
chartOfAccountOverdueBankDisbursedReceivableParentCode
chartOfAccountOverdueFinancialInstitutionDisbursedReceivableParentCode
chartOfAccountOverdueForeignAgencyOrSubsidiaryDisbursedReceivableParentCode
chartOfAccountOverdueNonDomiciledCompanyDisbursedReceivableParentCode
}
}
11 changes: 11 additions & 0 deletions bats/admin-gql/deposit-config.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
query depositConfig {
depositConfig {
chartOfAccountsOmnibusParentCode
chartOfAccountsIndividualDepositAccountsParentCode
chartOfAccountsGovernmentEntityDepositAccountsParentCode
chartOfAccountPrivateCompanyDepositAccountsParentCode
chartOfAccountBankDepositAccountsParentCode
chartOfAccountFinancialInstitutionDepositAccountsParentCode
chartOfAccountNonDomiciledCompanyDepositAccountsParentCode
}
}
5 changes: 4 additions & 1 deletion bats/lana-sim-time.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ app:
customer_sync:
customer_status_sync_active: false
create_deposit_account_on_customer_create: true
chart_of_accounts_seed_path: "./bats/coa.csv"
accounting_init:
chart_of_accounts_seed_path: "./bats/accounting-init/coa.csv"
credit_config_path: "./bats/accounting-init/credit-module-config.json"
deposit_config_path: "./bats/accounting-init/deposit-module-config.json"
time:
realtime: false
sim_time:
Expand Down
2 changes: 1 addition & 1 deletion core/credit/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ impl Default for CreditConfig {
fn default() -> Self {
CreditConfig {
upgrade_buffer_cvl_pct: default_upgrade_buffer_cvl_pct(),
customer_active_check_enabled: true,
customer_active_check_enabled: default_customer_active_check_enabled(),
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion core/credit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ use job::Jobs;
use outbox::{Outbox, OutboxEventMarker};
use tracing::instrument;

pub use chart_of_accounts_integration::ChartOfAccountsIntegrationConfig;
pub use chart_of_accounts_integration::{
ChartOfAccountsIntegrationConfig, ChartOfAccountsIntegrationConfigBuilderError,
};
pub use collateral::*;
pub use config::*;
use credit_facility::error::CreditFacilityError;
Expand Down
4 changes: 3 additions & 1 deletion core/deposit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ use outbox::{Outbox, OutboxEventMarker};

pub use account::DepositAccount;
use account::*;
pub use chart_of_accounts_integration::ChartOfAccountsIntegrationConfig;
pub use chart_of_accounts_integration::{
ChartOfAccountsIntegrationConfig, ChartOfAccountsIntegrationConfigBuilderError,
};
use deposit::*;
pub use deposit::{Deposit, DepositsByCreatedAtCursor};
pub use deposit_account_balance::DepositAccountBalance;
Expand Down
16 changes: 16 additions & 0 deletions lana/app/src/accounting_init/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,24 @@ use thiserror::Error;
pub enum AccountingInitError {
#[error("AccountingInitError - Sqlx: {0}")]
Sqlx(#[from] sqlx::Error),
#[error("AccountingInitError - JsonSerde: {0}")]
JsonSerde(#[from] serde_json::Error),
#[error("AccountingInitError - AccountCodeParseError: {0}")]
AccountCodeParseError(#[from] core_accounting::AccountCodeParseError),
#[error("AccountingInitError - ChartOfAccountsError: {0}")]
ChartOfAccountsError(#[from] core_accounting::chart_of_accounts::error::ChartOfAccountsError),
#[error("AccountingInitError - CoreCreditError: {0}")]
CoreCreditError(#[from] core_credit::error::CoreCreditError),
#[error("AccountingInitError - CoreDepositError: {0}")]
CoreDepositError(#[from] deposit::error::CoreDepositError),
#[error("AccountingInitError - CreditChartIntegrationConfigBuilderError: {0}")]
CreditChartIntegrationConfigBuilderError(
#[from] core_credit::ChartOfAccountsIntegrationConfigBuilderError,
),
#[error("AccountingInitError - DepositChartIntegrationConfigBuilderError: {0}")]
DepositChartIntegrationConfigBuilderError(
#[from] deposit::ChartOfAccountsIntegrationConfigBuilderError,
),
#[error("AccountingInitError - LedgerError: {0}")]
LedgerError(#[from] cala_ledger::error::LedgerError),
#[error("AccountingInitError - JournalError: {0}")]
Expand Down
18 changes: 13 additions & 5 deletions lana/app/src/accounting_init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ mod seed;

pub mod error;

use std::path::PathBuf;

use crate::{
accounting::ChartOfAccounts, balance_sheet::BalanceSheets, primitives::CalaJournalId,
accounting::ChartOfAccounts, app::AccountingInitConfig, balance_sheet::BalanceSheets,
credit::Credit, deposit::Deposits, primitives::CalaJournalId,
profit_and_loss::ProfitAndLossStatements, trial_balance::TrialBalances,
};

Expand Down Expand Up @@ -45,8 +44,17 @@ impl ChartsInit {
pub async fn charts_of_accounts(
chart_of_accounts: &ChartOfAccounts,
trial_balances: &TrialBalances,
seed_path: Option<PathBuf>,
credit: &Credit,
deposit: &Deposits,
accounting_init_config: AccountingInitConfig,
) -> Result<(), AccountingInitError> {
seed::charts_of_accounts::init(chart_of_accounts, trial_balances, seed_path).await
seed::charts_of_accounts::init(
chart_of_accounts,
trial_balances,
credit,
deposit,
accounting_init_config,
)
.await
}
}
Loading
Loading