aboutsummaryrefslogtreecommitdiff
path: root/src/sru.c
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-19 00:01:25 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-19 00:01:25 +0200
commit678d9a58be42c9375511c402642fd621029172c5 (patch)
tree6bbaa23c06b92767caf1f188d1f731f4a593054d /src/sru.c
parent49e44668c14abacef17f0f11be39cbd0faa7ecb9 (diff)
downloadbokf-678d9a58be42c9375511c402642fd621029172c5.tar.gz
bokf-678d9a58be42c9375511c402642fd621029172c5.zip
sru: INK2 report view in the TUI; voucher list tweaksv0.1.31
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.
Diffstat (limited to 'src/sru.c')
-rw-r--r--src/sru.c27
1 files changed, 27 insertions, 0 deletions
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) {