From ca267e6b1c727be254c6229fc1ed3e2c5a0d6065 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Tue, 22 Sep 2026 22:48:14 +0200 Subject: sru, tui: round every account to whole kronor; fix the årsredovisning Stäng skip MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- tests/test_core.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test_core.c b/tests/test_core.c index c9c969e..071b5ce 100644 --- a/tests/test_core.c +++ b/tests/test_core.c @@ -1654,6 +1654,15 @@ static void test_imported_closings(struct tctx *t) free(sru); yyjson_doc_free(d); + /* the huvudbok tells imported rows apart, for the TUI årsredovisning */ + d = call(reqf("{\"v\":1,\"id\":\"ic9a\",\"cmd\":\"report.general_ledger\"," + "\"session\":\"%s\",\"org\":%d,\"args\":{\"accounts\":" + "[\"3001\"]}}", + g_session, (int)org)); + CHECK_OK(d); + CHECK_STR(d, "result.accounts.0.rows.0.source", "sie_import"); + yyjson_doc_free(d); + /* a voucher entered in bokf is never skipped, whatever its text */ d = call(reqf("{\"v\":1,\"id\":\"ic10\",\"cmd\":\"voucher.post\"," "\"session\":\"%s\",\"org\":%d,\"args\":{\"date\":" @@ -4520,22 +4529,28 @@ static void test_sru(struct tctx *t) CHECK(strstr(sru, "#UPPGIFT 7410 1500") != NULL); CHECK(strstr(sru, "#UPPGIFT 7513 80") != NULL); CHECK(strstr(sru, "#UPPGIFT 7525 500") != NULL); - CHECK(strstr(sru, "#UPPGIFT 7528 168") != NULL); + /* every account rounds to whole kronor before it is summed, so the + fields add up: 1500 - 100 - 80 - 500 - 169 = 651 and + 1875 = 651 + 500 + 200 + 355 + 169 */ + CHECK(strstr(sru, "#UPPGIFT 7528 169") != NULL); CHECK(strstr(sru, "#UPPGIFT 7450 651") != NULL); CHECK(strstr(sru, "#UPPGIFT 7281 1875") != NULL); CHECK(strstr(sru, "#UPPGIFT 7369 355") != NULL); CHECK(strstr(sru, "#UPPGIFT 7321 500") != NULL); CHECK(strstr(sru, "#UPPGIFT 7302 651") != NULL); CHECK(strstr(sru, "#UPPGIFT 7650 651") != NULL); - CHECK(strstr(sru, "#UPPGIFT 7651 168") != NULL); + CHECK(strstr(sru, "#UPPGIFT 7651 169") != NULL); CHECK(strstr(sru, "#UPPGIFT 7653 100") != NULL); - CHECK(strstr(sru, "#UPPGIFT 7670 919") != NULL); - CHECK(strstr(sru, "#UPPGIFT 7104 919") != NULL); + CHECK(strstr(sru, "#UPPGIFT 7368 169") != NULL); + CHECK(strstr(sru, "#UPPGIFT 7670 920") != NULL); + CHECK(strstr(sru, "#UPPGIFT 7104 920") != NULL); CHECK(strstr(sru, "#FIL_SLUT") != NULL); free(sru); CHECK_STR(d, "result.from", "2026-01-01"); CHECK(find_amount(d, "result.ink2r", "code", "7281", "amount") == 1875); - CHECK(find_amount(d, "result.ink2s", "code", "7670", "amount") == 919); + CHECK(find_amount(d, "result.ink2s", "code", "7670", "amount") == 920); + CHECK(util_round_kr(150) == 200 && util_round_kr(149) == 100); + CHECK(util_round_kr(-150) == -200 && util_round_kr(-149) == -100); yyjson_doc_free(d); d = call(reqf("{\"v\":1,\"id\":\"126\",\"cmd\":\"sru.export\"," -- cgit v1.3