aboutsummaryrefslogtreecommitdiff
path: root/src/cmd_settings.c
diff options
context:
space:
mode:
authorAnders Betts <anders.betts@gmail.com>2026-09-22 09:04:27 +0200
committerAnders Betts <anders.betts@gmail.com>2026-09-22 09:04:27 +0200
commit227d0422da0062410c85529bc999d7e509d9de78 (patch)
tree23102d1fb049b610ec154e7c136e3d92d941bd6d /src/cmd_settings.c
parent8ceb1340a9030bb1030be61003dc65b444732b9e (diff)
downloadbokf-227d0422da0062410c85529bc999d7e509d9de78.tar.gz
bokf-227d0422da0062410c85529bc999d7e509d9de78.zip
documents: org name in the invoice and payslip headers, document_header_colorv0.1.63
Diffstat (limited to 'src/cmd_settings.c')
-rw-r--r--src/cmd_settings.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/cmd_settings.c b/src/cmd_settings.c
index f41f904..5bac3d9 100644
--- a/src/cmd_settings.c
+++ b/src/cmd_settings.c
@@ -22,7 +22,7 @@ static yyjson_mut_val *h_settings_get(struct req *r)
int have_default = 0, have_bank = 0, have_receivable = 0, have_revenue = 0;
int have_password = 0, have_security = 0;
int have_voucher = 0, have_invoice = 0, have_payroll = 0;
- int have_bokslut = 0, have_ib = 0;
+ int have_bokslut = 0, have_ib = 0, have_header_color = 0;
char legacy_series[16] = "A";
sqlite3_stmt *st = NULL;
if (sqlite3_prepare_v2(
@@ -59,6 +59,8 @@ static yyjson_mut_val *h_settings_get(struct req *r)
have_receivable = 1;
} else if (strcmp(k, "invoice_revenue_account") == 0) {
have_revenue = 1;
+ } else if (strcmp(k, "document_header_color") == 0) {
+ have_header_color = 1;
} else if (strcmp(k, "smtp_security") == 0) {
have_security = 1;
}
@@ -87,6 +89,9 @@ static yyjson_mut_val *h_settings_get(struct req *r)
if (!have_revenue)
yyjson_mut_obj_add_strcpy(r->rdoc, o, "invoice_revenue_account",
"3001");
+ if (!have_header_color)
+ yyjson_mut_obj_add_strcpy(r->rdoc, o, "document_header_color",
+ "#314c59");
if (!have_security)
yyjson_mut_obj_add_strcpy(r->rdoc, o, "smtp_security", "starttls");
yyjson_mut_obj_add_bool(r->rdoc, o, "smtp_password_set", have_password);
@@ -162,7 +167,7 @@ static yyjson_mut_val *h_settings_set(struct req *r)
return settings_result(r, key, "[redacted]", 0);
}
size_t maxlen;
- int digits_only = 0, bankgiro = 0, port = 0, security = 0;
+ int digits_only = 0, bankgiro = 0, port = 0, security = 0, color = 0;
if (strcmp(key, "default_series") == 0 ||
strcmp(key, "series_voucher") == 0 ||
strcmp(key, "series_invoice") == 0 ||
@@ -193,6 +198,9 @@ static yyjson_mut_val *h_settings_set(struct req *r)
bankgiro = 1;
} else if (strcmp(key, "invoice_our_ref") == 0) {
maxlen = 64;
+ } else if (strcmp(key, "document_header_color") == 0) {
+ maxlen = 7;
+ color = 1;
} else
return fail(r, "UNSUPPORTED", "unknown setting");
size_t len = strlen(value);
@@ -209,6 +217,8 @@ static yyjson_mut_val *h_settings_set(struct req *r)
return failf(r, "INVALID_ARGS",
"%s must not contain control characters", key);
}
+ if (color && !util_hex_color_valid(value))
+ return failf(r, "INVALID_ARGS", "%s must be #rrggbb", key);
if (port) {
long v = strtol(value, NULL, 10);
if (v < 1 || v > 65535)
@@ -252,7 +262,8 @@ static yyjson_mut_val *h_settings_set(struct req *r)
static const struct cmd_arg args_settings_set[] = {
{ "key", ARG_STR, 1, NULL, NULL,
"default_series, attachment_dir, bank_account,"
- " invoice_receivable_account, invoice_revenue_account, smtp_host,"
+ " invoice_receivable_account, invoice_revenue_account,"
+ " invoice_bankgiro, invoice_our_ref, document_header_color, smtp_host,"
" smtp_port, smtp_user, smtp_from, smtp_reply_to, smtp_security or"
" smtp_password" },
{ "value", ARG_STR, 0, NULL, NULL,