fix(store): cash accounts found by name come in chart order
FINDING from V-D2's reconcilable tests: cash_accounts returned the asset accounts whose names say cash in the order ChartOfAccounts::all yields them (a HashMap: "order unspecified"), so books.digest's unreconciled_accounts could list the same books' accounts in a different order from one run to the next. card_accounts, the rule beside it, already sorts by account id. The name-matched path now sorts the same way; configured codes keep the order they were configured in. No figure, membership or due date changes, only the order of the list. The earlier ignored test (cash_accounts_come_in_chart_order) now runs. This is a small fix kept in its own commit so it can be dropped without touching the tests. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7a1d4a51a8
commit
11314db1f7
2 files changed
+6
-4
No files matched your search
@@ -45,7 +45,8 @@ pub fn cash_accounts(ledger: &Ledger, configured: &[String]) -> Vec<AccountId> {
|
||||
.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<AccountId> = ledger
|
||||
.chart()
|
||||
.all()
|
||||
.filter(|a| {
|
||||
@@ -55,7 +56,9 @@ pub fn cash_accounts(ledger: &Ledger, configured: &[String]) -> Vec<AccountId> {
|
||||
&& 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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in new issue
Block a user