summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-18 21:35:10 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-18 21:35:10 +0200
commit251eb8c54c77029f0b43aa987ea50c44016147f3 (patch)
tree2bf4284ce2daab191d48579a6c5a84882060d398 /tests
parent64c0d5d79b31dafcbdb68ff938a92bd6f136d4a7 (diff)
downloadbokf-251eb8c54c77029f0b43aa987ea50c44016147f3.tar.gz
bokf-251eb8c54c77029f0b43aa987ea50c44016147f3.zip
eskd: generate the momsdeklaration file (eSKDUpload 6.0)v0.1.28
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.
Diffstat (limited to 'tests')
-rw-r--r--tests/test_core.c29
1 files changed, 29 insertions, 0 deletions
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, "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>") !=
+ NULL);
+ CHECK(strstr(xml, "<OrgNr>559331-2126</OrgNr>") != NULL);
+ CHECK(strstr(xml, "<Period>202601</Period>") != NULL);
+ CHECK(strstr(xml, "<ForsMomsEjAnnan>1000</ForsMomsEjAnnan>") != NULL);
+ CHECK(strstr(xml, "<MomsUtgHog>250</MomsUtgHog>") != NULL);
+ CHECK(strstr(xml, "<MomsBetala>250</MomsBetala>") != NULL);
+ CHECK(strstr(xml, "<TextUpplysningMoms>Bl\xe5</TextUpplysningMoms>") !=
+ 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));