acc_invoices: внутренние проекты (acc_internal_projects), описание, ссылка для оплаты, «Файла Invoice пока нет», строки необязательны, ждёт автор по умолчанию
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ export interface InvoiceRow {
|
||||
/** когда сотрудник поставил отметку «оплачен» */
|
||||
paid_manual_at: Date | string | null;
|
||||
qbo_txn_id?: string | null;
|
||||
no_invoice_file?: boolean;
|
||||
review_date: string | null;
|
||||
amount: number;
|
||||
author: string | null;
|
||||
@@ -73,7 +74,7 @@ export function errorsOf(r: InvoiceRow, now: Date, bankConfirmHours: number): st
|
||||
const e: string[] = [];
|
||||
if (r.is_draft) return e; // у черновика ошибок процесса нет
|
||||
if (!r.cancelled) {
|
||||
if (!r.invoice_url && !r.paid_on) e.push("Нет файла инвойса (ссылки на Drive)");
|
||||
if (!r.invoice_url && !r.paid_on && !r.no_invoice_file) e.push("Нет файла инвойса (ссылки на Drive)");
|
||||
if (r.llm_result && !isOk(r.llm_result)) e.push(`Проверка агента: ${r.llm_result}`);
|
||||
if (r.manual_result && !isOk(r.manual_result)) e.push(`Проверка сотрудника: ${r.manual_result}`);
|
||||
if (r.approves_rejected > 0) e.push("Согласование отклонено");
|
||||
@@ -146,12 +147,12 @@ export const canView = (w: Who, r: Pick<InvoiceRow, "author" | "target_employee"
|
||||
/** Поля, которые можно менять при is_draft = false (остальное - только после возврата в черновик). */
|
||||
export const LIVE_FIELDS = {
|
||||
/** сотрудники бухгалтерии */
|
||||
staff: ["contract_id", "invoice_url", "payment_url", "is_paid_manual", "target_employee", "need_employee_refund", "is_employee_refunded", "review_date", "manual_result", "project_customer_id", "jt_job_id", "pay_method"],
|
||||
staff: ["contract_id", "invoice_url", "payment_url", "is_paid_manual", "target_employee", "need_employee_refund", "is_employee_refunded", "review_date", "manual_result", "project_customer_id", "internal_project_id", "jt_job_id", "pay_method", "pay_link", "description", "no_invoice_file"],
|
||||
/** инициатор: только неплатёжные характеристики */
|
||||
owner: ["target_employee"],
|
||||
} as const;
|
||||
/** Поля черновика. */
|
||||
export const DRAFT_FIELDS = ["vendor_name", "vendor_qbo_id", "invoice_number", "invoice_date", "amount", "project_customer_id", "jt_job_id", "contract_id", "target_employee", "need_employee_refund", "invoice_url", "payment_url", "pay_method", "review_date"] as const;
|
||||
export const DRAFT_FIELDS = ["vendor_name", "vendor_qbo_id", "invoice_number", "invoice_date", "amount", "project_customer_id", "jt_job_id", "contract_id", "target_employee", "need_employee_refund", "invoice_url", "payment_url", "pay_method", "review_date", "internal_project_id", "description", "pay_link", "no_invoice_file"] as const;
|
||||
|
||||
export type Allowed = { ok: true } | { ok: false; status: 400 | 403 | 409; error: string };
|
||||
const no = (status: 400 | 403 | 409, error: string): Allowed => ({ ok: false, status, error });
|
||||
@@ -202,12 +203,12 @@ export function canCancel(w: Who, r: Pick<InvoiceRow, "author" | "target_employe
|
||||
}
|
||||
|
||||
/** Проверка перед отправкой черновика в платёжный процесс. Возвращает список недостающего. */
|
||||
export function submitProblems(r: { vendor_name: string | null; amount: number | null; invoice_date: string | null; invoice_url: string | null }, detailsSum: number | null): string[] {
|
||||
export function submitProblems(r: { vendor_name: string | null; amount: number | null; invoice_date: string | null; invoice_url: string | null; no_invoice_file?: boolean }, detailsSum: number | null): string[] {
|
||||
const p: string[] = [];
|
||||
if (!r.vendor_name?.trim()) p.push("не указан вендор");
|
||||
if (!(r.amount && r.amount > 0)) p.push("сумма должна быть больше нуля");
|
||||
if (!r.invoice_date) p.push("не указана дата инвойса");
|
||||
if (!r.invoice_url) p.push("не приложен файл инвойса");
|
||||
if (!r.invoice_url && !r.no_invoice_file) p.push("не приложен файл инвойса (если его пока нет, отметьте «Файла Invoice пока нет.»)");
|
||||
if (detailsSum !== null && r.amount !== null && Math.abs(detailsSum - r.amount) > 0.005) p.push("сумма строк не равна сумме инвойса");
|
||||
return p;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user