diff options
Diffstat (limited to 'clients/bokftui.c')
| -rw-r--r-- | clients/bokftui.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/clients/bokftui.c b/clients/bokftui.c index 06ccfe8..ec7e75a 100644 --- a/clients/bokftui.c +++ b/clients/bokftui.c @@ -5905,6 +5905,33 @@ static int64_t invoices_new(struct app *a) return out; } +static int invoices_key(void *ud, int ch) +{ + struct app *a = ud; + if (ch != 'n') + return TUI_HOOK_NONE; + char *resp = client_rpc(&a->conn, "invoice.sequence_get", a->session, + a->org, "{}"); + char def[16] = "1"; + if (resp && client_ok(resp)) + snprintf(def, sizeof def, "%lld", + (long long)jint_val(resp, "result.next_number", 1)); + free(resp); + char buf[16] = ""; + if (!tui_prompt_into(buf, sizeof buf, "Nästa fakturanummer", def, 0)) + return TUI_HOOK_STAY; + char args[64]; + snprintf(args, sizeof args, "{\"next_number\":%s}", buf); + resp = client_rpc(&a->conn, "invoice.sequence_set", a->session, a->org, + args); + if (resp && client_ok(resp)) + tui_message("Fakturor", "Nästa fakturanummer: %s.", buf); + else + show_error("Fakturor", resp); + free(resp); + return TUI_HOOK_REFRESH; +} + static void invoices_screen(struct app *a) { char **items = NULL; @@ -5978,8 +6005,8 @@ static void invoices_screen(struct app *a) } } int cur = start; - int sel = tui_select_list("Fakturor", items, (int)n + 1, start, 1, - &cur, 1, NULL, 0); + int sel = tui_select_list_hook("Fakturor", items, (int)n + 1, start, 1, + &cur, 1, NULL, 0, invoices_key, a); if (cur >= 0 && (size_t)cur < n) a->invoice_sel = ids[cur]; if (sel == -1) { |
