Cotton code
2221 lines · 57.8 KB · JSONRaw
{  "runs": [    {      "name": "a bank's debit lowers and its credit raises the balance",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": 6966100,        "known_balance_on": "2026-10-01",        "statements": []      },      "rows": [        {          "id": "d",          "day": "2026-10-04",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 190800,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-10-05",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 10000,          "direction": "in",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 6785300,        "rows": {          "d": {            "balance_before_minor": 6966100,            "balance_after_minor": 6775300,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 6775300,            "balance_after_minor": 6785300,            "balance_state": "ok"          }        }      }    },    {      "name": "a card's purchase raises what is owed and a payment lowers it",      "today": "2026-10-27",      "account": {        "kind": "credit_card",        "known_balance_minor": 6966100,        "known_balance_on": "2026-10-01",        "statements": []      },      "rows": [        {          "id": "d",          "day": "2026-10-04",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 190800,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-10-05",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 10000,          "direction": "in",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 7146900,        "rows": {          "d": {            "balance_before_minor": 6966100,            "balance_after_minor": 7156900,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 7156900,            "balance_after_minor": 7146900,            "balance_state": "ok"          }        }      }    },    {      "name": "a card repayment is money in and reduces what is owed",      "today": "2026-10-27",      "account": {        "kind": "credit_card",        "known_balance_minor": 6966100,        "known_balance_on": "2026-10-01",        "statements": []      },      "rows": [        {          "id": "p",          "day": "2026-10-06",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 190800,          "direction": "in",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 6775300,        "rows": {          "p": {            "balance_before_minor": 6966100,            "balance_after_minor": 6775300,            "balance_state": "ok"          }        }      }    },    {      "name": "a loan runs with bank arithmetic, and owing is never overdrawn",      "today": "2026-10-27",      "account": {        "kind": "loan",        "known_balance_minor": 10000,        "known_balance_on": "2026-03-01",        "statements": []      },      "rows": [        {          "id": "pay",          "day": "2026-03-02",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 2000,          "direction": "out",          "expected": false        },        {          "id": "big",          "day": "2026-03-05",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 9000,          "direction": "out",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": -1000,        "rows": {          "pay": {            "balance_before_minor": 10000,            "balance_after_minor": 8000,            "balance_state": "ok"          },          "big": {            "balance_before_minor": 8000,            "balance_after_minor": -1000,            "balance_state": "ok"          }        }      }    },    {      "name": "walks forward and back from a balance a statement printed",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": null,        "known_balance_on": null,        "statements": []      },      "rows": [        {          "id": "a",          "day": "2026-09-01",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 1000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-09-03",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 500000,          "direction": "in",          "expected": false        },        {          "id": "c",          "day": "2026-09-05",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 250000,          "direction": "out",          "expected": false        },        {          "id": "d",          "day": "2026-09-09",          "created_at": "2026-01-01T00:00:03Z",          "line_no": null,          "amount_minor": 50000,          "direction": "out",          "expected": false        }      ],      "printed": {        "b": 600000      },      "expect": {        "balance": 300000,        "rows": {          "a": {            "balance_before_minor": 99000,            "balance_after_minor": 100000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 100000,            "balance_after_minor": 600000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 600000,            "balance_after_minor": 350000,            "balance_state": "ok"          },          "d": {            "balance_before_minor": 350000,            "balance_after_minor": 300000,            "balance_state": "ok"          }        }      }    },    {      "name": "the account's known balance at the end of its day beats an earlier printed one",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": 70000,        "known_balance_on": "2026-09-10",        "statements": []      },      "rows": [        {          "id": "a",          "day": "2026-09-03",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 500000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-09-05",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 1000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-20",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 2000,          "direction": "out",          "expected": false        }      ],      "printed": {        "a": 600000      },      "expect": {        "balance": 68000,        "rows": {          "a": {            "balance_before_minor": -429000,            "balance_after_minor": 71000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 71000,            "balance_after_minor": 70000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 70000,            "balance_after_minor": 68000,            "balance_state": "ok"          }        }      }    },    {      "name": "a known balance before every row is the balance the first row starts from",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": 70000,        "known_balance_on": "2026-08-31",        "statements": []      },      "rows": [        {          "id": "a",          "day": "2026-09-03",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 500000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-09-05",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 1000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-20",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 2000,          "direction": "out",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 567000,        "rows": {          "a": {            "balance_before_minor": 70000,            "balance_after_minor": 570000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 570000,            "balance_after_minor": 569000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 569000,            "balance_after_minor": 567000,            "balance_state": "ok"          }        }      }    },    {      "name": "the coming rows run on from today's balance, an overdue expectation first",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": 100000,        "known_balance_on": "2026-10-01",        "statements": []      },      "rows": [        {          "id": "later",          "day": "2026-12-01",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 5000,          "direction": "in",          "expected": true        },        {          "id": "dated",          "day": "2026-11-15",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 2000,          "direction": "out",          "expected": false        },        {          "id": "happened",          "day": "2026-10-20",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 10000,          "direction": "out",          "expected": false        },        {          "id": "overdue",          "day": "2026-10-01",          "created_at": "2026-01-01T00:00:03Z",          "line_no": null,          "amount_minor": 3000,          "direction": "out",          "expected": true        }      ],      "printed": {},      "expect": {        "balance": 90000,        "rows": {          "later": {            "balance_before_minor": 85000,            "balance_after_minor": 90000,            "balance_state": "ok"          },          "dated": {            "balance_before_minor": 87000,            "balance_after_minor": 85000,            "balance_state": "ok"          },          "happened": {            "balance_before_minor": 100000,            "balance_after_minor": 90000,            "balance_state": "ok"          },          "overdue": {            "balance_before_minor": 90000,            "balance_after_minor": 87000,            "balance_state": "ok"          }        }      }    },    {      "name": "below zero is overdrawn, or recovers when that month ends back at zero or above",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": 1000,        "known_balance_on": "2026-10-27",        "statements": []      },      "rows": [        {          "id": "n2",          "day": "2026-11-02",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 5000,          "direction": "out",          "expected": true        },        {          "id": "n20",          "day": "2026-11-20",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 8000,          "direction": "in",          "expected": true        },        {          "id": "d5",          "day": "2026-12-05",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 9000,          "direction": "out",          "expected": true        },        {          "id": "j2",          "day": "2027-01-02",          "created_at": "2026-01-01T00:00:03Z",          "line_no": null,          "amount_minor": 1000,          "direction": "in",          "expected": true        }      ],      "printed": {},      "expect": {        "balance": 1000,        "rows": {          "n2": {            "balance_before_minor": 1000,            "balance_after_minor": -4000,            "balance_state": "recovers"          },          "n20": {            "balance_before_minor": -4000,            "balance_after_minor": 4000,            "balance_state": "ok"          },          "d5": {            "balance_before_minor": 4000,            "balance_after_minor": -5000,            "balance_state": "overdrawn"          },          "j2": {            "balance_before_minor": -5000,            "balance_after_minor": -4000,            "balance_state": "overdrawn"          }        }      }    },    {      "name": "a card's balance is what is owed: money out raises it, and owing is never overdrawn",      "today": "2026-10-27",      "account": {        "kind": "credit_card",        "known_balance_minor": 2000,        "known_balance_on": "2026-10-01",        "statements": []      },      "rows": [        {          "id": "spend",          "day": "2026-10-02",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 3000,          "direction": "out",          "expected": false        },        {          "id": "pay",          "day": "2026-10-05",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 10000,          "direction": "in",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": -5000,        "rows": {          "spend": {            "balance_before_minor": 2000,            "balance_after_minor": 5000,            "balance_state": "ok"          },          "pay": {            "balance_before_minor": 5000,            "balance_after_minor": -5000,            "balance_state": "ok"          }        }      }    },    {      "name": "a statement's closing balance anchors the end of its period, and the run walks back through it",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": null,        "known_balance_on": null,        "statements": [          {            "period_start": "2026-08-01",            "opening_balance_minor": null,            "period_end": "2026-08-31",            "closing_balance_minor": 75000          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-08-02",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 30000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-08-20",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 5000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-04",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 1000,          "direction": "out",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 74000,        "rows": {          "a": {            "balance_before_minor": 50000,            "balance_after_minor": 80000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 80000,            "balance_after_minor": 75000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 75000,            "balance_after_minor": 74000,            "balance_state": "ok"          }        }      }    },    {      "name": "a statement's opening balance anchors the start of its period, before that day's rows",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": null,        "known_balance_on": null,        "statements": [          {            "period_start": "2026-08-01",            "opening_balance_minor": 50000,            "period_end": "2026-08-31",            "closing_balance_minor": null          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-08-01",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 30000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-08-20",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 5000,          "direction": "out",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 75000,        "rows": {          "a": {            "balance_before_minor": 50000,            "balance_after_minor": 80000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 80000,            "balance_after_minor": 75000,            "balance_state": "ok"          }        }      }    },    {      "name": "a closing balance beats an older balance a line printed",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": null,        "known_balance_on": null,        "statements": [          {            "period_start": "2026-08-01",            "opening_balance_minor": null,            "period_end": "2026-08-31",            "closing_balance_minor": 90000          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-08-10",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 30000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-08-20",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 5000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-03",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 2000,          "direction": "out",          "expected": false        }      ],      "printed": {        "a": 10      },      "expect": {        "balance": 88000,        "rows": {          "a": {            "balance_before_minor": 65000,            "balance_after_minor": 95000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 95000,            "balance_after_minor": 90000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 90000,            "balance_after_minor": 88000,            "balance_state": "ok"          }        }      }    },    {      "name": "a line printed on the closing's own day loses to it",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": null,        "known_balance_on": null,        "statements": [          {            "period_start": "2026-08-01",            "opening_balance_minor": null,            "period_end": "2026-08-20",            "closing_balance_minor": 90000          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-08-10",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 30000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-08-20",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 5000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-03",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 2000,          "direction": "out",          "expected": false        }      ],      "printed": {        "b": 10      },      "expect": {        "balance": 88000,        "rows": {          "a": {            "balance_before_minor": 65000,            "balance_after_minor": 95000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 95000,            "balance_after_minor": 90000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 90000,            "balance_after_minor": 88000,            "balance_state": "ok"          }        }      }    },    {      "name": "a line printed after the closing beats it",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": null,        "known_balance_on": null,        "statements": [          {            "period_start": "2026-08-01",            "opening_balance_minor": null,            "period_end": "2026-08-31",            "closing_balance_minor": 90000          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-08-10",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 30000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-08-20",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 5000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-03",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 2000,          "direction": "out",          "expected": false        }      ],      "printed": {        "c": 60000      },      "expect": {        "balance": 60000,        "rows": {          "a": {            "balance_before_minor": 37000,            "balance_after_minor": 67000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 67000,            "balance_after_minor": 62000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 62000,            "balance_after_minor": 60000,            "balance_state": "ok"          }        }      }    },    {      "name": "a newer known balance beats a closing balance",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": 20000,        "known_balance_on": "2026-09-10",        "statements": [          {            "period_start": "2026-08-01",            "opening_balance_minor": 40000,            "period_end": "2026-08-31",            "closing_balance_minor": 70000          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-08-10",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 30000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-09-05",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 5000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-20",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 1000,          "direction": "out",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 19000,        "rows": {          "a": {            "balance_before_minor": -5000,            "balance_after_minor": 25000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 25000,            "balance_after_minor": 20000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 20000,            "balance_after_minor": 19000,            "balance_state": "ok"          }        }      }    },    {      "name": "a known balance on the closing's own day beats it",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": 20000,        "known_balance_on": "2026-08-31",        "statements": [          {            "period_start": "2026-08-01",            "opening_balance_minor": 40000,            "period_end": "2026-08-31",            "closing_balance_minor": 70000          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-08-10",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 30000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-09-05",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 5000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-20",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 1000,          "direction": "out",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 14000,        "rows": {          "a": {            "balance_before_minor": -10000,            "balance_after_minor": 20000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 20000,            "balance_after_minor": 15000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 15000,            "balance_after_minor": 14000,            "balance_state": "ok"          }        }      }    },    {      "name": "an older known balance loses to the closing",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": 20000,        "known_balance_on": "2026-08-15",        "statements": [          {            "period_start": "2026-08-01",            "opening_balance_minor": 40000,            "period_end": "2026-08-31",            "closing_balance_minor": 70000          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-08-10",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 30000,          "direction": "in",          "expected": false        },        {          "id": "b",          "day": "2026-09-05",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 5000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-20",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 1000,          "direction": "out",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 64000,        "rows": {          "a": {            "balance_before_minor": 40000,            "balance_after_minor": 70000,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 70000,            "balance_after_minor": 65000,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 65000,            "balance_after_minor": 64000,            "balance_state": "ok"          }        }      }    },    {      "name": "the later period's closing of two statements wins, July then August",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": null,        "known_balance_on": null,        "statements": [          {            "period_start": "2026-07-01",            "opening_balance_minor": 10000,            "period_end": "2026-07-31",            "closing_balance_minor": 9000          },          {            "period_start": "2026-08-01",            "opening_balance_minor": 9500,            "period_end": "2026-08-31",            "closing_balance_minor": 7500          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-07-10",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 1000,          "direction": "out",          "expected": false        },        {          "id": "b",          "day": "2026-08-10",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 2000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-10",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 3000,          "direction": "in",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 10500,        "rows": {          "a": {            "balance_before_minor": 10500,            "balance_after_minor": 9500,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 9500,            "balance_after_minor": 7500,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 7500,            "balance_after_minor": 10500,            "balance_state": "ok"          }        }      }    },    {      "name": "the later period's closing of two statements wins, August then July",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": null,        "known_balance_on": null,        "statements": [          {            "period_start": "2026-08-01",            "opening_balance_minor": 9500,            "period_end": "2026-08-31",            "closing_balance_minor": 7500          },          {            "period_start": "2026-07-01",            "opening_balance_minor": 10000,            "period_end": "2026-07-31",            "closing_balance_minor": 9000          }        ]      },      "rows": [        {          "id": "a",          "day": "2026-07-10",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 1000,          "direction": "out",          "expected": false        },        {          "id": "b",          "day": "2026-08-10",          "created_at": "2026-01-01T00:00:01Z",          "line_no": null,          "amount_minor": 2000,          "direction": "out",          "expected": false        },        {          "id": "c",          "day": "2026-09-10",          "created_at": "2026-01-01T00:00:02Z",          "line_no": null,          "amount_minor": 3000,          "direction": "in",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 10500,        "rows": {          "a": {            "balance_before_minor": 10500,            "balance_after_minor": 9500,            "balance_state": "ok"          },          "b": {            "balance_before_minor": 9500,            "balance_after_minor": 7500,            "balance_state": "ok"          },          "c": {            "balance_before_minor": 7500,            "balance_after_minor": 10500,            "balance_state": "ok"          }        }      }    },    {      "name": "rows made on one day run in the order they were made, then by statement line",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": 1000,        "known_balance_on": "2026-10-01",        "statements": []      },      "rows": [        {          "id": "second",          "day": "2026-10-02",          "created_at": "2026-10-02T09:00:00Z",          "line_no": 2,          "amount_minor": 100,          "direction": "out",          "expected": false        },        {          "id": "first",          "day": "2026-10-02",          "created_at": "2026-10-02T09:00:00Z",          "line_no": 1,          "amount_minor": 200,          "direction": "out",          "expected": false        },        {          "id": "typed",          "day": "2026-10-02",          "created_at": "2026-10-02T08:00:00Z",          "line_no": null,          "amount_minor": 300,          "direction": "in",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": 1000,        "rows": {          "second": {            "balance_before_minor": 1100,            "balance_after_minor": 1000,            "balance_state": "ok"          },          "first": {            "balance_before_minor": 1300,            "balance_after_minor": 1100,            "balance_state": "ok"          },          "typed": {            "balance_before_minor": 1000,            "balance_after_minor": 1300,            "balance_state": "ok"          }        }      }    },    {      "name": "with no anchor nothing is guessed",      "today": "2026-10-27",      "account": {        "kind": "bank",        "known_balance_minor": null,        "known_balance_on": null,        "statements": []      },      "rows": [        {          "id": "a",          "day": "2026-10-02",          "created_at": "2026-01-01T00:00:00Z",          "line_no": null,          "amount_minor": 3000,          "direction": "out",          "expected": false        }      ],      "printed": {},      "expect": {        "balance": null,        "rows": {          "a": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          }        }      }    }  ],  "books": [    {      "name": "a statement's booked rows run from the balances its lines printed, and a typed row after them on",      "today": "2026-10-27",      "book": {        "money_account": [          {            "id": "bank",            "created_at": "2026-09-01T00:00:00Z",            "data": {              "name": "Everyday",              "kind": "bank",              "currency": "INR"            }          }        ],        "statement": [          {            "id": "st",            "created_at": "2026-09-30T00:00:00Z",            "data": {              "account_id": "bank",              "read_status": "read",              "opening_balance_minor": 100000,              "closing_balance_minor": 350000            }          }        ],        "statement_line": [          {            "id": "l1",            "created_at": "2026-09-30T00:00:01Z",            "data": {              "statement_id": "st",              "line_no": 1,              "posted_on": "2026-09-03",              "amount_minor": 500000,              "direction": "in",              "balance_after_minor": 600000,              "transaction_id": "salary"            }          },          {            "id": "l2",            "created_at": "2026-09-30T00:00:02Z",            "data": {              "statement_id": "st",              "line_no": 2,              "posted_on": "2026-09-05",              "amount_minor": 250000,              "direction": "out",              "balance_after_minor": 350000,              "transaction_id": "rent"            }          }        ],        "transaction": [          {            "id": "salary",            "created_at": "2026-09-30T00:00:03Z",            "data": {              "occurred_on": "2026-09-03",              "account_id": "bank",              "amount_minor": 500000,              "direction": "in",              "status": "actual"            }          },          {            "id": "rent",            "created_at": "2026-09-30T00:00:03Z",            "data": {              "occurred_on": "2026-09-05",              "account_id": "bank",              "amount_minor": 250000,              "direction": "out",              "status": "actual"            }          },          {            "id": "groceries",            "created_at": "2026-10-01T00:00:00Z",            "data": {              "occurred_on": "2026-09-12",              "account_id": "bank",              "amount_minor": 20000,              "direction": "out",              "status": "actual"            }          }        ],        "evidence": []      },      "expect": {        "transactions": {          "salary": {            "balance_before_minor": 100000,            "balance_after_minor": 600000,            "balance_state": "ok"          },          "rent": {            "balance_before_minor": 600000,            "balance_after_minor": 350000,            "balance_state": "ok"          },          "groceries": {            "balance_before_minor": 350000,            "balance_after_minor": 330000,            "balance_state": "ok"          }        },        "accounts": {          "bank": 330000        }      }    },    {      "name": "a line reaches its row by evidence when the line names no row",      "today": "2026-10-27",      "book": {        "money_account": [          {            "id": "bank",            "created_at": "2026-09-01T00:00:00Z",            "data": {              "kind": "bank"            }          }        ],        "statement": [],        "statement_line": [          {            "id": "l1",            "created_at": "2026-09-30T00:00:01Z",            "data": {              "line_no": 1,              "balance_after_minor": 5000            }          }        ],        "transaction": [          {            "id": "fee",            "created_at": "2026-09-30T00:00:03Z",            "data": {              "occurred_on": "2026-09-03",              "account_id": "bank",              "amount_minor": 300,              "direction": "out",              "status": "actual"            }          },          {            "id": "tea",            "created_at": "2026-09-30T00:00:04Z",            "data": {              "occurred_on": "2026-09-04",              "account_id": "bank",              "amount_minor": 100,              "direction": "out",              "status": "actual"            }          }        ],        "evidence": [          {            "id": "e1",            "created_at": "2026-09-30T00:00:05Z",            "data": {              "kind": "statement_line",              "transaction_id": "fee",              "ref_id": "l1"            }          },          {            "id": "e2",            "created_at": "2026-09-30T00:00:06Z",            "data": {              "kind": "document",              "transaction_id": "tea",              "ref_id": "l1"            }          }        ]      },      "expect": {        "transactions": {          "fee": {            "balance_before_minor": 5300,            "balance_after_minor": 5000,            "balance_state": "ok"          },          "tea": {            "balance_before_minor": 5000,            "balance_after_minor": 4900,            "balance_state": "ok"          }        },        "accounts": {          "bank": 4900        }      }    },    {      "name": "a binned or ignored line, binned evidence, an unread or binned statement anchors nothing",      "today": "2026-10-27",      "book": {        "money_account": [          {            "id": "bank",            "created_at": "2026-09-01T00:00:00Z",            "data": {              "kind": "bank"            }          }        ],        "statement": [          {            "id": "unread",            "created_at": "2026-09-30T00:00:00Z",            "data": {              "account_id": "bank",              "read_status": "mismatch",              "period_end": "2026-09-30",              "closing_balance_minor": 1            }          },          {            "id": "binned",            "created_at": "2026-09-30T00:00:00Z",            "data": {              "account_id": "bank",              "read_status": "read",              "period_end": "2026-09-30",              "closing_balance_minor": 2,              "trashed_at": "2026-10-01T00:00:00Z"            }          }        ],        "statement_line": [          {            "id": "ignored",            "created_at": "2026-09-30T00:00:01Z",            "data": {              "line_no": 1,              "balance_after_minor": 3,              "transaction_id": "a",              "ignored_reason": "duplicate"            }          },          {            "id": "binnedline",            "created_at": "2026-09-30T00:00:02Z",            "data": {              "line_no": 2,              "balance_after_minor": 4,              "transaction_id": "b",              "trashed_at": "2026-10-01T00:00:00Z"            }          },          {            "id": "live",            "created_at": "2026-09-30T00:00:03Z",            "data": {              "line_no": 3,              "balance_after_minor": 5            }          }        ],        "transaction": [          {            "id": "a",            "created_at": "2026-09-30T00:00:03Z",            "data": {              "occurred_on": "2026-09-03",              "account_id": "bank",              "amount_minor": 300,              "direction": "out",              "status": "actual"            }          },          {            "id": "b",            "created_at": "2026-09-30T00:00:04Z",            "data": {              "occurred_on": "2026-09-04",              "account_id": "bank",              "amount_minor": 100,              "direction": "out",              "status": "actual"            }          }        ],        "evidence": [          {            "id": "e1",            "created_at": "2026-09-30T00:00:05Z",            "data": {              "kind": "statement_line",              "transaction_id": "a",              "ref_id": "live",              "trashed_at": "2026-10-01T00:00:00Z"            }          }        ]      },      "expect": {        "transactions": {          "a": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          },          "b": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          }        },        "accounts": {          "bank": null        }      }    },    {      "name": "only rows that move known money run: no proposal, no settled expectation, nothing binned",      "today": "2026-10-27",      "book": {        "money_account": [          {            "id": "wallet",            "created_at": "2026-01-01T00:00:00Z",            "data": {              "kind": "cash",              "known_balance_minor": 5000,              "known_balance_on": "2026-01-01T18:30:00Z"            }          }        ],        "statement": [],        "statement_line": [],        "evidence": [],        "transaction": [          {            "id": "lunch",            "created_at": "2026-01-02T00:00:00Z",            "data": {              "occurred_on": "2026-01-02",              "account_id": "wallet",              "amount_minor": 1500,              "direction": "out",              "status": "actual"            }          },          {            "id": "proposed",            "created_at": "2026-01-02T00:00:01Z",            "data": {              "occurred_on": "2026-01-03",              "account_id": "wallet",              "amount_minor": 700,              "direction": "out",              "status": "proposed"            }          },          {            "id": "notmoving",            "created_at": "2026-01-02T00:00:02Z",            "data": {              "occurred_on": "2026-01-03",              "account_id": "wallet",              "amount_minor": 700,              "direction": "out",              "status": "actual",              "moves_money": false            }          },          {            "id": "notmoving0",            "created_at": "2026-01-02T00:00:03Z",            "data": {              "occurred_on": "2026-01-03",              "account_id": "wallet",              "amount_minor": 700,              "direction": "out",              "status": "actual",              "moves_money": 0            }          },          {            "id": "unknown",            "created_at": "2026-01-02T00:00:04Z",            "data": {              "occurred_on": "2026-01-03",              "account_id": "wallet",              "amount_minor": 700,              "direction": "out",              "status": "actual",              "amount_known": false            }          },          {            "id": "binned",            "created_at": "2026-01-02T00:00:05Z",            "data": {              "occurred_on": "2026-01-03",              "account_id": "wallet",              "amount_minor": 700,              "direction": "out",              "status": "actual",              "trashed_at": "2026-01-04T00:00:00Z"            }          },          {            "id": "rent_due",            "created_at": "2026-01-02T00:00:06Z",            "data": {              "occurred_on": "2099-02-01",              "account_id": "wallet",              "amount_minor": 1000,              "direction": "out",              "status": "expected"            }          },          {            "id": "rent_paid",            "created_at": "2026-01-02T00:00:07Z",            "data": {              "occurred_on": "2026-01-04",              "account_id": "wallet",              "amount_minor": 1000,              "direction": "out",              "status": "actual",              "settles_transaction_id": "rent_due"            }          },          {            "id": "dues",            "created_at": "2026-01-02T00:00:08Z",            "data": {              "occurred_on": "2099-03-02",              "account_id": "wallet",              "amount_minor": 4000,              "direction": "out",              "status": "expected"            }          },          {            "id": "refund",            "created_at": "2026-01-02T00:00:09Z",            "data": {              "occurred_on": "2099-03-20",              "account_id": "wallet",              "amount_minor": 1000,              "direction": "in",              "status": "expected"            }          },          {            "id": "fees",            "created_at": "2026-01-02T00:00:10Z",            "data": {              "occurred_on": "2099-04-02",              "account_id": "wallet",              "amount_minor": 2000,              "direction": "out",              "status": "expected"            }          }        ]      },      "expect": {        "transactions": {          "lunch": {            "balance_before_minor": 5000,            "balance_after_minor": 3500,            "balance_state": "ok"          },          "rent_paid": {            "balance_before_minor": 3500,            "balance_after_minor": 2500,            "balance_state": "ok"          },          "dues": {            "balance_before_minor": 2500,            "balance_after_minor": -1500,            "balance_state": "overdrawn"          },          "refund": {            "balance_before_minor": -1500,            "balance_after_minor": -500,            "balance_state": "overdrawn"          },          "fees": {            "balance_before_minor": -500,            "balance_after_minor": -2500,            "balance_state": "overdrawn"          },          "proposed": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          },          "notmoving": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          },          "notmoving0": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          },          "unknown": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          },          "binned": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          },          "rent_due": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          }        },        "accounts": {          "wallet": 2500        }      }    },    {      "name": "a row with no account runs on the usual account, and each side of a transfer on its own",      "today": "2026-10-27",      "book": {        "money_account": [          {            "id": "bank",            "created_at": "2026-01-01T00:00:00Z",            "data": {              "kind": "bank",              "is_default": 1,              "known_balance_minor": 100000,              "known_balance_on": "2026-01-01"            }          },          {            "id": "wallet",            "created_at": "2026-01-01T00:00:01Z",            "data": {              "kind": "cash",              "known_balance_minor": 500,              "known_balance_on": "2026-01-01"            }          },          {            "id": "old",            "created_at": "2026-01-01T00:00:02Z",            "data": {              "kind": "bank",              "is_default": true,              "archived_at": "2026-01-02T00:00:00Z",              "known_balance_minor": 9,              "known_balance_on": "2026-01-01"            }          }        ],        "statement": [],        "statement_line": [],        "evidence": [],        "transaction": [          {            "id": "loose",            "created_at": "2026-01-03T00:00:00Z",            "data": {              "occurred_on": "2026-01-03",              "amount_minor": 2500,              "direction": "out",              "status": "actual"            }          },          {            "id": "out",            "created_at": "2026-01-05T00:00:00Z",            "data": {              "occurred_on": "2026-01-05",              "account_id": "bank",              "amount_minor": 1000,              "direction": "out",              "status": "actual"            }          },          {            "id": "into",            "created_at": "2026-01-05T00:00:01Z",            "data": {              "occurred_on": "2026-01-05",              "account_id": "wallet",              "amount_minor": 1000,              "direction": "in",              "status": "actual",              "transfer_of": "out"            }          },          {            "id": "nowhere",            "created_at": "2026-01-06T00:00:00Z",            "data": {              "occurred_on": "2026-01-06",              "account_id": "gone",              "amount_minor": 1,              "direction": "out",              "status": "actual"            }          }        ]      },      "expect": {        "transactions": {          "loose": {            "balance_before_minor": 100000,            "balance_after_minor": 97500,            "balance_state": "ok"          },          "out": {            "balance_before_minor": 97500,            "balance_after_minor": 96500,            "balance_state": "ok"          },          "into": {            "balance_before_minor": 500,            "balance_after_minor": 1500,            "balance_state": "ok"          },          "nowhere": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          }        },        "accounts": {          "bank": 96500,          "wallet": 1500,          "old": 9        }      }    },    {      "name": "two usual accounts are none: a row with no account stays empty",      "today": "2026-10-27",      "book": {        "money_account": [          {            "id": "a",            "created_at": "2026-01-01T00:00:00Z",            "data": {              "kind": "bank",              "is_default": true,              "known_balance_minor": 100,              "known_balance_on": "2026-01-01"            }          },          {            "id": "b",            "created_at": "2026-01-01T00:00:01Z",            "data": {              "kind": "bank",              "is_default": true,              "known_balance_minor": 200,              "known_balance_on": "2026-01-01"            }          },          {            "id": "spare",            "created_at": "2026-01-01T00:00:02Z",            "data": {              "kind": "bank"            }          }        ],        "statement": [],        "statement_line": [],        "evidence": [],        "transaction": [          {            "id": "loose",            "created_at": "2026-01-03T00:00:00Z",            "data": {              "occurred_on": "2026-01-03",              "amount_minor": 10,              "direction": "out",              "status": "actual"            }          },          {            "id": "unanchored",            "created_at": "2026-01-03T00:00:01Z",            "data": {              "occurred_on": "2026-01-03",              "account_id": "spare",              "amount_minor": 10,              "direction": "out",              "status": "actual"            }          }        ]      },      "expect": {        "transactions": {          "unanchored": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          },          "loose": {            "balance_before_minor": null,            "balance_after_minor": null,            "balance_state": null          }        },        "accounts": {          "a": 100,          "b": 200,          "spare": null        }      }    },    {      "name": "a loan's read statement runs its payment with bank arithmetic",      "today": "2026-10-27",      "book": {        "money_account": [          {            "id": "loan",            "created_at": "2026-03-01T00:00:00Z",            "data": {              "kind": "loan",              "currency": "INR"            }          }        ],        "statement": [          {            "id": "st",            "created_at": "2026-04-01T00:00:00Z",            "data": {              "account_id": "loan",              "read_status": "read",              "period_start": "2026-03-01",              "period_end": "2026-03-31",              "opening_balance_minor": 10000,              "closing_balance_minor": 8000            }          }        ],        "statement_line": [          {            "id": "l1",            "created_at": "2026-04-01T00:00:01Z",            "data": {              "line_no": 1,              "posted_on": "2026-03-02",              "amount_minor": 2000,              "direction": "out",              "transaction_id": "pay"            }          }        ],        "transaction": [          {            "id": "pay",            "created_at": "2026-04-01T00:00:02Z",            "data": {              "occurred_on": "2026-03-02",              "account_id": "loan",              "amount_minor": 2000,              "direction": "out",              "status": "actual"            }          }        ],        "evidence": []      },      "expect": {        "transactions": {          "pay": {            "balance_before_minor": 10000,            "balance_after_minor": 8000,            "balance_state": "ok"          }        },        "accounts": {          "loan": 8000        }      }    },    {      "name": "statement lines booked in one moment run in their printed order",      "today": "2026-10-27",      "book": {        "money_account": [          {            "id": "bank",            "created_at": "2026-08-01T00:00:00Z",            "data": {              "kind": "bank"            }          }        ],        "statement": [          {            "id": "st",            "created_at": "2026-09-01T00:00:00Z",            "data": {              "account_id": "bank",              "read_status": "read",              "period_start": "2026-08-01",              "period_end": "2026-08-31",              "opening_balance_minor": 50000,              "closing_balance_minor": 75000            }          }        ],        "statement_line": [          {            "id": "l2",            "created_at": "2026-09-01T00:00:01Z",            "data": {              "line_no": 2,              "transaction_id": "cash"            }          },          {            "id": "l1",            "created_at": "2026-09-01T00:00:01Z",            "data": {              "line_no": 1,              "transaction_id": "interest"            }          }        ],        "transaction": [          {            "id": "cash",            "created_at": "2026-09-01T00:00:02Z",            "data": {              "occurred_on": "2026-08-02",              "account_id": "bank",              "amount_minor": 5000,              "direction": "out",              "status": "actual"            }          },          {            "id": "interest",            "created_at": "2026-09-01T00:00:02Z",            "data": {              "occurred_on": "2026-08-02",              "account_id": "bank",              "amount_minor": 30000,              "direction": "in",              "status": "actual"            }          }        ],        "evidence": []      },      "expect": {        "transactions": {          "interest": {            "balance_before_minor": 50000,            "balance_after_minor": 80000,            "balance_state": "ok"          },          "cash": {            "balance_before_minor": 80000,            "balance_after_minor": 75000,            "balance_state": "ok"          }        },        "accounts": {          "bank": 75000        }      }    }  ]}