diff options
Diffstat (limited to 'clients/screens_vouchers.c')
| -rw-r--r-- | clients/screens_vouchers.c | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/clients/screens_vouchers.c b/clients/screens_vouchers.c index fedffe9..4cb6d9d 100644 --- a/clients/screens_vouchers.c +++ b/clients/screens_vouchers.c @@ -137,7 +137,7 @@ static int vd_key(void *ud, int ch) int asel = tui_select_list("Underlag", alines, (int)ctx->natts, 0, 0, &acursor, 0, "ta bort", 0); if (asel >= 0) { - attachment_download(a, aids[asel]); + attachment_view_or_download(a, aids[asel]); } else if (asel == -6 && acursor >= 0 && (size_t)acursor < ctx->natts) { char q[320]; @@ -743,6 +743,23 @@ static int64_t vform_post(struct vform *vf, int dry) replayed ? " — redan bokfört (idempotent)" : ""); free(ser); free(r); + if (strcmp(vf->series, a->default_series) != 0) { + yyjson_mut_doc *sd = yyjson_mut_doc_new(NULL); + yyjson_mut_val *so = yyjson_mut_obj(sd); + yyjson_mut_doc_set_root(sd, so); + yyjson_mut_obj_add_strcpy(sd, so, "key", "series_voucher"); + yyjson_mut_obj_add_strcpy(sd, so, "value", vf->series); + char *sargs = yyjson_mut_write(sd, 0, NULL); + yyjson_mut_doc_free(sd); + if (sargs) { + char *sr = client_rpc(&a->conn, "settings.set", + a->session, a->org, sargs); + free(sr); + free(sargs); + } + snprintf(a->default_series, sizeof a->default_series, "%s", + vf->series); + } free(args); return id; } @@ -789,21 +806,33 @@ int64_t vouchers_new_prefill(struct app *a, const struct voucher_prefill *p) if (p->description && *p->description) snprintf(vf.desc, sizeof vf.desc, "%s", p->description); if (p->bank_account && *p->bank_account) { - snprintf(vf.rows[0].account, sizeof vf.rows[0].account, "%s", - p->bank_account); int64_t amt = p->amount_ore < 0 ? -p->amount_ore : p->amount_ore; char tmp[32]; tui_kr_format(amt, tmp, sizeof tmp); - if (p->amount_ore > 0) + snprintf(vf.rows[0].account, sizeof vf.rows[0].account, "%s", + p->bank_account); + if (p->counter_account && *p->counter_account && + p->amount_ore > 0) { snprintf(vf.rows[0].debit, sizeof vf.rows[0].debit, "%s", tmp); - else if (p->amount_ore < 0) + snprintf(vf.rows[1].account, sizeof vf.rows[1].account, "%s", + p->counter_account); + snprintf(vf.rows[1].credit, sizeof vf.rows[1].credit, "%s", + tmp); + } else if (p->amount_ore > 0) { + snprintf(vf.rows[0].debit, sizeof vf.rows[0].debit, "%s", + tmp); + } else if (p->amount_ore < 0) { snprintf(vf.rows[0].credit, sizeof vf.rows[0].credit, "%s", tmp); + } } - if (p->description && *p->description) + if (p->description && *p->description) { snprintf(vf.rows[0].text, sizeof vf.rows[0].text, "%s", p->description); + snprintf(vf.rows[1].text, sizeof vf.rows[1].text, "%s", + p->description); + } } int text_w = COLS - 60; if (text_w < 8) @@ -836,7 +865,7 @@ int64_t vouchers_new_prefill(struct app *a, const struct voucher_prefill *p) tui_rt_normalize(&vf.rt); const char *hint = "Enter = ändra fält Tab = byta fält F4 = mall" " ^F = bifoga fil F5 = validera ^X = rensa rad" - " ^Enter = bokför Esc = avbryt"; + " F9 = bokför Esc = avbryt"; for (;;) { int rr = tui_rt_run("Nytt verifikat", &vf.rt, hint); if (rr == -1) |
