test(core): golden file for the tax summary
Golden for the Form 1065 first-quarter fixture (tax.rs books()), Jan 1 to Mar 31. Every number was recomputed by hand from the entries (plan/golden-worksheets/tax_summary_form_1065.md) before the engine's output was compared: Income: sales 10,000.00; refunds 250.00 are an expense-type account in an income category, so a contra: -250.00 (Form 1065 line 1b). Income 9,750.00. Deductions, book / deductible: fees 1,500 / 1,500; guaranteed payments 2,000 / 2,000; meals 333.33 at 50% = 166.665 = 166.67 (cent, half away from zero; Schedule C line 24b: "in most cases, the percentage is 50%"); software 600 / 600; penalties 40 at 0% = 0 (Schedule C Part V: no deduction for fines). Totals 4,473.33 book, 4,266.67 deductible. Misc 75.00 has no category and is listed apart, in no total (B-32). Book net 9,750.00 - 4,473.33 = 5,276.67; tax net 9,750.00 - 4,266.67 = 5,483.33; the 206.66 difference is the disallowed meals half (166.66) plus penalties (40.00). Decimals compare by value (normalized), as the existing snapshot golden writes them; no existing golden or assertion changed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5c7055123d
commit
545a502d3d
3 files changed
+232
No files matched your search
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"start": "2026-01-01",
|
||||
"end": "2026-03-31",
|
||||
"form": "form1065",
|
||||
"income": [
|
||||
{
|
||||
"category": "gross_receipts",
|
||||
"label": "Gross receipts or sales",
|
||||
"accounts": ["4000 Sales"],
|
||||
"book": "10000",
|
||||
"tax": "10000"
|
||||
},
|
||||
{
|
||||
"category": "returns_allowances",
|
||||
"label": "Returns and allowances",
|
||||
"accounts": ["4100 Refunds"],
|
||||
"book": "-250",
|
||||
"tax": "-250"
|
||||
}
|
||||
],
|
||||
"cost_of_goods": [],
|
||||
"deductions": [
|
||||
{
|
||||
"category": "commissions_fees",
|
||||
"label": "Commissions and fees",
|
||||
"accounts": ["6000 Platform fees"],
|
||||
"book": "1500",
|
||||
"tax": "1500"
|
||||
},
|
||||
{
|
||||
"category": "guaranteed_payments",
|
||||
"label": "Guaranteed payments to partners",
|
||||
"accounts": ["6400 Partner pay"],
|
||||
"book": "2000",
|
||||
"tax": "2000"
|
||||
},
|
||||
{
|
||||
"category": "meals",
|
||||
"label": "Meals",
|
||||
"accounts": ["6100 Meals"],
|
||||
"book": "333.33",
|
||||
"tax": "166.67"
|
||||
},
|
||||
{
|
||||
"category": "other_deductions",
|
||||
"label": "Other deductions",
|
||||
"accounts": ["6300 Software"],
|
||||
"book": "600",
|
||||
"tax": "600"
|
||||
},
|
||||
{
|
||||
"category": "nondeductible",
|
||||
"label": "Nondeductible expenses",
|
||||
"accounts": ["6200 Penalties"],
|
||||
"book": "40",
|
||||
"tax": "0"
|
||||
}
|
||||
],
|
||||
"separately_stated": [],
|
||||
"form_4797": [],
|
||||
"uncategorized": [
|
||||
{
|
||||
"account": "6500 Misc",
|
||||
"account_type": "Expense",
|
||||
"book": "75"
|
||||
}
|
||||
],
|
||||
"book_net": "5276.67",
|
||||
"tax_net": "5483.33"
|
||||
}
|
||||
@@ -145,6 +145,46 @@ fn the_summary_groups_by_category_and_applies_deductible_percents() {
|
||||
assert_eq!(ts.tax_net(), dec("5483.33"));
|
||||
}
|
||||
|
||||
/// Every decimal string in `v`, by value (`"0.00"` and `"0"` are one
|
||||
/// number), as `snapshot` writes them. Both sides of a golden comparison go
|
||||
/// through it, so a harmless difference of written scale is no failure and
|
||||
/// every value must still agree exactly.
|
||||
fn by_value(v: &mut serde_json::Value) {
|
||||
match v {
|
||||
serde_json::Value::String(s) => {
|
||||
if let Ok(x) = Decimal::from_str(s) {
|
||||
*s = x.normalize().to_string();
|
||||
}
|
||||
}
|
||||
serde_json::Value::Array(items) => items.iter_mut().for_each(by_value),
|
||||
serde_json::Value::Object(map) => map.values_mut().for_each(by_value),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
/// The golden: every number in `golden/tax_summary_form_1065.json` was
|
||||
/// computed by hand, from the fixture's entries, in
|
||||
/// `plan/golden-worksheets/tax_summary_form_1065.md`, before the engine's
|
||||
/// output was looked at. Rules: B-32 and `sources/irs-tax-lines.md` (the
|
||||
/// category-to-line map; a contra-income expense account reduces receipts;
|
||||
/// meals at 50% from the Schedule C line 24b instructions, so 333.33 is
|
||||
/// 166.665, the cent half away from zero, 166.67; fines and penalties at 0%
|
||||
/// from Schedule C Part V; an account with no category is listed, in no
|
||||
/// total). `book_net` and `tax_net` are methods, so the test adds them.
|
||||
#[test]
|
||||
fn golden_tax_summary_form_1065() {
|
||||
let l = books();
|
||||
let ts = tax_summary(&l, d(1, 1), d(3, 31), Some(TaxForm::Form1065)).unwrap();
|
||||
let mut actual = serde_json::to_value(&ts).unwrap();
|
||||
actual["book_net"] = serde_json::to_value(ts.book_net()).unwrap();
|
||||
actual["tax_net"] = serde_json::to_value(ts.tax_net()).unwrap();
|
||||
by_value(&mut actual);
|
||||
let mut golden: serde_json::Value =
|
||||
serde_json::from_str(include_str!("golden/tax_summary_form_1065.json")).unwrap();
|
||||
by_value(&mut golden);
|
||||
assert_eq!(actual, golden);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_override_beats_the_category_default() {
|
||||
let mut l = books();
|
||||
|
||||
Reference in new issue
Block a user