Очередь разбора: сумма/получатель/дата/адрес проекта, дата получения и дни; автоудаление уже проведённого; справочник проектов QuickBooks и закрытые проекты; запрос почты с Delivered-To (по встрече 2026-11-27)
All checks were successful
ci / test (push) Successful in 49s
ci / deploy (push) Successful in 2m58s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-27 18:01:37 +03:00
parent e716c82075
commit 24fed3d5a1
10 changed files with 200 additions and 20 deletions

View File

@@ -0,0 +1,31 @@
-- Завершённые проекты (встреча 2026-11-27): в QuickBooks API нет End date проекта, поэтому закрытые проекты отмечаются здесь
-- (Mathesar, таблица acc_project_closed). Помощник не предлагает закрытые проекты; расходы по ним остаются «потерями», задача уходит человеку.
create table if not exists acc_project_closed (
customer_id text primary key,
closed_on date,
note text
);
alter table acc_project_closed enable row level security;
-- агент категоризации читает справочник закрытых проектов и данные операций ленты
do $$
declare
t text;
r text := 'khb_agent_acc';
tables text[] := array['acc_project_closed','acc_feed_txn'];
begin
if not exists (select 1 from pg_roles where rolname = r) then
raise notice 'роль % не создана: выдать права после создания роли администратором БД', r;
return;
end if;
begin
foreach t in array tables loop
if to_regclass('public.' || t) is null then continue; end if;
execute format('grant select on %I to %I', t, r);
execute format('drop policy if exists %I on %I', r || '_read', t);
execute format('create policy %I on %I for select to %I using (true)', r || '_read', t, r);
end loop;
exception when insufficient_privilege then
raise notice 'нет прав выдать чтение роли % (выдать вручную администратором БД)', r;
end;
end $$;