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. --- src/commands.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/commands.c') diff --git a/src/commands.c b/src/commands.c index 1034b31..e16ba75 100644 --- a/src/commands.c +++ b/src/commands.c @@ -3600,6 +3600,25 @@ static yyjson_mut_val *h_report_voucher_list(struct req *r) return res; } +static yyjson_mut_val *h_report_vat_eskd(struct req *r) +{ + const char *from = arg_str(r->args, "from"); + const char *to = arg_str(r->args, "to"); + if (!from || !to) + return fail(r, "INVALID_ARGS", "from and to are required"); + char *err = NULL; + yyjson_mut_val *res = + report_vat_eskd(r->rdoc, r->db, r->org_id, from, to, + arg_str(r->args, "upplysning"), &err); + if (!res) { + yyjson_mut_val *e = fail(r, "INVALID_ARGS", + err ? err : "could not build the eSKD file"); + free(err); + return e; + } + return res; +} + static unsigned char *read_file(const char *path, size_t *out_len) { FILE *f = fopen(path, "rb"); @@ -3841,6 +3860,8 @@ const struct command g_commands[] = { h_report_general_ledger }, { "report.voucher_list", "Verifikationslista", PERM_READ, 1, 0, 0, h_report_voucher_list }, + { "report.vat_eskd", "eSKD XML for the momsdeklaration (ISO-8859-1)", + PERM_READ, 1, 0, 0, h_report_vat_eskd }, { "sie.export", "Export SIE 4 (PC8)", PERM_READ, 1, 0, 0, h_sie_export }, { "sie.import", "Import SIE 4 into an empty fiscal year", PERM_WRITE, 1, 1, 1, h_sie_import }, -- cgit v1.3