Jakob Wennberg
d69de86b71
fix(reports): count reversed originals in the KPI monthly breakdown ( #2201 ) ( #2243 )
...
The year total (tb / tb_ex_year_end) aggregates posted AND reversed
entries, so a same-year storno nets to 0. The monthly section, both the
get_kpi_report_aggregates RPC and the dimension-filtered JS fallback in
lib/reports/monthly-breakdown.ts, was posted-only: it dropped the reversed
original but kept the storno (itself posted). 10 000 kr on 3041 in March,
reversed in April, gave March 0 kr, April -10 000 kr, year 0 kr, and PR
#2198 made the per-month figures visible enough to add up.
Migration 20260903160000 replaces the RPC with the monthly join on
tb_ex_year_end's entry set verbatim (no extra status predicate); the JS
fallback filters status in ('posted','reversed') the same way. The pg-real
pin ("in tb, not in monthly") is flipped and a storno case asserts
sum(months) = net result. Everything else in the function is byte-identical
to 20260730090000.
Verified: pg-real suite against a rebuilt local supabase/postgres with every
migration applied (9 tests), unit suite, lint.
Closes #2201
Claude-Session: https://claude.ai/code/session_01VnConrmMCxJRQ5kfiPPWyy
Co-authored-by: Jakob Wennberg <311770904+jakobwennberg-oss@users.noreply.github.com >
Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com >
2026-09-03 18:21:00 +02:00
..
2026-09-02 18:14:32 +02:00
2026-07-24 16:36:35 +02:00
2026-07-03 16:50:28 +02:00
2026-08-25 09:34:05 +02:00
2026-08-24 14:07:58 +02:00
2026-08-06 23:00:05 +02:00
2026-07-04 15:58:06 +02:00
2026-07-04 15:58:06 +02:00
2026-07-26 17:48:18 +02:00
2026-08-03 15:41:01 +02:00
2026-07-21 23:00:15 +02:00
2026-09-02 11:38:30 +02:00
2026-07-04 15:58:06 +02:00
2026-08-26 09:58:25 +02:00
2026-07-04 15:58:06 +02:00
2026-07-16 16:00:05 +02:00
2026-08-06 23:00:05 +02:00
2026-08-15 23:07:29 +02:00
2026-09-02 15:25:34 +02:00
2026-08-03 15:41:01 +02:00
2026-08-25 09:34:05 +02:00
2026-08-28 12:12:47 +02:00
2026-08-03 18:55:59 +02:00
2026-09-03 14:25:32 +02:00
2026-08-27 18:32:52 +02:00
2026-08-26 16:56:39 +02:00
2026-07-04 15:58:06 +02:00
2026-07-27 03:34:56 +02:00
2026-08-25 10:32:12 +02:00
2026-08-06 23:00:05 +02:00
2026-08-26 16:56:39 +02:00
2026-07-11 23:13:50 +02:00
2026-08-21 15:55:26 +02:00
2026-08-04 19:34:54 +02:00
2026-08-06 23:00:05 +02:00
2026-07-04 15:58:06 +02:00
2026-09-02 11:38:30 +02:00
2026-07-04 15:58:06 +02:00
2026-08-27 14:35:19 +02:00
2026-08-31 20:51:17 +02:00
2026-09-02 20:57:57 +02:00
2026-08-25 12:41:02 +02:00
2026-07-27 03:34:56 +02:00
2026-07-27 03:34:56 +02:00
2026-07-28 19:50:16 +02:00
2026-08-26 15:14:49 +02:00
2026-07-10 11:05:40 +02:00
2026-09-02 18:14:49 +02:00
2026-07-04 15:58:06 +02:00
2026-08-24 17:05:00 +02:00
2026-07-04 15:58:06 +02:00
2026-07-04 15:58:06 +02:00
2026-07-04 15:58:06 +02:00
2026-09-01 14:23:05 +02:00
2026-08-25 15:15:33 +02:00
2026-07-27 03:34:56 +02:00
2026-07-28 18:34:55 +02:00
2026-07-13 22:54:33 +02:00
2026-07-13 22:54:33 +02:00
2026-07-04 15:58:06 +02:00
2026-07-21 23:00:15 +02:00
2026-08-20 21:25:18 +02:00
2026-07-27 03:34:56 +02:00
2026-08-28 23:51:27 +02:00
2026-08-06 23:00:05 +02:00
2026-08-06 23:00:05 +02:00
2026-08-30 11:56:15 +02:00
2026-05-12 13:12:17 +02:00
2026-08-28 17:45:10 +02:00
2026-08-31 16:01:11 +02:00
2026-08-19 20:09:23 +02:00
2026-08-25 17:03:57 +02:00
2026-08-03 17:56:37 +02:00
2026-09-02 08:50:42 +02:00
2026-08-13 23:57:53 +02:00
2026-07-04 15:58:06 +02:00
2026-08-17 21:36:16 +02:00
2026-07-04 15:58:06 +02:00
2026-08-13 16:53:19 +02:00
2026-09-03 18:21:00 +02:00
2026-08-06 23:00:05 +02:00
2026-08-06 23:00:05 +02:00
2026-08-30 16:54:35 +02:00
2026-08-06 23:00:05 +02:00
2026-08-10 12:23:42 +02:00
2026-07-23 16:16:55 +02:00
2026-08-17 22:20:52 +02:00
2026-08-24 13:19:32 +02:00
2026-07-04 15:58:06 +02:00
2026-07-29 18:15:06 +02:00
2026-09-01 11:29:12 +02:00
2026-09-03 18:09:46 +02:00
2026-08-20 10:27:52 +02:00
2026-07-04 15:58:06 +02:00
2026-06-08 09:47:33 +02:00
2026-09-02 17:33:30 +02:00
2026-09-02 14:33:45 +02:00
2026-09-02 18:14:32 +02:00
2026-09-02 18:18:35 +02:00
2026-09-02 18:18:12 +02:00
2026-07-04 15:58:06 +02:00
2026-08-13 23:12:27 +02:00
2026-07-22 18:30:33 +02:00
2026-07-22 18:33:49 +02:00
2026-08-31 08:39:04 +01:00
2026-08-13 15:55:01 +02:00
2026-07-27 03:34:56 +02:00
2026-07-27 03:34:56 +02:00
2026-08-21 17:27:45 +02:00
2026-08-13 19:44:32 +02:00
2026-08-21 16:56:32 +02:00
2026-09-01 14:14:09 +02:00
2026-08-29 00:29:11 +02:00
2026-08-28 22:12:20 +02:00
2026-07-04 15:58:06 +02:00
2026-08-25 14:36:18 +02:00
2026-07-23 16:16:55 +02:00
2026-07-03 13:57:59 +02:00
2026-07-12 19:14:12 +02:00
2026-05-26 22:29:41 +02:00
2026-07-03 13:57:59 +02:00
2026-07-05 03:05:09 +02:00
2026-07-05 03:05:09 +02:00
2026-09-02 18:14:49 +02:00
2026-09-01 14:14:45 +02:00
2026-09-02 11:38:30 +02:00
2026-09-02 11:38:30 +02:00
2026-07-04 15:58:06 +02:00
2026-06-04 13:14:57 +02:00
2026-07-27 03:34:56 +02:00
2026-08-09 12:44:08 +02:00
2026-07-21 16:54:14 +02:00
2026-07-12 19:14:12 +02:00
2026-08-14 08:21:57 +02:00
2026-07-12 19:14:12 +02:00
2026-07-09 12:19:57 +02:00
2026-07-27 14:49:22 +02:00
2026-08-03 18:49:46 +02:00
2026-08-27 22:24:36 +02:00
2026-09-01 14:29:47 +02:00
2026-07-21 23:00:15 +02:00
2026-08-04 11:43:58 +02:00
2026-08-26 16:56:39 +02:00
2026-07-04 15:58:06 +02:00
2026-07-04 15:58:06 +02:00
2026-05-06 10:24:57 +02:00
2026-08-13 23:12:27 +02:00
2026-08-08 11:58:51 +02:00
2026-09-01 11:29:12 +02:00
2026-08-15 19:50:32 +02:00
2026-08-13 16:53:19 +02:00
2026-08-30 11:51:27 +02:00
2026-08-06 23:00:05 +02:00
2026-08-06 23:00:05 +02:00
2026-08-25 14:23:56 +02:00
2026-08-05 15:47:23 +02:00
2026-08-05 15:27:00 +02:00
2026-08-12 15:08:13 +02:00