merge: P4b S7, bad debts (branch S7, 4b4fecb9)
The fourth of the paused branches: Ledger::write_off and the bad_debts control role, invoice.written_off with its evidence filed in the same store call, books.write_off_invoice, the write-off on the timeline and in Needs attention, Lean writeOff_within_bounds, rules.md B-41 and the bookspec examples. Twenty-eight files conflicted with the S4.4, S5 and S6 merges; resolved as plan 8.0.2 says, keeping both sides' appends with their seams restored, and: the scope table at 125; S7's law numbered 37; B-41 placed before B-42; the handbook's step 4 and recovery procedures folded into the one invoices-and-bills section; S7's wire tests in their own module with the confirm S4.4's contract needs; S7's copy of the payment steps dropped (S6 replaced them with Ledger::settle) and its write-off journaled through S6's journal_auto_lines; in the old-books fixture S7's hand-written write-off moved to a second invoice, since S6's hand-written payment settles invoice 1 in full. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
This commit is contained in:
commit
335a3eaa7e
47 files changed
+2883
-74
No files matched your search
@@ -67,6 +67,9 @@ enum Op {
|
||||
/// Record a send of document `k` (an invoice; a bill is skipped) on
|
||||
/// day `n`, a reminder after its first send. A send moves no figure.
|
||||
MarkSent(usize, u8),
|
||||
/// Write off an invoice `k` (mod the documents) on day `n` for `c`
|
||||
/// cents, with its evidence filed in the same call.
|
||||
WriteOff(usize, u8, i64),
|
||||
/// Close month `m` (January to March), in order.
|
||||
Close(u8),
|
||||
/// A hand line on receivables (true) or payables: always refused.
|
||||
@@ -91,6 +94,8 @@ fn arb_op() -> impl Strategy<Value = Op> {
|
||||
3 => (0usize..40, 0u8..90).prop_map(|(k, n)| Op::Reverse(k, n)),
|
||||
1 => (0usize..8, 0u8..90).prop_map(|(k, n)| Op::Void(k, n)),
|
||||
2 => (0usize..8, 0u8..90).prop_map(|(k, n)| Op::MarkSent(k, n)),
|
||||
2 => (0usize..8, 0u8..90, 1i64..40_000)
|
||||
.prop_map(|(k, n, c)| Op::WriteOff(k, n, c)),
|
||||
1 => (1u8..4).prop_map(Op::Close),
|
||||
1 => (any::<bool>(), 1i64..10_000).prop_map(|(r, c)| Op::Hand(r, c)),
|
||||
2 => (0usize..8, 0usize..8, 0u8..90, 1i64..20_000, 0i64..2_000, 0i64..500)
|
||||
@@ -225,6 +230,25 @@ fn run(s: &mut Store, k: &Setup, ops: &[Op], docs: &mut Vec<DocRef>) -> Result<(
|
||||
.map(drop)
|
||||
}
|
||||
},
|
||||
Op::WriteOff(..) if docs.is_empty() => Ok(()),
|
||||
Op::WriteOff(i, n, c) => match docs[i % docs.len()] {
|
||||
// A bill is never written off: the API takes an invoice.
|
||||
DocRef::Bill(_) => Ok(()),
|
||||
DocRef::Invoice(id) => s
|
||||
.write_off_invoice(
|
||||
id,
|
||||
day(n),
|
||||
cents(c),
|
||||
"uncollectible",
|
||||
Some(ledger_store::WriteOffEvidence::File {
|
||||
file_name: "collection-letter.pdf",
|
||||
mime_type: "application/pdf",
|
||||
bytes: b"%PDF-1.4\nFinal demand\n%%EOF\n",
|
||||
description: Some("Collection attempts"),
|
||||
}),
|
||||
)
|
||||
.map(drop),
|
||||
},
|
||||
Op::Close(m) => {
|
||||
let start = NaiveDate::from_ymd_opt(2026, u32::from(m), 1).unwrap();
|
||||
let end = start + chrono::Months::new(1) - chrono::Days::new(1);
|
||||
|
||||
Reference in new issue
Block a user