- Added `check_invoice_number_exists` method in `EconomicService` to verify invoice numbers in e-conomic journals. - Introduced `quick_analysis_on_upload` method in `OllamaService` for extracting critical fields from uploaded PDFs, including CVR, document type, and document number. - Created migration script to add new fields for storing detected CVR, vendor ID, document type, and document number in the `incoming_files` table. - Developed comprehensive tests for the quick analysis functionality, validating CVR detection, document type identification, and invoice number extraction.
20 lines
1.1 KiB
SQL
20 lines
1.1 KiB
SQL
-- Migration 011: Quick Analysis on Upload
|
|
-- Adds fields to store automatic CVR, document type, and document number detection
|
|
|
|
-- Add quick analysis fields to incoming_files
|
|
ALTER TABLE incoming_files
|
|
ADD COLUMN IF NOT EXISTS detected_cvr VARCHAR(8),
|
|
ADD COLUMN IF NOT EXISTS detected_vendor_id INTEGER REFERENCES vendors(id),
|
|
ADD COLUMN IF NOT EXISTS detected_document_type VARCHAR(20), -- 'invoice' or 'credit_note'
|
|
ADD COLUMN IF NOT EXISTS detected_document_number VARCHAR(100);
|
|
|
|
-- Add index for CVR lookups
|
|
CREATE INDEX IF NOT EXISTS idx_incoming_files_detected_cvr ON incoming_files(detected_cvr);
|
|
CREATE INDEX IF NOT EXISTS idx_incoming_files_detected_vendor ON incoming_files(detected_vendor_id);
|
|
|
|
-- Add comments
|
|
COMMENT ON COLUMN incoming_files.detected_cvr IS 'Automatically detected CVR number from PDF text';
|
|
COMMENT ON COLUMN incoming_files.detected_vendor_id IS 'Vendor matched by CVR on upload';
|
|
COMMENT ON COLUMN incoming_files.detected_document_type IS 'Auto-detected: invoice or credit_note';
|
|
COMMENT ON COLUMN incoming_files.detected_document_number IS 'Automatically extracted invoice/credit note number';
|