use datasynth_core::accounts::{
cash_accounts, control_accounts, equity_accounts, expense_accounts, intangible_accounts,
liability_accounts, manufacturing_accounts, revenue_accounts, tax_accounts, treasury_accounts,
};
use datasynth_group::{classify_account, TranslationAccountType};
use datasynth_standards::framework::AccountingFramework;
fn classify(code: &str) -> TranslationAccountType {
classify_account(code, AccountingFramework::default())
}
#[test]
fn cash_accounts_are_bs_monetary() {
assert_eq!(
classify(cash_accounts::OPERATING_CASH),
TranslationAccountType::BsMonetary,
"OPERATING_CASH (1000) must be BsMonetary",
);
assert_eq!(
classify(cash_accounts::BANK_ACCOUNT),
TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(cash_accounts::PETTY_CASH),
TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(cash_accounts::WIRE_CLEARING),
TranslationAccountType::BsMonetary,
);
}
#[test]
fn ar_and_ic_ar_are_bs_monetary() {
assert_eq!(
classify(control_accounts::AR_CONTROL), TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(control_accounts::IC_AR_CLEARING), TranslationAccountType::BsMonetary,
);
}
#[test]
fn inventory_is_bs_non_monetary() {
assert_eq!(
classify(control_accounts::INVENTORY), TranslationAccountType::BsNonMonetary,
);
assert_eq!(
classify(manufacturing_accounts::WIP), TranslationAccountType::BsNonMonetary,
"WIP must override the 1400-range BsMonetary default",
);
assert_eq!(
classify(manufacturing_accounts::FINISHED_GOODS), TranslationAccountType::BsNonMonetary,
);
}
#[test]
fn fixed_assets_are_bs_non_monetary() {
assert_eq!(
classify(control_accounts::FIXED_ASSETS), TranslationAccountType::BsNonMonetary,
);
assert_eq!(
classify(control_accounts::ACCUMULATED_DEPRECIATION), TranslationAccountType::BsNonMonetary,
);
}
#[test]
fn intangibles_and_goodwill_are_bs_non_monetary() {
assert_eq!(
classify(intangible_accounts::GOODWILL), TranslationAccountType::BsNonMonetary,
);
assert_eq!(
classify(intangible_accounts::CUSTOMER_RELATIONSHIPS), TranslationAccountType::BsNonMonetary,
);
assert_eq!(
classify(intangible_accounts::TRADE_NAME), TranslationAccountType::BsNonMonetary,
);
assert_eq!(
classify(intangible_accounts::ACCUMULATED_AMORTIZATION), TranslationAccountType::BsNonMonetary,
);
}
#[test]
fn ap_and_ic_ap_are_bs_monetary() {
assert_eq!(
classify(control_accounts::AP_CONTROL), TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(control_accounts::IC_AP_CLEARING), TranslationAccountType::BsMonetary,
);
}
#[test]
fn debt_and_accrued_liabilities_are_bs_monetary() {
assert_eq!(
classify(liability_accounts::SHORT_TERM_DEBT), TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(liability_accounts::LONG_TERM_DEBT), TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(liability_accounts::ACCRUED_EXPENSES), TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(treasury_accounts::INTEREST_PAYABLE), TranslationAccountType::BsMonetary,
);
}
#[test]
fn equity_accounts_classify_as_equity() {
assert_eq!(
classify(equity_accounts::COMMON_STOCK), TranslationAccountType::Equity,
);
assert_eq!(
classify(equity_accounts::APIC), TranslationAccountType::Equity,
);
assert_eq!(
classify(equity_accounts::RETAINED_EARNINGS), TranslationAccountType::Equity,
);
assert_eq!(
classify(equity_accounts::CTA), TranslationAccountType::Equity,
);
}
#[test]
fn revenue_accounts_classify_as_pl_revenue() {
assert_eq!(
classify(revenue_accounts::PRODUCT_REVENUE), TranslationAccountType::PlRevenue,
);
assert_eq!(
classify(revenue_accounts::IC_REVENUE), TranslationAccountType::PlRevenue,
);
}
#[test]
fn cogs_and_expenses_classify_as_pl_expense() {
assert_eq!(
classify(expense_accounts::COGS), TranslationAccountType::PlExpense,
);
assert_eq!(
classify(expense_accounts::SALARIES_WAGES), TranslationAccountType::PlExpense,
);
assert_eq!(
classify(expense_accounts::INTEREST_EXPENSE), TranslationAccountType::PlExpense,
);
assert_eq!(
classify(expense_accounts::DEPRECIATION), TranslationAccountType::PlExpense,
);
}
#[test]
fn tax_accounts_classify_correctly() {
assert_eq!(
classify(tax_accounts::INPUT_VAT), TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(tax_accounts::DEFERRED_TAX_ASSET), TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(tax_accounts::INCOME_TAX_PAYABLE), TranslationAccountType::BsMonetary,
);
assert_eq!(
classify(tax_accounts::DEFERRED_TAX_LIABILITY), TranslationAccountType::BsMonetary,
);
}
#[test]
fn unknown_1xxx_code_falls_back_by_range() {
assert_eq!(classify("1099"), TranslationAccountType::BsMonetary);
assert_eq!(classify("1250"), TranslationAccountType::BsNonMonetary);
assert_eq!(classify("1350"), TranslationAccountType::BsNonMonetary);
assert_eq!(classify("1700"), TranslationAccountType::BsNonMonetary);
assert_eq!(classify("1990"), TranslationAccountType::BsNonMonetary);
}
#[test]
fn unknown_2xxx_through_8xxx_codes_fall_back_by_range() {
assert_eq!(classify("2999"), TranslationAccountType::BsMonetary);
assert_eq!(classify("3999"), TranslationAccountType::Equity);
assert_eq!(classify("4999"), TranslationAccountType::PlRevenue);
assert_eq!(classify("5999"), TranslationAccountType::PlExpense);
assert_eq!(classify("6999"), TranslationAccountType::PlExpense);
assert_eq!(classify("7999"), TranslationAccountType::PlExpense);
assert_eq!(classify("8999"), TranslationAccountType::PlOci);
assert_eq!(classify("9000"), TranslationAccountType::BsMonetary);
}
#[test]
fn empty_code_falls_back_to_bs_monetary() {
assert_eq!(classify(""), TranslationAccountType::BsMonetary);
}
#[test]
fn malformed_code_falls_back_to_bs_monetary() {
assert_eq!(classify("ABC"), TranslationAccountType::BsMonetary);
assert_eq!(classify("X1100"), TranslationAccountType::BsMonetary);
}
#[test]
fn classification_is_deterministic_across_calls() {
let a1 = classify(control_accounts::AR_CONTROL);
let a2 = classify(control_accounts::AR_CONTROL);
assert_eq!(a1, a2);
let i1 = classify(control_accounts::INVENTORY);
let i2 = classify(control_accounts::INVENTORY);
assert_eq!(i1, i2);
}
#[test]
fn framework_does_not_change_classification_in_v5_0() {
let ar = control_accounts::AR_CONTROL;
assert_eq!(
classify_account(ar, AccountingFramework::UsGaap),
classify_account(ar, AccountingFramework::Ifrs),
);
assert_eq!(
classify_account(ar, AccountingFramework::FrenchGaap),
classify_account(ar, AccountingFramework::GermanGaap),
);
assert_eq!(
classify_account(ar, AccountingFramework::UsGaap),
classify_account(ar, AccountingFramework::DualReporting),
);
}