From 251eb8c54c77029f0b43aa987ea50c44016147f3 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Fri, 18 Sep 2026 21:35:10 +0200 Subject: eskd: generate the momsdeklaration file (eSKDUpload 6.0) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit report.vat_eskd builds the ISO-8859-1 XML from report.vat: whole kronor with öre truncated like the blankett, box 48 positive as filed, MomsBetala computed from the whole-krona boxes, and an optional upplysning converted from UTF-8, XML-escaped and capped at 300 characters. The TUI momsrapport gains "s = spara eSKD", prompting for a path and writing the bytes verbatim. Verified against the FY2027 Kapitas report: 05=703200, 10=175800, 20=1453, 30=851, 48=1030, 49=175621. --- tests/test_core.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') diff --git a/tests/test_core.c b/tests/test_core.c index 5740db3..aa2bd4a 100644 --- a/tests/test_core.c +++ b/tests/test_core.c @@ -820,6 +820,35 @@ int main(void) CHECK(yyjson_arr_size(jget(d, "result.vouchers")) == 0); yyjson_doc_free(d); + /* eSKD: ISO-8859-1 XML for the momsdeklaration */ + d = call(reqf("{\"v\":1,\"id\":\"54e\",\"cmd\":\"report.vat_eskd\"," + "\"session\":\"%s\",\"org\":%d,\"args\":" + "{\"from\":\"2026-01-01\",\"to\":\"2026-01-31\"," + "\"upplysning\":\"Blå\"}}", + g_session, (int)org_id)); + CHECK_OK(d); + CHECK_STR(d, "result.org_nr", "559331-2126"); + CHECK_STR(d, "result.period", "202601"); + char *b64 = jstr(d, "result.content_base64"); + unsigned char *xmlb = NULL; + size_t xmll = 0; + CHECK(b64 && util_b64_decode(b64, strlen(b64), &xmlb, &xmll) == 0); + char *xml = xmalloc(xmll + 1); + memcpy(xml, xmlb, xmll); + xml[xmll] = '\0'; + free(xmlb); + CHECK(strstr(xml, "") != + NULL); + CHECK(strstr(xml, "559331-2126") != NULL); + CHECK(strstr(xml, "202601") != NULL); + CHECK(strstr(xml, "1000") != NULL); + CHECK(strstr(xml, "250") != NULL); + CHECK(strstr(xml, "250") != NULL); + CHECK(strstr(xml, "Bl\xe5") != + NULL); + free(xml); + yyjson_doc_free(d); + d = call(reqf("{\"v\":1,\"id\":\"54\",\"cmd\":\"report.trial_balance\"," "\"session\":\"%s\",\"org\":%d}", g_session, (int)org_id)); -- cgit v1.3