From 678d9a58be42c9375511c402642fd621029172c5 Mon Sep 17 00:00:00 2001 From: Anders Betts Date: Sat, 19 Sep 2026 00:01:25 +0200 Subject: sru: INK2 report view in the TUI; voucher list tweaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit sru.export now returns the emitted fields as ink2/ink2r/ink2s arrays plus from/to, so Rapporter -> Inkomstdeklaration (INK2/SRU) renders the declaration as a table with the official fältnamn before saving; unmapped accounts are listed in the view. The voucher list puts the verifikat id before the date, widens the column gaps and adds an inner margin. --- src/sru.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src') diff --git a/src/sru.c b/src/sru.c index 98a3c6d..a6228f1 100644 --- a/src/sru.c +++ b/src/sru.c @@ -350,6 +350,22 @@ static void date_compact(const char *iso, char out[9]) snprintf(out, 9, "%.4s%.2s%.2s", iso, iso + 5, iso + 8); } +/* The emitted (non-zero) whole-krona fields, in blankett order. */ +static yyjson_mut_val *fields_json(yyjson_mut_doc *doc, const struct fldset *f, + const char *const *order, size_t norder) +{ + yyjson_mut_val *arr = yyjson_mut_arr(doc); + for (size_t i = 0; i < norder; i++) { + int64_t kr = fld_get(f, order[i]) / 100; + if (!kr) + continue; + yyjson_mut_val *o = yyjson_mut_arr_add_obj(doc, arr); + yyjson_mut_obj_add_strcpy(doc, o, "code", order[i]); + yyjson_mut_obj_add_int(doc, o, "amount", kr); + } + return arr; +} + static yyjson_mut_val *file_json(yyjson_mut_doc *doc, const char *fname, const struct buf *b) { @@ -692,6 +708,17 @@ yyjson_mut_val *sru_export(yyjson_mut_doc *doc, sqlite3 *db, int64_t org_id, yyjson_mut_val *o = yyjson_mut_obj(doc); yyjson_mut_obj_add_strcpy(doc, o, "period", type_base); yyjson_mut_obj_add_strcpy(doc, o, "blankett", type_ink2); + yyjson_mut_obj_add_strcpy(doc, o, "from", fy_start); + yyjson_mut_obj_add_strcpy(doc, o, "to", fy_end); + yyjson_mut_obj_add_val(doc, o, "ink2", + fields_json(doc, &ink2, INK2_ORDER, + sizeof INK2_ORDER / sizeof INK2_ORDER[0])); + yyjson_mut_obj_add_val(doc, o, "ink2r", + fields_json(doc, &ink2r, INK2R_ORDER, + sizeof INK2R_ORDER / sizeof INK2R_ORDER[0])); + yyjson_mut_obj_add_val(doc, o, "ink2s", + fields_json(doc, &ink2s, INK2S_ORDER, + sizeof INK2S_ORDER / sizeof INK2S_ORDER[0])); yyjson_mut_obj_add_val(doc, o, "info", info_file); yyjson_mut_obj_add_val(doc, o, "blanketter", blanketter_file); if (unmapped.n > 0) { -- cgit v1.3