summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--clients/bokftui.c31
-rw-r--r--docs/PROTOCOL.md3
2 files changed, 31 insertions, 3 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) {
diff --git a/docs/PROTOCOL.md b/docs/PROTOCOL.md
index 0f9b8e7..2fe0e68 100644
--- a/docs/PROTOCOL.md
+++ b/docs/PROTOCOL.md
@@ -683,7 +683,8 @@ commands. Implemented screens (0.1.0-dev):
consumed), `Ctrl+Enter` issues (`invoice.issue`) and then asks
"Skicka faktura <nr> till <e-post>?". The detail shows header and rows;
`p` fetches the stored PDF (`invoice.pdf`) and `s` sends it
- (`invoice.send`).
+ (`invoice.send`). In the list, `n` sets the next invoice number
+ (`invoice.sequence_get`/`sequence_set`, owner-only).
- **Kunder** — the customer register (name, address, postal code, city, VAT
number, e-mail, your reference, payment days, notes). Ctrl+N creates,
Enter edits (F5 validates with a dry run, Ctrl+Enter saves), `d`