refactor: rule references cite bookspec ids
Every B-n citation in crates/, docs/, deploy/, scripts/ and .github/ now names its bookspec id BS-<area>-<n> (D-68), via scripts/rewrite-rule-refs.py: the map is parsed from docs/spec/rules.md's index, rules.md-prefixed and bare forms are rewritten, sub-references (rule 11, item 7, INVARIANT 2) survive, and plan/, docs/spec/rules.md and docs/spec/claims/ are untouched. Program-output string literals that cited a rule were reverted by hand so user-visible output and its goldens are unchanged; DatedRule.catalog, metadata no output prints, now holds BS-1099-1. One SOURCE line that cited only 'R-?' now also cites BS-statement-5. Co-Authored-By: Muse Wonder 1.0
This commit is contained in:
1 parent
7a177a3cfc
commit
489360f598
221 files changed
+1706
-1580
No files matched your search
@@ -585,7 +585,7 @@ impl BooksServer {
|
||||
};
|
||||
// One registration is several commands: rehearse them all on a
|
||||
// copy first, and ask for the journal feature the basis needs
|
||||
// (B-27), so a refusal anywhere (the tag, the serial, the link, the
|
||||
// (BS-format-1), so a refusal anywhere (the tag, the serial, the link, the
|
||||
// basis, books waiting for their format upgrade) journals nothing.
|
||||
{
|
||||
let mut copy = store.ledger().clone();
|
||||
@@ -742,7 +742,7 @@ impl BooksServer {
|
||||
cost: money(a.cost.amount),
|
||||
useful_life_months: a.useful_life_months,
|
||||
// As of as_of, like every figure here: a disposal
|
||||
// after it hasn't happened yet (rules.md B-33).
|
||||
// after it hasn't happened yet (BS-statement-4).
|
||||
status: if disposed { "disposed" } else { "active" }.to_string(),
|
||||
held: acquired <= as_of && !disposed,
|
||||
accumulated_posted: figure(|r| r.accumulated_posted),
|
||||
|
||||
@@ -62,7 +62,7 @@ fn check_link_to(
|
||||
let sub = resolve_subject(store, s)?;
|
||||
// A link to a subject kind an older version doesn't know needs its
|
||||
// journal feature, asked here, before the file is filed: a refusal
|
||||
// leaves nothing half-filed (rules.md B-27).
|
||||
// leaves nothing half-filed (BS-format-1).
|
||||
if let Some(f) = Store::subject_feature(sub) {
|
||||
store.ensure_feature(f).map_err(|e| e.to_string())?;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! The audit group (plan P8; rules.md B-45): an audit run over the books,
|
||||
//! The audit group (plan P8; BS-ledger-13): an audit run over the books,
|
||||
//! its workpaper, and the claims that someone checked.
|
||||
//!
|
||||
//! ```text
|
||||
@@ -6,7 +6,7 @@
|
||||
//! that gives the same findings and the same workpaper for the same
|
||||
//! books, and attestations that rest on a head that has not moved.
|
||||
//! SOURCE: IRS Pub. 583 (records); Rev. Proc. 98-25 §5.01 (the audit
|
||||
//! trail); docs/spec/rules.md B-45; DECISION D-9 (the bar), D-53
|
||||
//! trail); BS-ledger-13; DECISION D-9 (the bar), D-53
|
||||
//! (an audit is a run, not a job), IZ-1k (the head).
|
||||
//! INVARIANTS:
|
||||
//! 1. `books.audit` previews (what it will check; nothing changes),
|
||||
@@ -356,7 +356,7 @@ impl BooksServer {
|
||||
/// ```text
|
||||
/// GOAL: the whole programme of checks over the books through a day,
|
||||
/// its workpaper filed, the run journaled.
|
||||
/// SOURCE: plan/served.md P8; B-45; D-9, D-53.
|
||||
/// SOURCE: plan/served.md P8; BS-ledger-13; D-9, D-53.
|
||||
/// INVARIANTS:
|
||||
/// 1. Without `confirmed`, a preview that lists the checks and
|
||||
/// changes nothing; with it, the preview's digest is required.
|
||||
@@ -529,7 +529,7 @@ impl BooksServer {
|
||||
|
||||
/// ```text
|
||||
/// GOAL: an audit run's workpaper, whole.
|
||||
/// SOURCE: plan/served.md P8 step 3; B-45.
|
||||
/// SOURCE: plan/served.md P8 step 3; BS-ledger-13.
|
||||
/// INVARIANTS:
|
||||
/// 1. Read-only; the JSON is the one filed, the PDF is handed over.
|
||||
/// ```
|
||||
@@ -581,7 +581,7 @@ impl BooksServer {
|
||||
|
||||
/// ```text
|
||||
/// GOAL: a checker's claim that a receipt supports an entry.
|
||||
/// SOURCE: plan/served.md P8 step 4; B-45; D-9.
|
||||
/// SOURCE: plan/served.md P8 step 4; BS-ledger-13; D-9.
|
||||
/// INVARIANTS:
|
||||
/// 1. The reading is compared with the entry's amount and date; a
|
||||
/// difference is recorded, marked, and never counts.
|
||||
@@ -619,7 +619,7 @@ impl BooksServer {
|
||||
|
||||
/// ```text
|
||||
/// GOAL: a checker's claim that it reviewed an entry whole.
|
||||
/// SOURCE: plan/served.md P8 step 4; B-45.
|
||||
/// SOURCE: plan/served.md P8 step 4; BS-ledger-13.
|
||||
/// ```
|
||||
#[tool(
|
||||
name = "books.review_entry",
|
||||
@@ -649,7 +649,7 @@ impl BooksServer {
|
||||
/// ```text
|
||||
/// GOAL: a checker's claim that a period is right, resting on an
|
||||
/// audit run at the books' current head.
|
||||
/// SOURCE: plan/served.md P8 step 4; B-45; D-9; IZ-1k.
|
||||
/// SOURCE: plan/served.md P8 step 4; BS-ledger-13; D-9; IZ-1k.
|
||||
/// INVARIANTS:
|
||||
/// 1. Refused unless an audit through the period's end stands at
|
||||
/// the current head.
|
||||
@@ -697,7 +697,7 @@ impl BooksServer {
|
||||
|
||||
/// ```text
|
||||
/// GOAL: every claim that someone checked, and whether it counts.
|
||||
/// SOURCE: plan/served.md P8 step 4; B-45; D-9.
|
||||
/// SOURCE: plan/served.md P8 step 4; BS-ledger-13; D-9.
|
||||
/// INVARIANTS:
|
||||
/// 1. `counted` is read against the bar as it stands now.
|
||||
/// ```
|
||||
|
||||
@@ -241,8 +241,8 @@ impl BooksServer {
|
||||
let mut store = self.lock()?;
|
||||
let id = resolve_account(&store, &p.account)?;
|
||||
let reason = p.reason.as_deref().map(str::trim).filter(|r| !r.is_empty());
|
||||
// The sets the books pick by name, before and after (rules.md
|
||||
// B-31: a rename moves no amount, but it can move an account into
|
||||
// The sets the books pick by name, before and after (
|
||||
// BS-ledger-10: a rename moves no amount, but it can move an account into
|
||||
// or out of one of these).
|
||||
let configured_cash = self.settings().roles.cash.clone();
|
||||
let picked = |ledger: &Ledger| {
|
||||
|
||||
@@ -78,7 +78,7 @@ fn document_lines(
|
||||
/// A document's notes, each project once, in the order first named: its
|
||||
/// late-tag note ([`projects::late_tag_note`]) for a finished or abandoned
|
||||
/// project, and on an invoice ([`projects::on_spec_invoice_note`]) one for
|
||||
/// an on-spec project (rules.md B-37 items 4, 5 and 8).
|
||||
/// an on-spec project (BS-statement-5 items 4, 5 and 8).
|
||||
fn document_notes(
|
||||
ledger: &ledger_core::Ledger,
|
||||
lines: &[DocumentLine],
|
||||
@@ -157,7 +157,7 @@ fn resolve_vendor_arg(store: &Store, vendor: &str) -> Result<u64, String> {
|
||||
|
||||
/// Whether these books declared the journal feature `documents_v2`: the
|
||||
/// bills and invoices carrying a number, terms, snapshots, references, a
|
||||
/// line's account or a quantity need it (rules.md B-27, D-52), and the
|
||||
/// line's account or a quantity need it (BS-format-1, D-52), and the
|
||||
/// bill rules A-10, A-13 and the file apply only where it is declared.
|
||||
fn documents_v2(store: &Store) -> bool {
|
||||
store
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! The drafts group (plan P4; rules.md B-43): which drafts are open and
|
||||
//! The drafts group (plan P4; BS-entry-5): which drafts are open and
|
||||
//! what they wait for, a draft's state, throwing one away, and the full
|
||||
//! preview of the post. Also what every report says is still open as of
|
||||
//! its end (`as_of_status`) and the open-draft refusal of the CPA package.
|
||||
@@ -7,7 +7,7 @@
|
||||
//! GOAL: a draft is never lost and never mistaken for a posted entry; a
|
||||
//! report or a package says when drafts dated in it are missing
|
||||
//! from its figures.
|
||||
//! SOURCE: docs/spec/rules.md B-43; plan/served.md 4.8, D-47.
|
||||
//! SOURCE: BS-entry-5; plan/served.md 4.8, D-47.
|
||||
//! INVARIANTS:
|
||||
//! 1. A state is a note on the draft: no figure moves.
|
||||
//! 2. A discard is previewed, then confirmed with the preview's digest;
|
||||
|
||||
@@ -234,7 +234,7 @@ impl BooksServer {
|
||||
// A payment method exists only in books that declare the
|
||||
// payment_instruments feature (books.add_instrument needs it), so
|
||||
// tagging the draft with one below can't be refused for the format
|
||||
// after the draft's first line (B-27).
|
||||
// after the draft's first line (BS-format-1).
|
||||
let id = store
|
||||
.create_entry(date, &p.description)
|
||||
.map_err(|e| e.to_string())?;
|
||||
@@ -595,7 +595,7 @@ impl BooksServer {
|
||||
.iter()
|
||||
.map(|l| {
|
||||
// A draft line an earlier version journaled may name an
|
||||
// account the chart doesn't have (rules.md B-28).
|
||||
// account the chart doesn't have (BS-entry-4).
|
||||
let (code, name) = match store.ledger().chart().get(l.account) {
|
||||
Some(a) => (a.code.clone(), a.name.clone()),
|
||||
None => (String::new(), format!("(no account {})", l.account)),
|
||||
@@ -851,7 +851,7 @@ mod tests {
|
||||
|
||||
/// lines_settled: posted, or a draft with lines whose debits equal its
|
||||
/// credits; a draft whose sides are past exact arithmetic (one an
|
||||
/// earlier version journaled, rules.md B-28) is not settled.
|
||||
/// earlier version journaled, BS-entry-4) is not settled.
|
||||
#[test]
|
||||
fn settled_lines_are_posted_or_balanced_drafts() {
|
||||
let mut l = Ledger::new(Currency::USD);
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//! wherever they are evidence.
|
||||
//! SOURCE: plan/served.md P6 step 4 (defect 4) and step 5 (defect 10);
|
||||
//! IZ-18 (no FIFO guess: `entry.settles` only); Rev. Proc. 98-25
|
||||
//! (an audit trail); rules.md B-44.
|
||||
//! (an audit trail); BS-ledger-12.
|
||||
//! ```
|
||||
|
||||
use super::*;
|
||||
@@ -23,7 +23,7 @@ impl BooksServer {
|
||||
/// ```text
|
||||
/// GOAL: find a filed file by its exact bytes, its receipt number, or
|
||||
/// what its text says.
|
||||
/// SOURCE: plan/served.md P6 step 4; B-44.
|
||||
/// SOURCE: plan/served.md P6 step 4; BS-ledger-12.
|
||||
/// INVARIANTS:
|
||||
/// 1. EXACTLY one of sha256, receipt_number and text is given.
|
||||
/// 2. Withdrawn files are listed too, marked (a duplicate is found
|
||||
@@ -96,7 +96,7 @@ impl BooksServer {
|
||||
/// ```text
|
||||
/// GOAL: record what a human read off a file, without touching the file
|
||||
/// or the ledger's amounts.
|
||||
/// SOURCE: plan/served.md P6 step 5 (defect 10); B-44.
|
||||
/// SOURCE: plan/served.md P6 step 5 (defect 10); BS-ledger-12.
|
||||
/// INVARIANTS:
|
||||
/// 1. Journaled as `attachment.annotated`; a refusal journals nothing.
|
||||
/// 2. The fields are the closed list of `AnnotationFieldsParam`; at
|
||||
@@ -206,7 +206,7 @@ impl BooksServer {
|
||||
/// GOAL: hold identical files once, linked wherever they were evidence,
|
||||
/// without ever leaving an entry the receipt policy covers with
|
||||
/// none.
|
||||
/// SOURCE: plan/served.md P6 step 4 (defect 4); rules.md B-44.
|
||||
/// SOURCE: plan/served.md P6 step 4 (defect 4); BS-ledger-12.
|
||||
/// INVARIANTS:
|
||||
/// 1. Records sharing one blob SHA are one set; the oldest is kept
|
||||
/// and linked to every subject the others had.
|
||||
|
||||
@@ -57,7 +57,7 @@ pub(crate) fn receipt_required_text(e: StoreError, policy: &ReceiptPolicy) -> St
|
||||
split_group
|
||||
)
|
||||
};
|
||||
// A draft's debits may be past exact arithmetic (rules.md B-28): then
|
||||
// A draft's debits may be past exact arithmetic (BS-entry-4): then
|
||||
// the refusal says so in place of the sum.
|
||||
let (total, debits) = match debits {
|
||||
Some(t) => (money(t), t.to_string()),
|
||||
@@ -140,7 +140,7 @@ pub(crate) fn settings_problems(ledger: &Ledger, cfg: &Settings) -> Vec<String>
|
||||
// Named as the books keep them.
|
||||
let how = " with books.set_setting";
|
||||
// The cash flow roles: codes the chart lacks here; the rest is the
|
||||
// engine's own check, the one the statement refuses on (rules.md B-14
|
||||
// engine's own check, the one the statement refuses on (BS-statement-3
|
||||
// rule 2), so the two never disagree.
|
||||
let lists = [
|
||||
(
|
||||
@@ -455,7 +455,7 @@ pub(crate) fn optional_text(s: &str) -> Option<String> {
|
||||
|
||||
/// The sum of `values`, each computed or refused: refused (as text) when
|
||||
/// one is, or when the sum is past exact arithmetic. Figures an earlier
|
||||
/// version journaled are as journaled (rules.md B-28).
|
||||
/// version journaled are as journaled (BS-entry-4).
|
||||
pub(crate) fn checked_sum(
|
||||
values: impl IntoIterator<Item = Result<Decimal, ledger_core::LedgerError>>,
|
||||
what: &str,
|
||||
@@ -541,7 +541,7 @@ pub(crate) fn lines_settled(entry: &JournalEntry) -> bool {
|
||||
if entry.status() == ledger_core::EntryStatus::Posted {
|
||||
return true;
|
||||
}
|
||||
// A draft's lines are as journaled, of any size (rules.md B-28): sides
|
||||
// A draft's lines are as journaled, of any size (BS-entry-4): sides
|
||||
// past exact arithmetic are not settled lines.
|
||||
let side = |s: Side| -> Option<Decimal> {
|
||||
entry
|
||||
@@ -644,13 +644,13 @@ pub(crate) fn resolve_class(store: &Store, class: &str) -> Result<u32, String> {
|
||||
}
|
||||
|
||||
/// A tool description that ends with the one sentence for its kind of
|
||||
/// dates (rules.md B-30), so no tool says other than the resolver does.
|
||||
/// dates (BS-period-3), so no tool says other than the resolver does.
|
||||
pub(crate) fn described(what: &str, kind: ledger_core::calendar::PeriodKind) -> String {
|
||||
format!("{what} {}", kind.describe())
|
||||
}
|
||||
|
||||
/// The warning for a revenue or expense account created without a tax
|
||||
/// category (rules.md B-32).
|
||||
/// category (BS-ledger-11).
|
||||
pub(crate) fn uncategorized_warning(code: &str, name: &str) -> String {
|
||||
format!(
|
||||
"{} {} has no tax category: the tax summary will list it as uncategorized. Propose one from books.tax_categories and set it with books.set_tax_category once the human agrees.",
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
//! ```text
|
||||
//! GOAL: the agent records how each payment was made and why each vendor
|
||||
//! does or doesn't get a 1099, and the worksheet never guesses.
|
||||
//! SOURCE: docs/spec/rules.md B-19 (Treas. Reg. §1.6041-1(a)(1)(iv),
|
||||
//! SOURCE: BS-1099-1 (Treas. Reg. §1.6041-1(a)(1)(iv),
|
||||
//! §1.6041-3; sources/irs-1099-payment-method.md); plan/served.md
|
||||
//! 4.9; DECISION D-40 (owner, 2026-10-20).
|
||||
//! INVARIANTS:
|
||||
|
||||
@@ -924,7 +924,7 @@ impl BooksServer {
|
||||
due: i.new.due.map(|d| d.to_string()),
|
||||
})
|
||||
.collect();
|
||||
// The projects under way, by name (rules.md B-37): at most 20.
|
||||
// The projects under way, by name (BS-statement-5): at most 20.
|
||||
const START_PROJECTS: usize = 20;
|
||||
let mut projects: Vec<ProjectBriefOut> = ledger
|
||||
.list_classes()
|
||||
|
||||
@@ -144,7 +144,7 @@ fn party_document(
|
||||
}
|
||||
|
||||
/// A party-totals `basis` from a tool: "cash" (the default) or "all"
|
||||
/// (rules.md B-35 item 4); any other word is refused.
|
||||
/// (BS-partner-3 item 4); any other word is refused.
|
||||
fn parse_basis(basis: Option<&str>) -> Result<ledger_core::parties::Basis, String> {
|
||||
match basis {
|
||||
None => Ok(ledger_core::parties::Basis::default()),
|
||||
@@ -589,7 +589,7 @@ impl BooksServer {
|
||||
fields.push(F::Email(optional_text(&v)));
|
||||
}
|
||||
// "" clears the terms; any other text is trade terms this party
|
||||
// grants or is granted (B-39).
|
||||
// grants or is granted (BS-arap-3).
|
||||
let terms = |v: String| -> Result<Option<ledger_core::Terms>, String> {
|
||||
if v.trim().is_empty() {
|
||||
return Ok(None);
|
||||
@@ -653,7 +653,7 @@ impl BooksServer {
|
||||
.map_err(|e| e.to_string())?;
|
||||
}
|
||||
// The journal features these lines need, asked for before this
|
||||
// command's first line, never between its lines (rules.md B-27:
|
||||
// command's first line, never between its lines (BS-format-1:
|
||||
// books waiting for their format upgrade must not be left with the
|
||||
// name changed and the rest not).
|
||||
if fields.iter().any(|f| f.needs_documents_v2()) {
|
||||
@@ -749,7 +749,7 @@ impl BooksServer {
|
||||
/// GOAL: the books know a W-9 arrived and what it said, and the full
|
||||
/// TIN (and the form, which shows it) is kept where it can be
|
||||
/// handed to the CPA and purged, never in the journal.
|
||||
/// SOURCE: docs/parties-and-attachments.md "The TIN vault"; B-26;
|
||||
/// SOURCE: docs/parties-and-attachments.md "The TIN vault"; BS-partner-2;
|
||||
/// Treas. Reg. §301.6109-4 (truncated TINs); DECISION (owner,
|
||||
/// 2026-10-15): full TINs only in the encrypted vault.
|
||||
/// INVARIANTS:
|
||||
@@ -852,7 +852,7 @@ impl BooksServer {
|
||||
let existing = store.ledger().get_party(id).and_then(|p| p.w9.clone());
|
||||
let party_tin = store.ledger().get_party(id).and_then(|p| p.tin.clone());
|
||||
// A new TIN with another last four replaces the party's TIN facts:
|
||||
// cleared first, so the two never disagree on the record (B-26).
|
||||
// cleared first, so the two never disagree on the record (BS-partner-2).
|
||||
let replace_tin = tin
|
||||
.as_ref()
|
||||
.is_some_and(|t| party_tin.as_ref().is_some_and(|pt| pt.last4 != t.last4()));
|
||||
@@ -956,7 +956,7 @@ impl BooksServer {
|
||||
let on_file = facts.is_some();
|
||||
// The vendor record's W-9 flag follows (below): its feature is
|
||||
// asked for before this command's first line, never after it
|
||||
// (B-27: books waiting for their format upgrade must not be left
|
||||
// (BS-format-1: books waiting for their format upgrade must not be left
|
||||
// with the W-9 recorded and the flag not).
|
||||
let vendor = store.ledger().get_party(id).and_then(|p| p.vendor);
|
||||
if vendor
|
||||
@@ -991,7 +991,7 @@ impl BooksServer {
|
||||
/// GOAL: any party's full TIN (a member's SSN for their K-1, a payee's
|
||||
/// from their W-9) kept where the CPA package can carry it, and
|
||||
/// nowhere else.
|
||||
/// SOURCE: docs/parties-and-attachments.md "The TIN vault"; B-26;
|
||||
/// SOURCE: docs/parties-and-attachments.md "The TIN vault"; BS-partner-2;
|
||||
/// DECISION (owner, 2026-10-15): "In the vault, that's the
|
||||
/// WHOLE reason we built it. And it needs to be in the damn CPA
|
||||
/// package."
|
||||
@@ -1407,7 +1407,7 @@ impl BooksServer {
|
||||
.vendor
|
||||
.and_then(|v| ledger.get_vendor(v))
|
||||
.map(|v| v.decision_on(today()).cloned().unwrap_or_default());
|
||||
// Documents and runs are restored as journaled (rules.md B-28): a
|
||||
// Documents and runs are restored as journaled (BS-entry-4): a
|
||||
// total past exact arithmetic refuses the answer, never a panic.
|
||||
let mut payroll = Vec::new();
|
||||
let (mut gross, mut net) = (Decimal::ZERO, Decimal::ZERO);
|
||||
|
||||
@@ -146,7 +146,7 @@ impl BooksServer {
|
||||
.list_payroll_runs()
|
||||
.into_iter()
|
||||
.map(|r| {
|
||||
// A run is as journaled (rules.md B-28): a total past exact
|
||||
// A run is as journaled (BS-entry-4): a total past exact
|
||||
// arithmetic refuses the list, never a panic.
|
||||
let total_gross =
|
||||
checked_sum(r.lines.iter().map(|l| Ok(l.gross_pay)), "gross pay")?;
|
||||
|
||||
@@ -66,7 +66,7 @@ impl BooksServer {
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
// The members' split, from the closed ledger (rules.md B-13).
|
||||
// The members' split, from the closed ledger (BS-partner-1).
|
||||
let split = |ledger: &Ledger| -> Option<MembersCloseOut> {
|
||||
let (since_close, parts) = ledger.member_close_split(p.period_id)?;
|
||||
let names = self.member_capitals(ledger).unwrap_or_default();
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
//! Projects through the server: `books.add_project`,
|
||||
//! `books.update_project`, `books.projects` and `books.project` (rules.md
|
||||
//! B-37). A project is a class with its facts: `books.add_line`'s class
|
||||
//! `books.update_project`, `books.projects` and `books.project` (
|
||||
//! BS-statement-5). A project is a class with its facts: `books.add_line`'s class
|
||||
//! tags a line with it, and every class tool keeps working.
|
||||
//!
|
||||
//! ```text
|
||||
//! GOAL: the agent records what each project is and links what belongs to
|
||||
//! it; anyone reads what it earned and cost from the same figures
|
||||
//! the viewer and bookspec use.
|
||||
//! SOURCE: docs/spec/rules.md B-37 (DECISION, owner, 2026-10-21; job
|
||||
//! costing; ASC 450-30-25-1 for on-spec work), B-30 (omitted
|
||||
//! dates), B-27 (journal feature `projects`).
|
||||
//! SOURCE: BS-statement-5 (DECISION, owner, 2026-10-21; job
|
||||
//! costing; ASC 450-30-25-1 for on-spec work), BS-period-3 (omitted
|
||||
//! dates), BS-format-1 (journal feature `projects`).
|
||||
//! INVARIANTS:
|
||||
//! 1. Every field is checked before anything is written; a refusal
|
||||
//! journals nothing.
|
||||
@@ -144,7 +144,7 @@ fn by_name(ledger: &Ledger) -> Vec<ClassId> {
|
||||
}
|
||||
|
||||
/// The note `books.add_line` and `books.record_payout` give for a line tagged to a finished or
|
||||
/// abandoned project (rules.md B-37 item 5).
|
||||
/// abandoned project (BS-statement-5 item 5).
|
||||
pub(super) fn late_tag_note(ledger: &Ledger, id: ClassId) -> Option<String> {
|
||||
let f = ledger.project_facts(id)?;
|
||||
if !f.status.is_over() {
|
||||
@@ -162,7 +162,7 @@ pub(super) fn late_tag_note(ledger: &Ledger, id: ClassId) -> Option<String> {
|
||||
}
|
||||
|
||||
/// The note `books.create_invoice` gives for a line naming an on-spec
|
||||
/// project (rules.md B-37 items 4 and 8): on spec, a hoped-for payment is
|
||||
/// project (BS-statement-5 items 4 and 8): on spec, a hoped-for payment is
|
||||
/// no receivable and no income until received, so an invoice for one
|
||||
/// means there is now an agreement, or it shouldn't be an invoice.
|
||||
pub(super) fn on_spec_invoice_note(ledger: &Ledger, id: ClassId) -> Option<String> {
|
||||
|
||||
@@ -549,7 +549,7 @@ impl BooksServer {
|
||||
.chart()
|
||||
.find_by_code(&code)
|
||||
.ok_or_else(|| format!("unknown account {code}"))?;
|
||||
// The dates resolved (rules.md B-30), sent as resolved, so what
|
||||
// The dates resolved (BS-period-3), sent as resolved, so what
|
||||
// the agent is told and what the viewer shows can't differ.
|
||||
let (s, e) = self
|
||||
.periods()
|
||||
@@ -728,7 +728,7 @@ impl BooksServer {
|
||||
if let Some(n) = blobs {
|
||||
checked.push(format!("{n} stored files match their SHA-256"));
|
||||
}
|
||||
// Receivables and payables equal their documents (rules.md B-38
|
||||
// Receivables and payables equal their documents (BS-arap-2
|
||||
// INVARIANT 1): an identity, so a difference is an engine error.
|
||||
let checks = store
|
||||
.ledger()
|
||||
@@ -956,8 +956,8 @@ impl BooksServer {
|
||||
return Err("iif takes as_of, not start or end: the file holds every posted entry from the first through as_of, so QuickBooks' balances match the books'".to_string());
|
||||
}
|
||||
// As of today by default, like every other as-of export
|
||||
// (rules.md B-30); never a period, so the general journal's
|
||||
// default period never shortens it (D-36, B-34).
|
||||
// (BS-period-3); never a period, so the general journal's
|
||||
// default period never shortens it (D-36, BS-format-2).
|
||||
let as_of = self.as_of(p.as_of.as_deref())?;
|
||||
let iif = self.export_iif(as_of, &p.cash_accounts)?;
|
||||
let warnings = iif.warnings();
|
||||
@@ -1044,7 +1044,7 @@ impl BooksServer {
|
||||
expenses: Decimal,
|
||||
}
|
||||
let mut by_class: HashMap<Option<u32>, Acc> = HashMap::new();
|
||||
// A closing entry isn't income or spending (rules.md B-11): left
|
||||
// A closing entry isn't income or spending (BS-period-1): left
|
||||
// out, as profit_and_loss_for_period leaves it out (found by
|
||||
// pnl_by_class_excludes_closing_entries, 2026-10-14).
|
||||
let closings = ledger.closing_entry_ids();
|
||||
@@ -1114,7 +1114,7 @@ impl BooksServer {
|
||||
/// GOAL: everything the CPA needs for the return in one zip, the K-1s'
|
||||
/// and 1099s' TINs included, without a full TIN ever landing in
|
||||
/// the books (a git repository) or the conversation.
|
||||
/// SOURCE: docs/mcp-interface.md; B-26; DECISION (owner,
|
||||
/// SOURCE: docs/mcp-interface.md; BS-partner-2; DECISION (owner,
|
||||
/// 2026-10-15): "it needs to be in the damn CPA package."
|
||||
/// INVARIANTS:
|
||||
/// 1. The zip is handed over (tools/files.rs INVARIANT 6: an export
|
||||
@@ -1516,7 +1516,7 @@ impl BooksServer {
|
||||
ledger_package::export_iif(store.ledger(), cash, as_of)
|
||||
}
|
||||
/// The general journal as JSON or CSV: each entry posted in the
|
||||
/// period (rules.md B-30, as the XLSX journal), in posting order.
|
||||
/// period (BS-period-3, as the XLSX journal), in posting order.
|
||||
fn export_journal(&self, format: &str, p: &ExportParams) -> Result<String, String> {
|
||||
let (start, end) = self.statement_range(p.start.as_deref(), p.end.as_deref())?;
|
||||
let store = self.lock()?;
|
||||
|
||||
@@ -6,7 +6,7 @@ use super::*;
|
||||
|
||||
fn schedule_out(ledger: &Ledger, s: &ledger_core::AmortizationSchedule) -> ScheduleOut {
|
||||
// A schedule an earlier version journaled may run past the last date
|
||||
// chrono holds (rules.md B-28): shown, with why its plan can't be.
|
||||
// chrono holds (BS-entry-4): shown, with why its plan can't be.
|
||||
let plan = s.plan();
|
||||
let code = |id| {
|
||||
ledger
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! `books.receive_payment`, `books.pay_bill`, `books.bills_due` and the
|
||||
//! agings: paying on terms (plan P4b S6; rules.md B-42). A payment settles
|
||||
//! agings: paying on terms (plan P4b S6; BS-arap-6). A payment settles
|
||||
//! one or several invoices (or bills) of one party, with the early-payment
|
||||
//! discounts their terms allow and the processor's fee on a customer
|
||||
//! payment posted gross. Split from `tools/documents.rs` so S4.4's work
|
||||
@@ -247,7 +247,7 @@ fn settlement(
|
||||
}
|
||||
|
||||
/// What a payment settled: each document's figures after it (derived from
|
||||
/// its lines that stand, rules.md B-38) and what reached or left the
|
||||
/// its lines that stand, BS-arap-2) and what reached or left the
|
||||
/// account.
|
||||
fn payment_out(
|
||||
ledger: &Ledger,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
//! `books.write_off_invoice`'s group: bad debts (plan P4b S7; rules.md
|
||||
//! B-41). A file of its own (plan 8.2 U0a) so S4.4's document tools and
|
||||
//! `books.write_off_invoice`'s group: bad debts (plan P4b S7;
|
||||
//! BS-arap-5). A file of its own (plan 8.2 U0a) so S4.4's document tools and
|
||||
//! this one land apart: a tool is added to its group's file and nowhere
|
||||
//! else.
|
||||
|
||||
use super::*;
|
||||
|
||||
/// An invoice's figures after a write-off, as the tool answers them: read
|
||||
/// from its tagged lines that stand (rules.md B-38), at the end of the
|
||||
/// from its tagged lines that stand (BS-arap-2), at the end of the
|
||||
/// books.
|
||||
fn write_off_out(
|
||||
ledger: &Ledger,
|
||||
@@ -50,7 +50,7 @@ impl BooksServer {
|
||||
let date = parse_date(&p.date)?;
|
||||
let mut store = self.lock()?;
|
||||
// The event type is new: books that haven't declared documents_v2
|
||||
// refuse it with the upgrade remedy, journaling nothing (B-27).
|
||||
// refuse it with the upgrade remedy, journaling nothing (BS-format-1).
|
||||
store
|
||||
.ensure_feature(ledger_store::format::DOCUMENTS_V2)
|
||||
.map_err(|e| e.to_string())?;
|
||||
@@ -65,7 +65,7 @@ impl BooksServer {
|
||||
Some(a) => parse_amount(a)?,
|
||||
None => owed,
|
||||
};
|
||||
// The evidence is the point of a write-off (B-41 INVARIANT 1): one
|
||||
// The evidence is the point of a write-off (BS-arap-5 INVARIANT 1): one
|
||||
// of the two, and the preview says so too rather than posting
|
||||
// without it later.
|
||||
match (p.upload_id.is_some(), p.existing_attachment_id.is_some()) {
|
||||
|
||||
Reference in new issue
Block a user