Merge main into the K-U5 branch: X-H1b, K-U3, S-E2, S-E3, X-H1c
This commit is contained in:
commit
5e4950697e
100 files changed
+1793
-374
No files matched your search
@@ -152,7 +152,7 @@ pub enum StoreError {
|
||||
#[error("store not found at {0}")]
|
||||
NotFound(String),
|
||||
|
||||
/// A write-off with no evidence (BS-arap-5 INVARIANT 1): a bad
|
||||
/// A write-off with no evidence (BS-arap-5 statement 10): a bad
|
||||
/// debt is deducted on evidence that it is worthless (Treas. Reg.
|
||||
/// §1.166-2), so the books take the write-off only with its file.
|
||||
#[error(
|
||||
|
||||
@@ -192,7 +192,7 @@ pub const ASSET_BASIS: &str = "asset_basis";
|
||||
pub const PROJECTS: &str = "projects";
|
||||
|
||||
/// Feature: an `invoice.created` or `bill.created` line naming its project
|
||||
/// (`class_id`, BS-statement-5 item 8). An older version would restore the
|
||||
/// (`class_id`, BS-statement-5 statement 6). An older version would restore the
|
||||
/// document without its lines' projects, silently. Its own feature, not
|
||||
/// `projects`': books that consented to projects before it existed must
|
||||
/// consent again before a document names one.
|
||||
|
||||
@@ -507,7 +507,7 @@ struct AttachRequest<'a> {
|
||||
}
|
||||
|
||||
/// The evidence a bad-debt write-off files (plan P4b S7; BS-arap-5
|
||||
/// INVARIANT 1): the file that shows the debt is worthless — collection
|
||||
/// statement 9): the file that shows the debt is worthless — collection
|
||||
/// correspondence, a bankruptcy notice (Treas. Reg. §1.166-2). Given as
|
||||
/// bytes to file in the same call, or as an attachment already in the
|
||||
/// books that is linked to the write-off's entry and its invoice.
|
||||
@@ -3446,7 +3446,7 @@ impl Store {
|
||||
}
|
||||
|
||||
/// The issued copy of an invoice, filed in the call that issues it
|
||||
/// (plan P4b S4.3 item 11, A-7; BS-arap-4 item 3): the entry, then
|
||||
/// (plan P4b S4.3 item 11, A-7; BS-arap-4 invariant 3 and WB-arap-8): the entry, then
|
||||
/// `invoice.created`, then `receipt.attached` on the entry
|
||||
/// (`INV-0007.pdf`, `application/pdf`, "Issued invoice"), then
|
||||
/// `attachment.linked` to the invoice. The server renders the PDF
|
||||
@@ -3462,7 +3462,7 @@ impl Store {
|
||||
/// GOAL: the copy sent is kept with the invoice, or nothing is.
|
||||
/// SOURCE: IRS Pub. 583 (keep invoices); Rev. Proc. 98-25 (the audit
|
||||
/// trail keeps the record as issued); plan P4b S4.3, 8.3.11;
|
||||
/// BS-arap-4 item 3.
|
||||
/// BS-arap-4 invariant 3 and WB-arap-8.
|
||||
/// INVARIANTS:
|
||||
/// 1. Every refusal (an unknown customer, an invalid line or due
|
||||
/// date, a duplicate number, a closed period, a feature the books
|
||||
@@ -4534,7 +4534,7 @@ impl Store {
|
||||
/// ```text
|
||||
/// GOAL: a project in one command, journaled as two events only when
|
||||
/// it has facts, so a name-only project is a plain class.
|
||||
/// SOURCE: BS-statement-5 item 1; BS-format-1 (journal feature
|
||||
/// SOURCE: WB-statement-5; BS-format-1 (journal feature
|
||||
/// `projects`).
|
||||
/// INVARIANTS:
|
||||
/// 1. A refusal journals nothing: the whole record is rehearsed, and
|
||||
@@ -6885,7 +6885,7 @@ fn document_line_json(l: &DocumentLine) -> Value {
|
||||
"amount": l.amount.to_string(),
|
||||
});
|
||||
// Its project, behind the feature document_line_projects (
|
||||
// BS-format-1, BS-statement-5 item 8); a line naming none is written as before it.
|
||||
// BS-format-1, BS-statement-5 statement 6); a line naming none is written as before it.
|
||||
if let Some(c) = l.class_id {
|
||||
v["class_id"] = json!(c);
|
||||
}
|
||||
@@ -6964,7 +6964,7 @@ fn invoice_fields_json(payload: &mut Value, fields: &arap::InvoiceFields) {
|
||||
}
|
||||
|
||||
/// Add a bill's new fields to its `bill.created` payload, each key only when
|
||||
/// set. A duplicate's reason is journaled for the record (BS-arap-4 item
|
||||
/// set. A duplicate's reason is journaled for the record (BS-arap-4 invariant
|
||||
/// 4); the bill itself keeps none.
|
||||
fn bill_fields_json(payload: &mut Value, fields: &arap::BillFields) {
|
||||
if let Some(r) = &fields.vendor_ref {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
//! Documents through the store, at random (BS-arap-2 INVARIANTS 1, 2,
|
||||
//! 4 and 6; plan P4b.15): histories of invoices, bills, payments (with a
|
||||
//! Documents through the store, at random (BS-arap-2 invariants 1, 2, 3, 6, 7 and 9; plan P4b.15): histories of invoices, bills, payments (with a
|
||||
//! payment method and a reference, or none), voids, reversals of any
|
||||
//! entry, closed months and refused hand lines, run through `Store`, then
|
||||
//! replayed (the books reopened) and read by a `Snapshot`.
|
||||
@@ -9,7 +8,7 @@
|
||||
//! the live books, their replay and a viewer's snapshot agree on
|
||||
//! every figure, at every date, and the control accounts equal
|
||||
//! their documents.
|
||||
//! SOURCE: BS-entry-4 (replay), BS-arap-2 INVARIANTS 1, 2, 4, 6.
|
||||
//! SOURCE: BS-entry-4 (replay), BS-arap-2 invariants 1, 2, 3, 6, 7 and 9.
|
||||
//! ```
|
||||
|
||||
use chrono::NaiveDate;
|
||||
@@ -417,7 +416,7 @@ fn agree(live: &Ledger, dir: &Path, docs: &[DocRef]) -> Result<(), TestCaseError
|
||||
proptest! {
|
||||
#![proptest_config(ProptestConfig::with_cases(32))]
|
||||
|
||||
/// BS-arap-2 INVARIANT 4 (and 1, 2, 6 through the store): a document's
|
||||
/// BS-arap-2 invariant 7 (and 1, 6, 9 through the store): a document's
|
||||
/// state is a function of the journal and the day. Half the history,
|
||||
/// then the books reopened and compared; the rest on the reopened
|
||||
/// books, compared again.
|
||||
|
||||
@@ -377,7 +377,7 @@ fn legacy_reversal_now_counts() {
|
||||
assert_eq!(trial_balance_json(&again), g["trial_balance"]);
|
||||
}
|
||||
|
||||
/// BS-arap-2 scenario 5 and item 7 in books an earlier version keeps: the
|
||||
/// BS-arap-2 scenario 5 and WB-arap-4 in books an earlier version keeps: the
|
||||
/// right payment after the wrong one was reversed waits for the journal
|
||||
/// feature document_standing (an older version would count both),
|
||||
/// refused and journaling nothing until the owner's upgrade; a payment
|
||||
@@ -831,7 +831,7 @@ fn no_new_fields_journals_byte_for_byte() {
|
||||
}
|
||||
|
||||
/// The issued copy is filed with the invoice or nothing is (plan P4b S4.3
|
||||
/// item 11, A-7; BS-arap-4 item 3): a refusal leaves the journal, the
|
||||
/// item 11, A-7; BS-arap-4 invariant 3 and WB-arap-8): a refusal leaves the journal, the
|
||||
/// ledger and the allocators exactly as they were; an issue journals the
|
||||
/// entry, `invoice.created`, `receipt.attached` on that entry
|
||||
/// (`INV-0007.pdf`, `application/pdf`, "Issued invoice") and
|
||||
@@ -1247,8 +1247,7 @@ fn mark_sent_on_void_refused() {
|
||||
|
||||
/// A settlement of two invoices, a discount and a processor's fee: one
|
||||
/// entry whose events name the lines they tag, every figure derived, and
|
||||
/// the books replaying to the same lines (plan P4b S6; BS-arap-6
|
||||
/// INVARIANTS 1 and 3).
|
||||
/// the books replaying to the same lines (plan P4b S6; BS-arap-6 invariant 3 and WB-arap-15).
|
||||
#[test]
|
||||
fn a_settlement_names_its_lines_and_replays() {
|
||||
use ledger_core::{Application, DocRef, Fee, SettleParams};
|
||||
@@ -1422,7 +1421,7 @@ fn settlement_waits_for_documents_v2() {
|
||||
|
||||
/// Legacy payment events carry no `line`, so replay keeps the positional
|
||||
/// rule: the first untagged control line for the payment's amount, in the
|
||||
/// order the events come (plan P4b S6; BS-arap-6 INVARIANT 3).
|
||||
/// order the events come (plan P4b S6; WB-arap-15).
|
||||
#[test]
|
||||
fn legacy_payment_events_keep_the_positional_rule() {
|
||||
use ledger_core::{DocRef, Movement};
|
||||
@@ -1582,7 +1581,7 @@ fn write_off_waits_for_documents_v2() {
|
||||
/// A write-off is journaled as its entry and one `invoice.written_off`,
|
||||
/// and replay derives the same figures and the projection agrees: the
|
||||
/// invoice reads Written off, the bad-debt expense is on 6990, and the
|
||||
/// control account still equals its documents (BS-arap-5, BS-arap-2 INVARIANT 1).
|
||||
/// control account still equals its documents (BS-arap-5, BS-arap-2 invariant 1).
|
||||
#[test]
|
||||
fn write_off_replays_and_projects() {
|
||||
let dir = test_dir("write-off-replay");
|
||||
@@ -1600,7 +1599,7 @@ fn write_off_replays_and_projects() {
|
||||
)
|
||||
.unwrap();
|
||||
// Half paid, the rest written off: the invoice reads Written off with
|
||||
// 50 paid and 50 written off (BS-arap-2 SCENARIO 7).
|
||||
// 50 paid and 50 written off (BS-arap-2 scenario 7).
|
||||
s.receive_payment(inv, d(2026, 4, 20), cents(5_000), bank)
|
||||
.unwrap();
|
||||
let from = journal_len(&dir.0);
|
||||
@@ -1683,7 +1682,7 @@ fn write_off_replays_and_projects() {
|
||||
s.verify().unwrap();
|
||||
}
|
||||
|
||||
/// No evidence, no write-off (BS-arap-5 INVARIANT 1; Treas. Reg.
|
||||
/// No evidence, no write-off (BS-arap-5 statement 10; Treas. Reg.
|
||||
/// §1.166-2(a)): refused, journaling nothing; an attachment already filed
|
||||
/// is linked instead, to the entry and the invoice.
|
||||
#[test]
|
||||
|
||||
@@ -1175,7 +1175,7 @@ fn reversing_a_linked_acquisition_still_opens_and_verifies() {
|
||||
Store::open(&dir).unwrap().verify().unwrap();
|
||||
}
|
||||
|
||||
// ------------------------------------------------- depreciation runs (BS-asset-1 rules 6 and 8)
|
||||
// ------------------------------------------------- depreciation runs (BS-asset-1 statements 14 and 28)
|
||||
|
||||
/// A run is the books' record of what they carry for an asset
|
||||
/// (Ledger::accumulated_posted): recorded live, replayed from the journal,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! An invoice's or bill's lines in the journal (BS-statement-5 item 8,
|
||||
//! An invoice's or bill's lines in the journal (BS-statement-5 statement 6,
|
||||
//! BS-format-1): a line naming its project carries `class_id` (journal feature
|
||||
//! `document_line_projects`), and the entry's revenue or expense line for
|
||||
//! that project is tagged by `entry.line_class_set` right after its
|
||||
@@ -9,7 +9,7 @@
|
||||
//! ```text
|
||||
//! GOAL: a document's projects are journaled once, replay exactly, and
|
||||
//! never reach books whose owner hasn't consented to the format.
|
||||
//! SOURCE: BS-statement-5 item 8, BS-format-1, BS-entry-4; plan/served.md
|
||||
//! SOURCE: BS-statement-5 statement 6, BS-format-1, BS-entry-4; plan/served.md
|
||||
//! D-39 (the owner's upgrade).
|
||||
//! ```
|
||||
|
||||
|
||||
@@ -2636,7 +2636,7 @@ fn every_figure_of(l: &ledger_core::Ledger) -> (usize, usize) {
|
||||
tally(reports::general_ledger(l, start, end).map(|_| ()));
|
||||
tally(reports::members_equity(l, start, end, &members).map(|_| ()));
|
||||
// The statement of cash flows foots on every book, or is refused
|
||||
// for a reason: never an engine error (BS-statement-3 rule 9).
|
||||
// for a reason: never an engine error (BS-statement-3 statement 14).
|
||||
let cf = reports::cash_flow(
|
||||
l,
|
||||
&reports::CashFlowParams {
|
||||
|
||||
Reference in new issue
Block a user