merge: golden files for the 1099 worksheet (with a recorded business card's exclusion) and prepaid and deferred amortization (branch t3/golden-1099-prepaid-amortization, 06b571c1; reviewed and recomputed independently)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
de584309fc
7 files changed
+802
-3
No files matched your search
@@ -494,7 +494,7 @@ impl Status1099 {
|
||||
}
|
||||
|
||||
/// One vendor's year.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
|
||||
pub struct Vendor1099Line {
|
||||
/// The vendor.
|
||||
pub vendor_id: VendorId,
|
||||
@@ -542,7 +542,7 @@ impl Vendor1099Line {
|
||||
}
|
||||
|
||||
/// One payment on a vendor's year, for the worksheet's lists.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
|
||||
pub struct Payment1099 {
|
||||
/// The entry.
|
||||
pub entry_id: EntryId,
|
||||
@@ -557,7 +557,7 @@ pub struct Payment1099 {
|
||||
}
|
||||
|
||||
/// The year's 1099 report.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize)]
|
||||
pub struct Vendor1099Report {
|
||||
/// Calendar year.
|
||||
pub year: i32,
|
||||
|
||||
@@ -208,6 +208,10 @@ fn cash_paid_per_vendor_and_who_is_reportable() {
|
||||
assert_eq!(ace.form(), Some(Form1099::Misc));
|
||||
assert_eq!(ace.decided, Some(src()));
|
||||
assert!(!ace.tin_on_file);
|
||||
// No method records the card: Sam's 5,000 on it counts for no one.
|
||||
let sam = line(&r, "Sam");
|
||||
assert_eq!((sam.excluded_card, sam.undetermined), (dec("0"), dec("0")));
|
||||
assert!(r.excluded_card_payments.is_empty());
|
||||
// The untagged 50 paid out for contract labor: the quieter note's one.
|
||||
assert_eq!(r.untagged_payments.len(), 1);
|
||||
}
|
||||
@@ -2511,3 +2515,35 @@ fn card_accounts_are_the_company_cards_liabilities() {
|
||||
[m.card]
|
||||
);
|
||||
}
|
||||
|
||||
/// Golden (oracle Layer 1): the worksheet's figures for the hand-verified
|
||||
/// fixture above, every one recomputed from the entries in
|
||||
/// plan/golden-worksheets/1099-worksheet.md before this test was run.
|
||||
/// 2025 and 2026 together pin the year boundary: Dana's 300.00 on
|
||||
/// 2025-12-30 counts in 2025 only, and the threshold moves from 600 to
|
||||
/// 2,000 (rules.md B-19).
|
||||
#[test]
|
||||
fn golden_1099_worksheet() {
|
||||
let mut l = books();
|
||||
// Record the card (worksheet, "With the card recorded"): Sam's 5,000
|
||||
// is then a card payment, excluded and listed (B-19). books() leaves
|
||||
// it unrecorded, and other tests rely on that.
|
||||
let card = l.chart().find_by_code("2100").unwrap().id;
|
||||
l.add_instrument(
|
||||
InstrumentKind::BusinessCard,
|
||||
"Harbor Visa",
|
||||
Some("0042"),
|
||||
None,
|
||||
card,
|
||||
)
|
||||
.unwrap();
|
||||
let r2026 = report_for(&l, 2026, None, &[]).unwrap();
|
||||
let r2025 = report_for(&l, 2025, None, &[]).unwrap();
|
||||
let got = serde_json::json!({
|
||||
"2025": serde_json::to_value(&r2025).unwrap(),
|
||||
"2026": serde_json::to_value(&r2026).unwrap(),
|
||||
});
|
||||
let want: serde_json::Value =
|
||||
serde_json::from_str(include_str!("golden/form1099_worksheet.json")).unwrap();
|
||||
assert_eq!(got, want);
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
{
|
||||
"deferred": {
|
||||
"balance_sheet": {
|
||||
"as_of": "2026-03-31",
|
||||
"assets": [
|
||||
{
|
||||
"amount": "1000",
|
||||
"code": "1000",
|
||||
"name": "Cash"
|
||||
}
|
||||
],
|
||||
"current_earnings": "1000.00",
|
||||
"equity": [],
|
||||
"liabilities": [],
|
||||
"total_assets": "1000",
|
||||
"total_equity": "1000.00",
|
||||
"total_liabilities": "0"
|
||||
},
|
||||
"currency": "USD",
|
||||
"description": "Quarterly plan, Acme",
|
||||
"kind": "deferred_revenue",
|
||||
"months": 3,
|
||||
"plan": [
|
||||
{
|
||||
"amount": "333.33",
|
||||
"date": "2026-01-31"
|
||||
},
|
||||
{
|
||||
"amount": "333.33",
|
||||
"date": "2026-02-28"
|
||||
},
|
||||
{
|
||||
"amount": "333.34",
|
||||
"date": "2026-03-31"
|
||||
}
|
||||
],
|
||||
"posted": [
|
||||
"2026-01-31",
|
||||
"2026-02-28",
|
||||
"2026-03-31"
|
||||
],
|
||||
"profit_and_loss": {
|
||||
"end": "2026-03-31",
|
||||
"expenses": [],
|
||||
"revenue": [
|
||||
{
|
||||
"amount": "1000.00",
|
||||
"code": "4000",
|
||||
"name": "Subscription Revenue"
|
||||
}
|
||||
],
|
||||
"start": "2026-01-01",
|
||||
"total_expenses": "0",
|
||||
"total_revenue": "1000.00"
|
||||
},
|
||||
"remaining": "0",
|
||||
"start": "2026-01-01",
|
||||
"total": "1000"
|
||||
},
|
||||
"prepaid": {
|
||||
"balance_sheet": {
|
||||
"as_of": "2026-05-31",
|
||||
"assets": [
|
||||
{
|
||||
"amount": "-1200",
|
||||
"code": "1000",
|
||||
"name": "Cash"
|
||||
},
|
||||
{
|
||||
"amount": "900",
|
||||
"code": "1300",
|
||||
"name": "Prepaid Expenses"
|
||||
}
|
||||
],
|
||||
"current_earnings": "-300",
|
||||
"equity": [],
|
||||
"liabilities": [],
|
||||
"total_assets": "-300",
|
||||
"total_equity": "-300",
|
||||
"total_liabilities": "0"
|
||||
},
|
||||
"currency": "USD",
|
||||
"description": "Liability insurance",
|
||||
"kind": "prepaid_expense",
|
||||
"months": 12,
|
||||
"plan": [
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-03-31"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-04-30"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-05-31"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-06-30"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-07-31"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-08-31"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-09-30"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-10-31"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-11-30"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2026-12-31"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2027-01-31"
|
||||
},
|
||||
{
|
||||
"amount": "100",
|
||||
"date": "2027-02-28"
|
||||
}
|
||||
],
|
||||
"posted": [
|
||||
"2026-03-31",
|
||||
"2026-04-30",
|
||||
"2026-05-31"
|
||||
],
|
||||
"profit_and_loss": {
|
||||
"end": "2026-05-31",
|
||||
"expenses": [
|
||||
{
|
||||
"amount": "300",
|
||||
"code": "6300",
|
||||
"name": "Insurance"
|
||||
}
|
||||
],
|
||||
"revenue": [],
|
||||
"start": "2026-03-01",
|
||||
"total_expenses": "300",
|
||||
"total_revenue": "0"
|
||||
},
|
||||
"remaining": "900",
|
||||
"start": "2026-03-01",
|
||||
"total": "1200"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,244 @@
|
||||
{
|
||||
"2025": {
|
||||
"excluded_card_payments": [],
|
||||
"other_receipts": [],
|
||||
"threshold": "600",
|
||||
"through": null,
|
||||
"undetermined_payments": [],
|
||||
"unresolved": [],
|
||||
"untagged_payments": [],
|
||||
"vendors": [
|
||||
{
|
||||
"decided": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
},
|
||||
"decision": {
|
||||
"files": "misc"
|
||||
},
|
||||
"decision_needed": false,
|
||||
"decisions": [
|
||||
{
|
||||
"decision": {
|
||||
"files": "misc"
|
||||
},
|
||||
"effective": null,
|
||||
"source": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
}
|
||||
}
|
||||
],
|
||||
"effective": null,
|
||||
"excluded_card": "0",
|
||||
"name": "Ace Rentals",
|
||||
"not_reportable": "0",
|
||||
"paid": "0",
|
||||
"reportable": false,
|
||||
"status": "under_threshold",
|
||||
"tin_on_file": false,
|
||||
"undetermined": "0",
|
||||
"vendor_id": 2
|
||||
},
|
||||
{
|
||||
"decided": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
},
|
||||
"decision": {
|
||||
"files": "nec"
|
||||
},
|
||||
"decision_needed": false,
|
||||
"decisions": [
|
||||
{
|
||||
"decision": {
|
||||
"files": "nec"
|
||||
},
|
||||
"effective": null,
|
||||
"source": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
}
|
||||
}
|
||||
],
|
||||
"effective": null,
|
||||
"excluded_card": "0",
|
||||
"name": "Dana",
|
||||
"not_reportable": "0",
|
||||
"paid": "300",
|
||||
"reportable": false,
|
||||
"status": "under_threshold",
|
||||
"tin_on_file": true,
|
||||
"undetermined": "0",
|
||||
"vendor_id": 1
|
||||
},
|
||||
{
|
||||
"decided": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
},
|
||||
"decision": {
|
||||
"files": "nec"
|
||||
},
|
||||
"decision_needed": false,
|
||||
"decisions": [
|
||||
{
|
||||
"decision": {
|
||||
"files": "nec"
|
||||
},
|
||||
"effective": null,
|
||||
"source": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
}
|
||||
}
|
||||
],
|
||||
"effective": null,
|
||||
"excluded_card": "0",
|
||||
"name": "Sam",
|
||||
"not_reportable": "0",
|
||||
"paid": "0",
|
||||
"reportable": false,
|
||||
"status": "under_threshold",
|
||||
"tin_on_file": true,
|
||||
"undetermined": "0",
|
||||
"vendor_id": 3
|
||||
}
|
||||
],
|
||||
"year": 2025
|
||||
},
|
||||
"2026": {
|
||||
"excluded_card_payments": [
|
||||
{
|
||||
"amount": "5000",
|
||||
"date": "2026-04-01",
|
||||
"entry_id": 8,
|
||||
"instrument": null,
|
||||
"vendor_id": 3
|
||||
}
|
||||
],
|
||||
"other_receipts": [],
|
||||
"threshold": "2000",
|
||||
"through": null,
|
||||
"undetermined_payments": [],
|
||||
"unresolved": [],
|
||||
"untagged_payments": [
|
||||
10
|
||||
],
|
||||
"vendors": [
|
||||
{
|
||||
"decided": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
},
|
||||
"decision": {
|
||||
"files": "misc"
|
||||
},
|
||||
"decision_needed": false,
|
||||
"decisions": [
|
||||
{
|
||||
"decision": {
|
||||
"files": "misc"
|
||||
},
|
||||
"effective": null,
|
||||
"source": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
}
|
||||
}
|
||||
],
|
||||
"effective": null,
|
||||
"excluded_card": "0",
|
||||
"name": "Ace Rentals",
|
||||
"not_reportable": "0",
|
||||
"paid": "1200",
|
||||
"reportable": false,
|
||||
"status": "under_threshold",
|
||||
"tin_on_file": false,
|
||||
"undetermined": "0",
|
||||
"vendor_id": 2
|
||||
},
|
||||
{
|
||||
"decided": null,
|
||||
"decision": "undetermined",
|
||||
"decision_needed": true,
|
||||
"decisions": [],
|
||||
"effective": null,
|
||||
"excluded_card": "0",
|
||||
"name": "Bigco",
|
||||
"not_reportable": "0",
|
||||
"paid": "9000",
|
||||
"reportable": false,
|
||||
"status": "undetermined",
|
||||
"tin_on_file": false,
|
||||
"undetermined": "0",
|
||||
"vendor_id": 4
|
||||
},
|
||||
{
|
||||
"decided": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
},
|
||||
"decision": {
|
||||
"files": "nec"
|
||||
},
|
||||
"decision_needed": false,
|
||||
"decisions": [
|
||||
{
|
||||
"decision": {
|
||||
"files": "nec"
|
||||
},
|
||||
"effective": null,
|
||||
"source": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
}
|
||||
}
|
||||
],
|
||||
"effective": null,
|
||||
"excluded_card": "0",
|
||||
"name": "Dana",
|
||||
"not_reportable": "0",
|
||||
"paid": "2200",
|
||||
"reportable": true,
|
||||
"status": "reportable",
|
||||
"tin_on_file": true,
|
||||
"undetermined": "0",
|
||||
"vendor_id": 1
|
||||
},
|
||||
{
|
||||
"decided": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
},
|
||||
"decision": {
|
||||
"files": "nec"
|
||||
},
|
||||
"decision_needed": false,
|
||||
"decisions": [
|
||||
{
|
||||
"decision": {
|
||||
"files": "nec"
|
||||
},
|
||||
"effective": null,
|
||||
"source": {
|
||||
"decided_by": "Riley Chen",
|
||||
"decided_on": "2026-01-05"
|
||||
}
|
||||
}
|
||||
],
|
||||
"effective": null,
|
||||
"excluded_card": "5000",
|
||||
"name": "Sam",
|
||||
"not_reportable": "0",
|
||||
"paid": "0",
|
||||
"reportable": false,
|
||||
"status": "under_threshold",
|
||||
"tin_on_file": true,
|
||||
"undetermined": "0",
|
||||
"vendor_id": 3
|
||||
}
|
||||
],
|
||||
"year": 2026
|
||||
}
|
||||
}
|
||||
@@ -811,3 +811,94 @@ fn a_month_that_rounds_to_nothing_is_never_a_posting() {
|
||||
assert_eq!(s.next().unwrap(), Some(d(3, 31)));
|
||||
assert_eq!(s.remaining().unwrap(), dec("0.01"));
|
||||
}
|
||||
|
||||
/// The plan as JSON: one object per period, in plan order.
|
||||
fn plan_values(plan: Vec<(NaiveDate, Decimal)>) -> Vec<serde_json::Value> {
|
||||
plan.into_iter()
|
||||
.map(|(date, amount)| serde_json::json!({"date": date, "amount": amount}))
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Golden (oracle Layer 1): the two hand-verified amortization fixtures,
|
||||
/// every period, rounding remainder and running balance recomputed in
|
||||
/// plan/golden-worksheets/amortization-plans.md before this test was run.
|
||||
/// A year of prepaid insurance at 100.00 a month (three months posted,
|
||||
/// 900.00 left) and three months of deferred revenue at 333.33, 333.33,
|
||||
/// 333.34 (the last period takes the rounding, so the three sum to
|
||||
/// 1,000.00 exactly: rules.md B-16).
|
||||
#[test]
|
||||
fn golden_amortization_plans() {
|
||||
let mut b = books();
|
||||
post(&mut b.l, d(3, 1), b.prepaid, b.cash, "1200");
|
||||
let prepaid_id =
|
||||
b.l.register_schedule(NewSchedule {
|
||||
description: "Liability insurance".into(),
|
||||
kind: ScheduleKind::PrepaidExpense,
|
||||
total: usd("1200"),
|
||||
start: d(3, 1),
|
||||
months: 12,
|
||||
balance_account: b.prepaid,
|
||||
pl_account: b.insurance,
|
||||
convention: ledger_core::ScheduleConvention::MonthlyEven,
|
||||
})
|
||||
.unwrap();
|
||||
for (month, _) in b.l.get_schedule(prepaid_id).unwrap().due(d(5, 31)).unwrap() {
|
||||
b.l.post_schedule_month(prepaid_id, month).unwrap();
|
||||
}
|
||||
let prepaid_schedule = b.l.get_schedule(prepaid_id).unwrap().clone();
|
||||
let prepaid = serde_json::json!({
|
||||
"description": prepaid_schedule.description,
|
||||
"kind": prepaid_schedule.kind,
|
||||
"total": prepaid_schedule.total.amount,
|
||||
"currency": prepaid_schedule.total.currency.code(),
|
||||
"start": prepaid_schedule.start,
|
||||
"months": prepaid_schedule.months,
|
||||
"posted": prepaid_schedule.posted,
|
||||
"plan": plan_values(prepaid_schedule.plan().unwrap()),
|
||||
"remaining": prepaid_schedule.remaining().unwrap(),
|
||||
"profit_and_loss": profit_and_loss_for_period(&b.l, d(3, 1), d(5, 31), None).unwrap(),
|
||||
"balance_sheet": balance_sheet_as_of(&b.l, d(5, 31)).unwrap(),
|
||||
});
|
||||
|
||||
let mut b = books();
|
||||
post(&mut b.l, d(1, 1), b.cash, b.deferred, "1000");
|
||||
let deferred_id =
|
||||
b.l.register_schedule(NewSchedule {
|
||||
description: "Quarterly plan, Acme".into(),
|
||||
kind: ScheduleKind::DeferredRevenue,
|
||||
total: usd("1000"),
|
||||
start: d(1, 1),
|
||||
months: 3,
|
||||
balance_account: b.deferred,
|
||||
pl_account: b.revenue,
|
||||
convention: ledger_core::ScheduleConvention::MonthlyEven,
|
||||
})
|
||||
.unwrap();
|
||||
for (month, _) in
|
||||
b.l.get_schedule(deferred_id)
|
||||
.unwrap()
|
||||
.due(d(12, 31))
|
||||
.unwrap()
|
||||
{
|
||||
b.l.post_schedule_month(deferred_id, month).unwrap();
|
||||
}
|
||||
let deferred_schedule = b.l.get_schedule(deferred_id).unwrap().clone();
|
||||
let deferred = serde_json::json!({
|
||||
"description": deferred_schedule.description,
|
||||
"kind": deferred_schedule.kind,
|
||||
"total": deferred_schedule.total.amount,
|
||||
"currency": deferred_schedule.total.currency.code(),
|
||||
"start": deferred_schedule.start,
|
||||
"months": deferred_schedule.months,
|
||||
"posted": deferred_schedule.posted,
|
||||
"plan": plan_values(deferred_schedule.plan().unwrap()),
|
||||
"remaining": deferred_schedule.remaining().unwrap(),
|
||||
"profit_and_loss": profit_and_loss_for_period(&b.l, d(1, 1), d(3, 31), None).unwrap(),
|
||||
"balance_sheet": balance_sheet_as_of(&b.l, d(3, 31)).unwrap(),
|
||||
});
|
||||
|
||||
let got = serde_json::json!({"prepaid": prepaid, "deferred": deferred});
|
||||
let want: serde_json::Value =
|
||||
serde_json::from_str(include_str!("golden/amortization_plans.json")).unwrap();
|
||||
assert_eq!(got, want);
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
# Golden worksheet: the 1099 vendor worksheet
|
||||
|
||||
Golden: `crates/ledger-core/tests/golden/form1099_worksheet.json`
|
||||
Test: `golden_1099_worksheet` in `crates/ledger-core/tests/form1099.rs`
|
||||
Fixture: `books()` in that test file (the existing hand-verified fixture:
|
||||
bill payments, a card charge, a reversal, a year boundary), **plus** one
|
||||
step the golden test itself takes: it records `2100 Credit Card` as a
|
||||
business-card payment method ("Harbor Visa") before building the reports
|
||||
(section "With the card recorded"). `books()` is unchanged; other tests
|
||||
rely on its unrecorded card.
|
||||
Rules: `docs/spec/rules.md` B-19 (thresholds, payment methods, decisions,
|
||||
status), and D-40 as B-19 records it.
|
||||
|
||||
Every number below was worked from the fixture's entries before the report
|
||||
was serialized. The report's own buckets are `paid` (counts),
|
||||
`excluded_card` (a card or payment network paid: the processor's 1099-K),
|
||||
`undetermined` (a financing liability with no method recorded), and
|
||||
`not_reportable` (paid while the vendor was decided not reportable).
|
||||
|
||||
## The accounts and the payments
|
||||
|
||||
Chart: `1000 Bank` (asset, the cash account), `2100 Credit Card`
|
||||
(liability; in `books()` **no** business-card payment method records it and
|
||||
it is not a financing account; the golden test records it, see "With the
|
||||
card recorded"), `6000 Contract Labor` and `6600 Rent` (expenses).
|
||||
`create_bill` adds its control accounts (general expenses, payables); they
|
||||
are not cash and no payment comes out of them.
|
||||
|
||||
| # | Date | Entry | Vendor | Dr | Cr | Amount |
|
||||
|---|---|---|---|---|---|---|
|
||||
| 1 | 2026-03-01 | Bill 1 (due 2026-03-31) | Dana | general expenses | payables | 1,500 |
|
||||
| 2 | 2026-03-20 | pay Bill 1 from the bank | Dana | payables | 1000 Bank | 1,500 |
|
||||
| 3 | 2026-06-01 | payment | Dana | 6000 Contract Labor | 1000 Bank | 700 |
|
||||
| 4 | 2025-12-30 | payment | Dana | 6000 Contract Labor | 1000 Bank | 300 |
|
||||
| 5 | 2026-01-01 | payment | Ace Rentals | 6600 Rent | 1000 Bank | 1,200 |
|
||||
| 6 | 2026-02-01 | payment | Ace Rentals | 6600 Rent | 1000 Bank | 1,200 |
|
||||
| 7 | 2026-02-02 | reversal of #6 (duplicate) | Ace Rentals | 1000 Bank | 6600 Rent | 1,200 |
|
||||
| 8 | 2026-04-01 | payment | Sam | 6000 Contract Labor | 2100 Credit Card | 5,000 |
|
||||
| 9 | 2026-05-01 | payment | Bigco | 6000 Contract Labor | 1000 Bank | 9,000 |
|
||||
| 10 | 2026-07-01 | payment, no vendor tag | — | 6000 Contract Labor | 1000 Bank | 50 |
|
||||
|
||||
Decisions, each from the beginning (`effective: null`), decided by Riley
|
||||
Chen on 2026-01-05: Dana 1099-NEC with a W-9, Ace Rentals 1099-MISC
|
||||
without one, Sam 1099-NEC with a W-9. Bigco is never decided.
|
||||
|
||||
## Buckets, by entry
|
||||
|
||||
A line pays only out of a source B-19 names. `1000 Bank` is a cash
|
||||
account, so a bank credit counts (presumed check/ACH/transfer, D-40).
|
||||
`2100 Credit Card` is not a cash account and not a financing account.
|
||||
(In `books()` alone, with no method recording it, it would be "anything
|
||||
else" in B-19's table and the 5,000 at #8 would be in no bucket; that
|
||||
unrecorded-card analysis is kept as a note under "With the card recorded"
|
||||
and is why the golden records the card: the unrecorded case exercises no
|
||||
`excluded_card` figure at all.) With the card recorded (below), #8 is in
|
||||
the **card** bucket. A bill is not a payment until it is paid
|
||||
(B-19), so #1 counts nothing and #2 counts 1,500. A reversal nets on its
|
||||
original's side, so #7 cancels #6.
|
||||
|
||||
Dana:
|
||||
- 2026: #2 1,500 (bank, counts) + #3 700 (bank, counts) = **2,200**.
|
||||
#4 is dated 2025-12-30, outside the 2026 window.
|
||||
- 2025: #4 **300**.
|
||||
|
||||
Ace Rentals:
|
||||
- 2026: #5 1,200 counts; #6 (+1,200) and #7 (−1,200) net **0**.
|
||||
Total **1,200**.
|
||||
- 2025: no payments → 0.
|
||||
|
||||
Sam:
|
||||
- 2026: #8 5,000 out of 2100, a recorded company card's account →
|
||||
`excluded_card` **5,000**, `paid` 0 (see "With the card recorded").
|
||||
- 2025: no payments → 0.
|
||||
|
||||
Bigco:
|
||||
- 2026: #9 9,000 out of the bank, counts, and Bigco is undecided for the
|
||||
whole year → it lands in the undecided paid side (`paid`), with
|
||||
`decision_needed` true. **9,000**.
|
||||
- 2025: no payments, no decision → not on the worksheet.
|
||||
|
||||
## Status, per B-19
|
||||
|
||||
T is the year's threshold: 600 for 2025, 2,000 for 2026 (26 U.S.C.
|
||||
§6041(a), §6041A(a)(2), Pub. L. 119-21 §70433; payments after 2025-12-31).
|
||||
|
||||
- Dana 2026: decided for a 1099, nothing undecided, lo(F) = 2,200 ≥ 2,000
|
||||
→ **reportable**. A W-9 is on file.
|
||||
- Ace Rentals 2026: decided for a 1099, lo(F) = hi(F) = 1,200 < 2,000
|
||||
→ **under_threshold**.
|
||||
- Sam 2026: decided for a 1099, F = 0, U = 0 (the 5,000 is in the card
|
||||
bucket, outside both), no payment while not reportable
|
||||
→ **under_threshold** (a card charge is a property of the payment, never
|
||||
the vendor's reason, B-19).
|
||||
- Bigco 2026: undecided money; hi(F) + max(hi(U), 0) = 0 + 9,000 ≥ 2,000
|
||||
→ **undetermined**, `decision_needed` true, `reportable` false. Absent a
|
||||
decision it is never reportable (defect 18).
|
||||
- 2025: Dana 300 < 600 → **under_threshold**. Ace Rentals and Sam are on
|
||||
the 2025 worksheet with 0 because each has a decision for a 1099 in
|
||||
force during 2025 (a decision from the beginning; B-19's list of "every
|
||||
vendor with a decision for a 1099 in force during the year"), both
|
||||
**under_threshold**. Bigco has neither a decision nor a figure in 2025,
|
||||
so it is absent.
|
||||
|
||||
## Lists
|
||||
|
||||
- 2026 `untagged_payments`: [10], the 50.00 contract-labor payment with no
|
||||
vendor tag (B-19's "quieter note").
|
||||
- 2026 `excluded_card_payments`: [#8] — one `Payment1099`: entry 8, date
|
||||
2026-04-01, vendor Sam (3), amount 5,000, `instrument` null (the entry
|
||||
is untagged; a company card's account is excluded with or without a tag,
|
||||
B-19's table, last-but-one row; the existing test
|
||||
`card_account_payments_are_listed_not_dropped` reports `None` the same
|
||||
way).
|
||||
- 2026 `undetermined_payments`: empty — no payment came through a
|
||||
financing liability with its method unrecorded.
|
||||
- `other_receipts`, `unresolved`: empty.
|
||||
- 2025 has no card, undetermined, other-receipt, unresolved or untagged
|
||||
entries.
|
||||
|
||||
## With the card recorded
|
||||
|
||||
The golden test calls `add_instrument(BusinessCard, "Harbor Visa",
|
||||
Some("0042"), None, <2100>)` before the reports. Worked from B-19's table
|
||||
for #8 (Dr 6000 5,000 / Cr 2100 5,000, vendor Sam, no method tag), line
|
||||
by line, first match wins:
|
||||
|
||||
- Cr 2100 (−5,000 of credit): the entry has no method, so rows 1 and 2
|
||||
(the *entry's* method) do not match; 2100 is not a cash account (row 3)
|
||||
and not a financing account nor a member/platform method's account
|
||||
(row 4); it **is** a business_card method's account (row 5) → **card
|
||||
(excluded)**, 5,000.
|
||||
- Dr 6000: an expense → "anything else", no payment line.
|
||||
- Net of the entry's buckets: card 5,000, nothing else; no signs differ,
|
||||
so nothing goes to undetermined.
|
||||
|
||||
Effect on the reports (and nothing else moves):
|
||||
|
||||
| Report | Field | Unrecorded | Recorded |
|
||||
|---|---|---|---|
|
||||
| 2026 | Sam `excluded_card` | 0 | **5,000** |
|
||||
| 2026 | `excluded_card_payments` | [] | **[#8 5,000, instrument null]** |
|
||||
| 2026 | Sam `paid`, `undetermined`, `not_reportable` | 0, 0, 0 | 0, 0, 0 |
|
||||
| 2026 | Sam `status`, `reportable`, `decision_needed` | under_threshold, false, false | unchanged: F = 0, U = 0 |
|
||||
| 2025 | everything | — | unchanged (#8 is dated 2026-04-01) |
|
||||
|
||||
Why nothing else moves: every other payment is out of `1000 Bank`, a cash
|
||||
account, whose rule (row 3) does not depend on the card's method; #10 is
|
||||
untagged and from the bank, so `untagged_payments` stays [10]; the card
|
||||
method adds no vendor line and no list entry of its own; the instrument's
|
||||
id appears in the report only through an entry tagged with it, and none
|
||||
is.
|
||||
|
||||
The unrecorded case (the earlier version of this golden) is kept as a note:
|
||||
with no method recording 2100, #8 is "anything else": `paid` 0,
|
||||
`excluded_card` 0, the list empty, Sam under_threshold. That is correct per
|
||||
B-19 ("Cards and party totals") but it exercises no card figure, so the
|
||||
parity row's "card exclusion" claim was not covered. The unrecorded card's
|
||||
charge counting for no one is still pinned by
|
||||
`cash_paid_per_vendor_and_who_is_reportable` (Sam `paid` 0, and the
|
||||
exclusion buckets 0 on the unrecorded `books()`) and by the first half of
|
||||
`card_account_payments_are_listed_not_dropped`.
|
||||
|
||||
## Fields fixed by the fixture
|
||||
|
||||
Names sort by name then vendor id: Ace Rentals (2), Bigco (4), Dana (1),
|
||||
Sam (3) in 2026; Ace (2), Dana (1), Sam (3) in 2025. Each `decisions` list
|
||||
is the one decision from the beginning, with its source (Riley Chen,
|
||||
2026-01-05). `tin_on_file`: Dana true, Sam true, Ace false, Bigco false.
|
||||
`through` is null (the whole calendar year).
|
||||
@@ -0,0 +1,100 @@
|
||||
# Golden worksheet: prepaid expense and deferred revenue amortization
|
||||
|
||||
Golden: `crates/ledger-core/tests/golden/amortization_plans.json`
|
||||
Test: `golden_amortization_plans` in `crates/ledger-core/tests/schedules.rs`
|
||||
Fixture: the existing `books()` fixture and the two hand-verified setups in
|
||||
`a_prepaid_expense_is_expensed_month_by_month` and
|
||||
`deferred_revenue_is_earned_to_the_cent` (same accounts, same totals, same
|
||||
conventions).
|
||||
Rules: `docs/spec/rules.md` B-16 (prepaids recognized over the period
|
||||
benefited, deferred revenue as it is earned; equal-months schedules, the
|
||||
last month absorbing rounding), with B-15's rounding discipline, and D-37
|
||||
(monthly_even schedules start on the 1st).
|
||||
|
||||
The schedules in this fixture ask explicitly for `monthly_even` (the
|
||||
convention of every schedule registered before P3), so the plan is
|
||||
`amortization_plan`: each period is `total ÷ months` rounded to the cent,
|
||||
and the last period is `total − each × (months − 1)`, so the plan sums to
|
||||
the total exactly.
|
||||
|
||||
## Prepaid expense: a year of insurance from 2026-03-01
|
||||
|
||||
Entry: 2026-03-01, Dr 1300 Prepaid Expenses 1,200 / Cr 1000 Cash 1,200.
|
||||
|
||||
Plan, 12 equal months (monthly_even; the 1st is the start):
|
||||
|
||||
- Each of the first 11 months: 1,200 ÷ 12 = **100.00**.
|
||||
- Last month: 1,200 − 100.00 × 11 = 1,200 − 1,100 = **100.00** (no
|
||||
remainder here; the division is exact).
|
||||
|
||||
| # | Period | Amount | Cumulative | Remaining |
|
||||
|---|---|---|---|---|
|
||||
| 1 | 2026-03-31 | 100 | 100 | 1,100 |
|
||||
| 2 | 2026-04-30 | 100 | 200 | 1,000 |
|
||||
| 3 | 2026-05-31 | 100 | 300 | 900 |
|
||||
| 4 | 2026-06-30 | 100 | 400 | 800 |
|
||||
| 5 | 2026-07-31 | 100 | 500 | 700 |
|
||||
| 6 | 2026-08-31 | 100 | 600 | 600 |
|
||||
| 7 | 2026-09-30 | 100 | 700 | 500 |
|
||||
| 8 | 2026-10-31 | 100 | 800 | 400 |
|
||||
| 9 | 2026-11-30 | 100 | 900 | 300 |
|
||||
| 10 | 2026-12-31 | 100 | 1,000 | 200 |
|
||||
| 11 | 2027-01-31 | 100 | 1,100 | 100 |
|
||||
| 12 | 2027-02-28 | 100 | 1,200 | 0 |
|
||||
|
||||
The fixture posts the first three months (March, April, May). Remaining =
|
||||
1,200 − 300 = **900**. `posted` is those three month ends.
|
||||
|
||||
Postings: each month Dr 6300 Insurance / Cr 1300 Prepaid Expenses, 100.
|
||||
|
||||
Profit and loss, 2026-03-01 through 2026-05-31: insurance expense
|
||||
100 + 100 + 100 = **300**; revenue 0.
|
||||
|
||||
Balance sheet at 2026-05-31:
|
||||
- Cash: 0 − 1,200 = **−1,200** (the fixture pays the premium from cash and
|
||||
has no other entries).
|
||||
- Prepaid Expenses: 1,200 − 300 = **900**.
|
||||
- Total assets: −1,200 + 900 = **−300**.
|
||||
- Liabilities: **0**.
|
||||
- Current earnings: revenue 0 − expense 300 = **−300**; equity **−300**.
|
||||
- −300 = 0 + (−300): balanced.
|
||||
|
||||
## Deferred revenue: three months from 2026-01-01
|
||||
|
||||
Entry: 2026-01-01, Dr 1000 Cash 1,000 / Cr 2400 Deferred Revenue 1,000.
|
||||
|
||||
Plan, 3 equal months:
|
||||
|
||||
- Each of the first 2 months: 1,000 ÷ 3 = 333.333… → **333.33**.
|
||||
- Last month: 1,000 − 333.33 × 2 = 1,000 − 666.66 = **333.34** (the
|
||||
rounding remainder, 0.01, is absorbed by the last period).
|
||||
- Sum: 333.33 + 333.33 + 333.34 = **1,000.00** exactly.
|
||||
|
||||
| # | Period | Amount | Cumulative | Remaining |
|
||||
|---|---|---|---|---|
|
||||
| 1 | 2026-01-31 | 333.33 | 333.33 | 666.67 |
|
||||
| 2 | 2026-02-28 | 333.33 | 666.66 | 333.34 |
|
||||
| 3 | 2026-03-31 | 333.34 | 1,000.00 | 0 |
|
||||
|
||||
All three months are posted, so remaining = **0**. Postings: each month
|
||||
Dr 2400 Deferred Revenue / Cr 4000 Subscription Revenue.
|
||||
|
||||
Profit and loss, 2026-01-01 through 2026-03-31: revenue 333.33 + 333.33 +
|
||||
333.34 = **1,000.00**; expenses 0.
|
||||
|
||||
Balance sheet at 2026-03-31:
|
||||
- Cash **1,000**.
|
||||
- Liabilities: the deferred revenue is fully earned → **0**.
|
||||
- Current earnings **1,000.00**; equity **1,000.00**.
|
||||
- 1,000 = 0 + 1,000.00: balanced.
|
||||
|
||||
## Notes on the serialized figures
|
||||
|
||||
- The decimal strings keep the arithmetic scale: the prepaid plan divides
|
||||
exactly, so its amounts print as `"100"`, `"300"`, `"900"`, `"1200"`;
|
||||
the deferred plan carries cents, so its amounts print as `"333.33"`,
|
||||
`"333.34"`, `"1000.00"`, and its remaining as `"0"`.
|
||||
- `total` is the schedule's `Money.amount`; `currency` is the code (USD),
|
||||
not `Money`'s three-byte serde form, so the golden stays readable.
|
||||
- `posted` is the schedule's posted month ends; `plan` is every period,
|
||||
posted or not, in order.
|
||||
Reference in new issue
Block a user