feat: enhance supplier invoices, entity-aware categorization, and new tests
Expand supplier invoice module with overdue cron job, credit note journal entries, and event emissions on approve/mark-paid/create flows. Add entity type (EF/AB) awareness to transaction categorization UI and category mapping logic. Add comprehensive tests for supplier-invoice-entries, transaction-entries, and expanded API route coverage. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
f6a9889f0a
commit
a9bf24ce0b
@@ -0,0 +1,30 @@
|
||||
-- Migration: supplier_invoice_overdue_cron
|
||||
-- Sets overdue status on supplier invoices past due_date via pg_cron
|
||||
|
||||
-- Enable pg_cron extension
|
||||
CREATE EXTENSION IF NOT EXISTS pg_cron WITH SCHEMA pg_catalog;
|
||||
|
||||
-- Grant usage to postgres role (required by Supabase)
|
||||
GRANT USAGE ON SCHEMA cron TO postgres;
|
||||
|
||||
-- Function to update overdue supplier invoices
|
||||
CREATE OR REPLACE FUNCTION public.update_overdue_supplier_invoices()
|
||||
RETURNS void
|
||||
LANGUAGE plpgsql
|
||||
SECURITY DEFINER
|
||||
AS $$
|
||||
BEGIN
|
||||
UPDATE supplier_invoices
|
||||
SET status = 'overdue',
|
||||
updated_at = NOW()
|
||||
WHERE due_date < CURRENT_DATE
|
||||
AND status IN ('registered', 'approved');
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- Schedule daily at 06:00 UTC (matches existing banking sync timing)
|
||||
SELECT cron.schedule(
|
||||
'update-overdue-supplier-invoices',
|
||||
'0 6 * * *',
|
||||
$$SELECT public.update_overdue_supplier_invoices()$$
|
||||
);
|
||||
Reference in New Issue
Block a user