fix(mcp,store,core): four refusals are decided before the call's first line (P15 T1, D-88)
A refusal is decided before anything is written; a failed call on the record is for a call that failed part way. Four tools wrote a line and then refused, so under T1 each left a begun line, its lines and a failed closing line in the journal for a plain "no": - books.attach_receipt and books.file_document: bytes already filed are one file, so filing them again links the existing attachment; a link it already holds was refused after the earlier links were written. The store now asks first (Store::check_filing_links). - books.draft_entry and books.draft_from_template: a no_party_reason that names a full tax id was refused by the mark, after the draft was made. Ledger::check_no_party_reason is asked first. - books.dispose_asset: a receipt named twice was refused at its second link, after the disposal was posted. The ids are checked for repeats first. Each has a test that the journal is byte for byte as it was. No journal format or frame shape changes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc55a10101
commit
38612ab553
11 files changed
+192
-2
No files matched your search
@@ -1295,6 +1295,31 @@ fn a_reversed_run_is_not_posted() {
|
||||
assert_eq!(dec(&a, "book_value").as_deref(), Some("1200"));
|
||||
}
|
||||
|
||||
/// A bill of sale named twice is refused before the disposal is written:
|
||||
/// the second link would be refused after the first, and a refusal is
|
||||
/// decided before anything is written (D-88), so the journal is byte for
|
||||
/// byte what it was and the asset is still held.
|
||||
#[test]
|
||||
fn disposing_with_a_receipt_named_twice_is_refused_before_anything_is_written() {
|
||||
let mut m = books("disposed-twice");
|
||||
m.post(
|
||||
"2026-01-01",
|
||||
&[("1000", "debit", "9000.00"), ("3000", "credit", "9000.00")],
|
||||
);
|
||||
let (id, sold) = m.register_ok(json!({}));
|
||||
let doc = m.file_bill_of_sale();
|
||||
let before = m.journal_raw();
|
||||
let why = m.refuse(
|
||||
"books.dispose_asset",
|
||||
json!({"tag": sold, "date": "2026-03-31", "proceeds": "100.00",
|
||||
"proceeds_account": "1000", "gain_loss_account": "7100",
|
||||
"confirmed": true, "receipt_attachment_ids": [doc, doc]}),
|
||||
);
|
||||
assert!(why.contains("twice"), "{why}");
|
||||
assert!(m.journal_raw() == before, "a refusal wrote to the journal");
|
||||
assert_eq!(m.asset(id)["status"], "active");
|
||||
}
|
||||
|
||||
/// A disposed asset is not held: every figure 0.00 once it left the books.
|
||||
#[test]
|
||||
fn a_disposed_asset_has_left_the_books() {
|
||||
|
||||
Reference in new issue
Block a user