summaryrefslogtreecommitdiff
path: root/clients/vlist.h
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-23 09:13:17 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-23 09:13:17 +0200
commit53071bb69f5d21b35b8a61c2b1dd18832ce781d4 (patch)
treefa76c13cef78925d1b9650e92f64d5115dcdb6e7 /clients/vlist.h
parent2ca284619125af0d5c12e9210ff1bfc8f9122739 (diff)
downloadbokf-53071bb69f5d21b35b8a61c2b1dd18832ce781d4.tar.gz
bokf-53071bb69f5d21b35b8a61c2b1dd18832ce781d4.zip
tui: aligned voucher detail, up/down between vouchers, list sorting
The detail pads every column by display width, blanks zero amounts and shows row texts and a Summa line. Up/Down step to the previous/next voucher in the list order; 's' cycles the list sort (number or date, ascending or descending, saved in tui.conf). The list fetches all pages of voucher.list instead of stopping at 200. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'clients/vlist.h')
-rw-r--r--clients/vlist.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/clients/vlist.h b/clients/vlist.h
new file mode 100644
index 0000000..8324ade
--- /dev/null
+++ b/clients/vlist.h
@@ -0,0 +1,46 @@
+#ifndef BOKF_VLIST_H
+#define BOKF_VLIST_H
+
+#include <stddef.h>
+#include <stdint.h>
+
+/* Voucher list ordering and stepping for the Verifikat view. Pure, so it is
+ unit-tested in tests/test_tui.c. */
+
+struct vlist_item {
+ int64_t id;
+ char series[16];
+ int64_t number;
+ char date[16];
+ char *desc; /* owned by the caller */
+ int attachments;
+};
+
+enum {
+ VSORT_NUMBER = 0, /* series, then number, ascending */
+ VSORT_NUMBER_DESC,
+ VSORT_DATE, /* date, then series and number, ascending */
+ VSORT_DATE_DESC,
+ VSORT_COUNT,
+};
+
+/* Sorts in place; ties fall back to the id so the order is stable. An
+ out-of-range mode sorts by number. */
+void vlist_sort(struct vlist_item *v, size_t n, int mode);
+
+/* Swedish label for the list title, e.g. "datum, fallande". */
+const char *vlist_sort_label(int mode);
+
+/* Config value ("number", "number-desc", "date", "date-desc") and back;
+ an unknown name gives VSORT_NUMBER. */
+const char *vlist_sort_name(int mode);
+int vlist_sort_parse(const char *name);
+
+/* Index of the item with this id, or -1. */
+int vlist_index(const struct vlist_item *v, size_t n, int64_t id);
+
+/* Index dir steps from idx, or -1 past either end or when idx is not in
+ the list. */
+int vlist_step(size_t n, int idx, int dir);
+
+#endif