Done: нельзя при нерешённой проблеме (Can't done - not solved yet. SS, исходная проблема сохраняется), точечная проверка операции в QuickBooks; вложения документов в QuickBooks (qbo-attach, миграция 078, ссылка на Drive в Memo); review-done-action.md по замечаниям
Some checks failed
ci / test (push) Failing after 1m0s
ci / deploy (push) Has been skipped

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 19:32:51 +03:00
parent 2419bd26d3
commit 1112dac733
12 changed files with 523 additions and 55 deletions

View File

@@ -16,6 +16,8 @@ import { GmailClient } from "./gmail.js";
import { GoogleAuth } from "./google.js";
import { runSpamRescue } from "./spam-rescue.js";
import { runCategorizePost } from "./categorize-post.js";
import { makeQboClient } from "./qbo-client.js";
import { runQboAttach } from "./qbo-attach.js";
import { runHistoryWeekly } from "./history-report.js";
import { makeClaudeStatementReader, runMonthlyReconcile } from "./reconcile.js";
import { buildApi } from "./http-api.js";
@@ -29,7 +31,7 @@ import { runReceiptSearch, runReceiptWeeklyReport } from "./receipt-search.js";
import { runReceiptsSlack } from "./receipts.js";
import { loadNonWorkdays } from "./workdays.js";
const { common, service: s } = loadServiceSettings("accounting_automation", accountingSchema);
const { common, service: s, raw: rawSettings } = loadServiceSettings("accounting_automation", accountingSchema);
const log = createLogger("accounting_automation", common.logLevel);
const pool = createPool(common.database.url, 6);
@@ -42,6 +44,9 @@ const claude = makeClaudeRunner({
});
const auth = s.google ? new GoogleAuth({ client_email: s.google.client_email, private_key: s.google.private_key }) : null;
const drive = auth && s.google?.rootFolderId ? new DriveClient({ auth, rootFolderId: s.google.rootFolderId }) : null;
// Прямой клиент QuickBooks (токен у qbo_auth): проверка операции при Done и вложения документов
const qboAuthToken = (rawSettings.qbo_auth as { http?: { token?: string } } | undefined)?.http?.token;
const qbo = qboAuthToken ? makeQboClient({ authUrl: process.env.KHB_QBO_AUTH_URL ?? "http://khb-qbo-auth:8095", authToken: qboAuthToken }) : null;
const slack = s.slack ? createSlackClient({ botToken: s.slack.botToken }) : null;
const notify = async (text: string): Promise<void> => {
@@ -100,6 +105,7 @@ const app = buildApi({
delaySeconds: s.finalizeDelaySeconds,
noReceiptLimitUsd: s.receipts.noReceiptLimitUsd,
notify,
qbo,
notifyPerson: slack ? async (slackUserId, text) => void (await slack.postMessage(slackUserId, text)) : undefined,
});
return booked.closed ? { ...done, booked } : done;
@@ -156,6 +162,10 @@ const app = buildApi({
"history-weekly": () => runHistoryWeekly({ pool, ...reportSlack() }),
"fraud-weekly": () => runFraudWeekly({ pool, ...reportSlack() }),
"categorize-post": async () => runCategorizePost({ pool, claude, log, notify }),
"qbo-attach": async () => {
if (!qbo || !drive) throw new Error("не настроены qbo_auth (токен) или Drive");
return runQboAttach({ pool, qbo, drive, log });
},
"spam-rescue": async () => {
if (!auth || !s.google) throw new Error("не настроены google (ключ сервисного аккаунта)");
return runSpamRescue({ pool, auth, log, mailboxes: s.google.spamRescue.mailboxes, sourceMailbox: s.google.gmailUser, dryRun: s.google.spamRescue.dryRun });