diff --git a/crates/ledger-store/src/reconcilable.rs b/crates/ledger-store/src/reconcilable.rs index e05fcf95..d67d1abf 100644 --- a/crates/ledger-store/src/reconcilable.rs +++ b/crates/ledger-store/src/reconcilable.rs @@ -45,7 +45,8 @@ pub fn cash_accounts(ledger: &Ledger, configured: &[String]) -> Vec { .filter_map(|c| ledger.chart().find_by_code(c).map(|a| a.id)) .collect(); } - ledger + // In chart order, as `card_accounts` is: the chart iterates in no order. + let mut found: Vec = ledger .chart() .all() .filter(|a| { @@ -55,7 +56,9 @@ pub fn cash_accounts(ledger: &Ledger, configured: &[String]) -> Vec { && CASH_WORDS.iter().any(|w| n.contains(w)) }) .map(|a| a.id) - .collect() + .collect(); + found.sort_unstable(); + found } /// The card accounts (`ledger_core::parties::card_accounts`: the diff --git a/crates/ledger-store/tests/reconcilable.rs b/crates/ledger-store/tests/reconcilable.rs index acee8330..92690af6 100644 --- a/crates/ledger-store/tests/reconcilable.rs +++ b/crates/ledger-store/tests/reconcilable.rs @@ -188,7 +188,7 @@ fn cash_accounts_are_the_assets_whose_names_say_cash() { ); } -/// FINDING (V-D2): the cash accounts found by name come out in the order +/// FINDING (V-D2; fixed by the commit that removed this test's ignore): the cash accounts found by name came out in the order /// the chart's `HashMap` yields them (`ChartOfAccounts::all` says "order /// unspecified"), not in chart order as `card_accounts` does (ascending /// account id). `books.digest`'s `unreconciled_accounts` lists accounts in @@ -198,7 +198,6 @@ fn cash_accounts_are_the_assets_whose_names_say_cash() { /// rule rather than a broken one; the expectation here is the order /// `card_accounts` already keeps. #[test] -#[ignore = "finding: cash_accounts yields name-matched accounts in HashMap order, so books.digest's unreconciled_accounts order is not stable; expected ascending account id as card_accounts keeps"] fn cash_accounts_come_in_chart_order() { let dir = test_dir("cash-order"); let mut s = Store::create(&dir, Currency::USD).unwrap();