acc_invoices: OK в проверках принимается в любом регистре, латиницей и кириллицей (ОК), в базе хранится как OK
Some checks failed
ci / test (push) Successful in 52s
ci / deploy (push) Has been cancelled

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 20:15:24 +03:00
parent d0a22b8cec
commit dd2b8f6df3
4 changed files with 20 additions and 6 deletions

View File

@@ -6,7 +6,7 @@ import { z } from "zod";
import { AuthError, createAuth, type Actor, type JwtVerifier } from "./auth.js";
import { LOOKUP, getApproves, getContractPanel, getDetails, getInvoice, listInvoices, recomputeApproved, type ListItem } from "./repo.js";
import {
QUICK_FILTERS, STATUS_LABELS, canCancel, canMarkPaid, canReturnToDraft, canSendToBank, canView, dayInTz, editableFields, errorsOf, isStaff, matchesFilter, statusOf, submitProblems,
QUICK_FILTERS, STATUS_LABELS, canCancel, canMarkPaid, canReturnToDraft, canSendToBank, canView, dayInTz, editableFields, errorsOf, isStaff, matchesFilter, normResult, statusOf, submitProblems,
type QuickFilter,
} from "./rules.js";
import type { AccInvoicesSettings } from "./settings.js";
@@ -178,6 +178,7 @@ export function buildApi(deps: ApiDeps): FastifyInstance {
if (!row) return;
const patch = FIELD_SCHEMA.parse(req.body ?? {});
const allowed = new Set(editableFields(a, row));
if (typeof patch.manual_result === "string") patch.manual_result = normResult(patch.manual_result);
const keys = Object.keys(patch);
if (!keys.length) return fail(reply, 400, "нет полей для изменения");
const denied = keys.filter((k) => !allowed.has(k));
@@ -304,7 +305,7 @@ export function buildApi(deps: ApiDeps): FastifyInstance {
if (!row) return;
if (row.is_draft || row.cancelled) return fail(reply, 409, "проверка возможна только у инвойса в платёжном процессе");
const body = z.object({ result: z.string().trim().min(1).max(2000) }).parse(req.body);
await pool.query("update acc_invoices set manual_result = $2, updated_at = now() where id = $1", [row.id, body.result]);
await pool.query("update acc_invoices set manual_result = $2, updated_at = now() where id = $1", [row.id, normResult(body.result)]);
return { ok: true };
});