cash flow: financing and investing gross; account roles are a setting
check / check (push) Canceled after 0s

From ASC 230 (via Deloitte DART and PwC Viewpoint), replacing two
formerly assumed behaviors:

- Financing and investing are gross (230-10-45-7): per account, cash in
  and cash out are separate lines (contributions apart from
  distributions, borrowing apart from repayment), netted only within
  one entry. Lines come in code order, in before out.
- Investing includes making and collecting loans and buying investments
  (230-10-20, 45-13), not only registered fixed assets:
  CashFlowParams gains investing_accounts.
- The roles are per-company settings: [books] financing_accounts and
  investing_accounts in wanderbooks.toml (beside cash_accounts). The MCP
  tools (cash_flow, export, CPA package) default every list to them and
  share one path; the viewer reads them too, falling back to its name
  guess for debt. A due-to-owners liability listed as financing gives
  PwC 6.9.3.1's constructive treatment of expenses an owner paid.

rules.md B-14 quotes the sources; new tests cite them; docs/testing.md
#8 is resolved.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GWVo7x3UHw5kwCUaWxiejX
This commit is contained in:
swaitsandClaude Opus 5.5 committed 2026-10-13 18:36:21 -06:00
1 parent 08d1a9c230
commit 819cd09e0d
13 files changed
+521 -126

No files matched your search

+13
View File
@@ -77,6 +77,10 @@ pub struct Books {
pub entries: Vec<EntryInfo>,
pub entry_index: HashMap<EntryId, usize>,
pub cash_accounts: Vec<AccountId>,
/// `[books] financing_accounts`, resolved (empty when not set).
pub financing_accounts: Vec<AccountId>,
/// `[books] investing_accounts`, resolved (empty when not set).
pub investing_accounts: Vec<AccountId>,
pub card_accounts: Vec<AccountId>,
/// Entries created or changed by the most recent refresh.
pub fresh: HashSet<EntryId>,
@@ -164,6 +168,13 @@ impl Books {
.and_then(|t| t.parse().ok())
.unwrap_or(Decimal::new(25, 0));
let cash_accounts = cash_accounts(&ledger, &settings);
let codes = |cs: &[String]| -> Vec<AccountId> {
cs.iter()
.filter_map(|c| ledger.chart().find_by_code(c).map(|a| a.id))
.collect()
};
let financing_accounts = codes(&settings.financing_accounts);
let investing_accounts = codes(&settings.investing_accounts);
let card_accounts: Vec<AccountId> = ledger
.chart()
.all()
@@ -303,6 +314,8 @@ impl Books {
entries,
entry_index,
cash_accounts,
financing_accounts,
investing_accounts,
card_accounts,
fresh,
fresh_from_seq,
+6
View File
@@ -554,7 +554,12 @@ fn balance_sheet(b: &Books, dates: &[(NaiveDate, String)]) -> Table {
t
}
/// Financing accounts: from `[books] financing_accounts`, else liabilities
/// whose names say they are debt.
fn financing_accounts(b: &Books) -> Vec<AccountId> {
if !b.financing_accounts.is_empty() {
return b.financing_accounts.clone();
}
b.ledger
.chart()
.all()
@@ -585,6 +590,7 @@ fn cash_flow_table(b: &Books, cols: &Cols, total: bool) -> Table {
end: *e,
cash_accounts: b.cash_accounts.clone(),
financing_accounts: fin.clone(),
investing_accounts: b.investing_accounts.clone(),
},
)
.ok()