acc_invoices: внутренние проекты (acc_internal_projects), описание, ссылка для оплаты, «Файла Invoice пока нет», строки необязательны, ждёт автор по умолчанию
All checks were successful
ci / test (push) Successful in 52s
ci / deploy (push) Successful in 3m5s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-12-04 15:30:38 +03:00
parent ade259515f
commit d0a22b8cec
9 changed files with 93 additions and 29 deletions

View File

@@ -86,7 +86,7 @@ function Main({ me, onLogout }: { me: Me; onLogout: () => void }) {
useEffect(() => { const t = setTimeout(loadList, q ? 250 : 0); return () => clearTimeout(t); }, [loadList, q]);
useEffect(() => { loadDetail(selected); }, [selected, loadDetail]);
useEffect(() => { api<Lookups>("lookups").then(setLookups).catch(() => setLookups({ projects: [], vendors: [], people: [], categories: [], contracts: [] })); }, []);
useEffect(() => { api<Lookups>("lookups").then(setLookups).catch(() => setLookups({ projects: [], internal_projects: [], vendors: [], people: [], categories: [], contracts: [] })); }, []);
useEffect(() => { location.hash = `f=${filter}`; }, [filter]);
useEffect(() => { if (selected && !list.items.some((r) => r.id === selected)) { /* выбранная строка ушла из фильтра: деталь остаётся, пока не выберут другую */ } }, [list, selected]);
@@ -200,7 +200,7 @@ function Main({ me, onLogout }: { me: Me; onLogout: () => void }) {
<strong>{inv.vendor_name} {inv.invoice_number}</strong>
<span className={`badge b-${inv.status}`}>{inv.status_label}</span>
<span className="spacer" />
{inv.editable.length > 0 && <button className="btn small" onClick={() => openForm(inv, detail!.details)}>Редактировать</button>}
{inv.editable.length > 0 && <button className="btn small" onClick={() => openForm(inv, detail!.details.filter((l) => !l.virtual))}>Редактировать</button>}
{inv.is_draft && !inv.cancelled && <button className="btn small primary" onClick={() => act("submit", undefined, "Отправлено в платёжный процесс")}>Отправить в процесс</button>}
{!inv.is_draft && !inv.cancelled && !inv.sent_to_bank && !inv.paid_on && <button className="btn small" onClick={() => act("draft", undefined, "Возвращён в черновик, согласования сброшены")}>Вернуть в черновик</button>}
{me.is_staff && !inv.is_draft && !inv.cancelled && <button className="btn small" onClick={() => { setPendingAction("manual"); setReason(inv.manual_result ?? "OK"); reasonDlg.show(); }}>Проверка: результат</button>}
@@ -228,16 +228,19 @@ function Main({ me, onLogout }: { me: Me; onLogout: () => void }) {
<div className="details">
<section className="panel" aria-label="Строки инвойса">
<div className="panel-links">
<LinkBtn href={inv?.invoice_url} label="Invoice на Google Drive" off="Файла инвойса на Drive нет" />
<LinkBtn href={inv?.invoice_url} label="Invoice на Google Drive" off={inv?.no_invoice_file ? "Файла Invoice пока нет." : "Файла инвойса на Drive нет"} />
{inv?.payment_url && <LinkBtn href={inv.payment_url} label="Платёж на Google Drive" />}
{inv?.pay_link && <LinkBtn href={inv.pay_link} label="Оплатить по ссылке" />}
{showQb && <LinkBtn href={inv?.qbo_txn_id ? qbUrl(inv.qbo_txn_id) : null} label="Invoice в QuickBooks" off="Проводки в QuickBooks нет" />}
</div>
{inv?.no_invoice_file && !inv.invoice_url && <p className="hint">Файла Invoice пока нет.</p>}
{inv?.description && <p className="desc">{inv.description}</p>}
<h2>Строки инвойса</h2>
{inv ? (
<table className="mini">
<tbody>
{detail!.details.map((l) => (
<tr key={l.id}><td>{l.description}</td><td className="muted">{l.category_name}</td><td className="r">{money(l.amount)}</td></tr>
<tr key={l.id}><td>{l.description ?? (l.virtual ? "Вся сумма инвойса (одна строка)" : "")}{l.virtual && l.description ? <span className="muted"> · одна строка на всю сумму</span> : null}</td><td className="muted">{l.category_name}</td><td className="r">{money(l.amount)}</td></tr>
))}
{!detail!.details.length && <tr><td colSpan={3} className="empty">Строк нет</td></tr>}
<tr className="total"><td>Итого по строкам</td><td /><td className="r">{money(lineTotal)}</td></tr>
@@ -296,7 +299,7 @@ function Main({ me, onLogout }: { me: Me; onLogout: () => void }) {
</section>
</div>
{lookups && <FormDialog store={form} lookups={lookups} row={formRow} lines={formLines} onSaved={async (id) => { setSelected(id); await loadList(); await loadDetail(id); }} />}
{lookups && <FormDialog store={form} lookups={lookups} defaultPerson={me.person_id} row={formRow} lines={formLines} onSaved={async (id) => { setSelected(id); await loadList(); await loadDetail(id); }} />}
<Ariakit.Dialog store={reasonDlg} backdrop={<div className="backdrop" />} className="dialog small" aria-label="Комментарий">
<Ariakit.DialogHeading className="dialog-title">{pendingAction === "manual" ? "Результат проверки сотрудником" : "Причина отклонения"}</Ariakit.DialogHeading>
<p className="hint">{pendingAction === "manual" ? "«OK», если ошибок нет, иначе текст проблемы." : "Комментарий увидит бухгалтерия."}</p>