diff options
| author | Anders Betts <anders.betts@gmail.com> | 2026-09-18 23:41:59 +0200 |
|---|---|---|
| committer | Anders Betts <anders.betts@gmail.com> | 2026-09-18 23:41:59 +0200 |
| commit | 49e44668c14abacef17f0f11be39cbd0faa7ecb9 (patch) | |
| tree | dd8248143def675fd033abf390c06567f78d5c4c /tests | |
| parent | e9fc91dbc8314a25a0d71b7ee4344d3fc4ccfd5e (diff) | |
| download | bokf-0.1.30.tar.gz bokf-0.1.30.zip | |
bokslut, INK2/SRU export and attachment markersv0.1.30
- bokslut.post: year-end bookings (manual entries, periodiseringsfond,
skatt at a given rate, resultatdisposition) with a dry-run plan through
the normal ledger path; the resultatrapport separates
bokslutsdispositioner and skatt per K2.
- sru.export: INFO.SRU + BLANKETTER.SRU (INK2/INK2R/INK2S) from the
official 2025P4 field tables and the BAS mapping, with manual INK2S
adjustments, submitter defaults and unmapped-account detection; the TUI
writes both files from Rapporter -> Inkomstdeklaration.
- voucher.list carries attachment_count and the voucher list marks
vouchers with underlag with an x column.
- date_prompt restores the cursor state so it stops blinking at the bottom
after the report date prompts.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_core.c | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/tests/test_core.c b/tests/test_core.c index 6f114b9..bb31fc7 100644 --- a/tests/test_core.c +++ b/tests/test_core.c @@ -996,6 +996,16 @@ int main(void) CHECK_STR(d, "error.code", "NOT_FOUND"); yyjson_doc_free(d); + /* voucher.list reports the attachment count */ + d = call(reqf("{\"v\":1,\"id\":\"61i\",\"cmd\":\"voucher.list\"," + "\"session\":\"%s\",\"org\":%d,\"args\":{\"limit\":5}}", + g_session, (int)org_id)); + CHECK_OK(d); + CHECK(jint(d, "result.items.0.attachment_count") >= 1); + CHECK(jint(d, "result.items.1.attachment_count") == 0); + CHECK(jint(d, "result.items.2.attachment_count") >= 1); + yyjson_doc_free(d); + /* correction */ d = call(reqf("{\"v\":1,\"id\":\"62\",\"cmd\":\"voucher.correct\"," "\"session\":\"%s\",\"org\":%d,\"args\":{\"voucher\":%lld," @@ -1518,6 +1528,116 @@ int main(void) CHECK(n05 == 1); yyjson_doc_free(d); + /* ---------------- bokslut: dispositions, tax, transfer ---------- */ + d = call(reqf("{\"v\":1,\"id\":\"120\",\"cmd\":\"bokslut.post\"," + "\"session\":\"%s\",\"org\":%d,\"dry_run\":true,\"args\":" + "{\"tax_rate\":20.6}}", + g_session, (int)vat_org)); + CHECK_OK(d); + CHECK(jint(d, "result.result_before_ore") == 132000); + CHECK(jint(d, "result.taxable_ore") == 132000); + CHECK(jint(d, "result.tax_ore") == 27192); + CHECK(jint(d, "result.result_after_ore") == 104808); + CHECK(yyjson_arr_size(jget(d, "result.vouchers")) == 2); + yyjson_doc_free(d); + + d = call(reqf("{\"v\":1,\"id\":\"121\",\"cmd\":\"bokslut.post\"," + "\"session\":\"%s\",\"org\":%d,\"args\":" + "{\"tax_rate\":20.6,\"periodiseringsfond_ore\":50000}}", + g_session, (int)vat_org)); + CHECK_OK(d); + CHECK(jint(d, "result.entries_ore") == -50000); + CHECK(jint(d, "result.taxable_ore") == 82000); + CHECK(jint(d, "result.tax_ore") == 16892); + CHECK(jint(d, "result.result_after_ore") == 65108); + CHECK(yyjson_arr_size(jget(d, "result.vouchers")) == 3); + yyjson_doc_free(d); + + d = call(reqf("{\"v\":1,\"id\":\"122\",\"cmd\":\"report.balance_sheet\"," + "\"session\":\"%s\",\"org\":%d}", + g_session, (int)vat_org)); + CHECK_OK(d); + CHECK(find_amount(d, "result.equity.accounts", "account", "2110", + "amount_ore") == 50000); + CHECK(find_amount(d, "result.liabilities.accounts", "account", "2512", + "amount_ore") == 16892); + CHECK(find_amount(d, "result.equity.accounts", "account", "2099", + "amount_ore") == 65108); + yyjson_doc_free(d); + + d = call(reqf("{\"v\":1,\"id\":\"123\",\"cmd\":\"bokslut.post\"," + "\"session\":\"%s\",\"org\":%d,\"args\":" + "{\"entries\":[{\"debit_account\":\"8910\"," + "\"amount_ore\":100}]}}", + g_session, (int)vat_org)); + CHECK_STR(d, "error.code", "INVALID_ARGS"); + yyjson_doc_free(d); + + /* ---------------- SRU (INK2/INK2R/INK2S) ----------------------- */ + d = call(reqf("{\"v\":1,\"id\":\"124\",\"cmd\":\"org.update\"," + "\"session\":\"%s\",\"org\":%d,\"args\":" + "{\"org_nr\":\"559331-2126\",\"postal_code\":\"192 48\"," + "\"city\":\"Sollentuna\"}}", + g_session, (int)vat_org)); + CHECK_OK(d); + yyjson_doc_free(d); + + d = call(reqf("{\"v\":1,\"id\":\"125\",\"cmd\":\"sru.export\"," + "\"session\":\"%s\",\"org\":%d,\"args\":" + "{\"adjustments\":[{\"code\":\"7653\"," + "\"amount_ore\":10000}]}}", + g_session, (int)vat_org)); + CHECK_OK(d); + CHECK_STR(d, "result.period", "2026P4"); + CHECK_STR(d, "result.blankett", "INK2-2026P4"); + char *sb64 = jstr(d, "result.blanketter.content_base64"); + unsigned char *srub = NULL; + size_t srul = 0; + CHECK(sb64 && util_b64_decode(sb64, strlen(sb64), &srub, &srul) == 0); + char *sru = xmalloc(srul + 1); + memcpy(sru, srub, srul); + sru[srul] = '\0'; + free(srub); + CHECK(strstr(sru, "#BLANKETT INK2-2026P4") != NULL); + CHECK(strstr(sru, "#BLANKETT INK2R-2026P4") != NULL); + CHECK(strstr(sru, "#BLANKETT INK2S-2026P4") != NULL); + CHECK(strstr(sru, "#UPPGIFT 7011 20260101") != NULL); + 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); + 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 7653 100") != NULL); + CHECK(strstr(sru, "#UPPGIFT 7670 919") != NULL); + CHECK(strstr(sru, "#UPPGIFT 7104 919") != NULL); + CHECK(strstr(sru, "#FIL_SLUT") != NULL); + free(sru); + yyjson_doc_free(d); + + d = call(reqf("{\"v\":1,\"id\":\"126\",\"cmd\":\"sru.export\"," + "\"session\":\"%s\",\"org\":%d,\"args\":{}}", + g_session, (int)vat_org)); + CHECK_OK(d); + sb64 = jstr(d, "result.info.content_base64"); + srub = NULL; + srul = 0; + CHECK(sb64 && util_b64_decode(sb64, strlen(sb64), &srub, &srul) == 0); + sru = xmalloc(srul + 1); + memcpy(sru, srub, srul); + sru[srul] = '\0'; + free(srub); + CHECK(strstr(sru, "#ORGNR 165593312126") != NULL); + CHECK(strstr(sru, "#POSTORT Sollentuna") != NULL); + CHECK(strstr(sru, "#FILNAMN BLANKETTER.SRU") != NULL); + free(sru); + yyjson_doc_free(d); + /* close fiscal year and verify hard stop */ d = call(reqf("{\"v\":1,\"id\":\"73\",\"cmd\":\"fiscal_year.close\"," "\"session\":\"%s\",\"org\":%d,\"args\":{\"id\":%lld," |
