Commit Graph

125 Commits

Author SHA1 Message Date
Christian
0f97dda8cd Fix: Fjern timer/pris/total fra e-conomic varetekst
- Før: 'CC5784. 8.0 timer 1,200,- 9,600 / Arbejde konstant / 09.12.2025 - Marley'
- Nu: 'Arbejde konstant / 09.12.2025 - Marley'
- e-conomic viser timer og priser i egne kolonner, så det er overflødigt i teksten
2025-12-23 01:27:09 +01:00
Christian
5c96639a79 Fix: Gør e-conomic product number konfigurerbar
BUG FIX:
- Hardcoded 'TIME001' eksisterer ikke i e-conomic
- Tilføjet TIMETRACKING_ECONOMIC_PRODUCT setting (default: '1000')
- Produkt nummer kan nu ændres via .env
- Fejl: Product 'TIME001' not found

LØSNING:
Tilføj til .env: TIMETRACKING_ECONOMIC_PRODUCT=XXXX
hvor XXXX er dit produkt nummer for konsulentimer i e-conomic
2025-12-23 01:11:58 +01:00
Christian
05d2ac9356 Fix: Gør e-conomic layout konfigurerbar (layout 21 er historisk)
BUG FIX:
- Hardcoded layout 21 fejler med 'Layout 21 is historic'
- Tilføjet TIMETRACKING_ECONOMIC_LAYOUT setting (default: 19)
- Layout 19 er standard dansk faktura layout
- Kan nu ændres via .env uden kode-ændringer

ERROR: e-conomic API error - layout: Layout '21' is historic
LØSNING: Brug layout 19 eller andet aktivt layout nummer
2025-12-23 01:04:44 +01:00
Christian
a98a5784b7 Fix: Return single order object ved cancel_order (ikke list)
BUG FIX:
- execute_query returnerer list, men TModuleOrder(**updated) forventede dict
- TypeError: argument after ** must be a mapping, not list
- Changed til updated[0] for at få første row
- Dette er den SIDSTE execute_query/execute_query_single bug i order_service.py

ERROR: TModuleOrder() argument after ** must be a mapping, not list
  → return TModuleOrder(**updated)
  → updated er list, skal være dict
2025-12-23 00:46:38 +01:00
Christian
0fdf4549d6 Fix: Tilføj RETURNING id til order INSERT statements
CRITICAL BUG FIX:
- execute_insert() kalder cursor.fetchone() men INSERT havde ingen RETURNING clause
- Forårsagede '500: no results to fetch' ved order oprettelse
- Tilføjet RETURNING id til:
  * tmodule_orders INSERT (linje 222)
  * tmodule_order_lines INSERT (linje 240)
- Opdateret database.py docstring til at gøre RETURNING requirement klart

ERROR: ProgrammingError - no results to fetch
  → INSERT INTO tmodule_orders ... VALUES (...)
  → Manglede RETURNING id
2025-12-23 00:29:25 +01:00
Christian
718de1a6bd Fix: Remove hourly_rate query from customers table (kolonne eksisterer ikke)
BUG FIX:
- _get_hourly_rate() tried to query hourly_rate from customers table
- customers table har ikke hourly_rate kolonne
- Forårsagede '500: no results to fetch' fejl ved order oprettelse
- Changed execute_query_single → execute_query for tmodule_customers check
- Removed hub customer rate check (ikke relevant)
- Falls back til default rate fra settings

ERROR: SELECT hourly_rate FROM customers WHERE id = 512
       → column 'hourly_rate' does not exist
2025-12-23 00:23:01 +01:00
Christian
0205516422 Cleanup: Fjernet duplikat order check i cancel_order 2025-12-22 22:20:20 +01:00
Christian
dd23312731 Fix: Flere steder i order_service brugte execute_query_single forkert 2025-12-22 17:13:10 +01:00
Christian
0d9af55dfc Fix: Timetracking ordre generering brugte execute_query_single i stedet for execute_query 2025-12-22 16:57:52 +01:00
Christian
3628cbd9fe Fix: Kontakt detail viser nu relaterede firmaer i Firmaer fanen 2025-12-22 16:40:49 +01:00
Christian
d2c7a8a624 Fix: SQL ambiguous column error i contacts søgning - prefikseret med c. 2025-12-22 16:04:49 +01:00
Christian
9fe17e7f85 Fix: Tilføjet company_count og company_names til contacts API med JOIN 2025-12-22 15:48:21 +01:00
Christian
ba0a2fd160 Fix: Ændret debug endpoint path for at undgå conflict 2025-12-22 15:43:47 +01:00
Christian
bd2de09076 Add: Debug endpoint for contact-company links 2025-12-22 15:35:26 +01:00
Christian
5bb6e73a26 Fix: Contacts query skulle returnere alle rækker ikke kun én 2025-12-22 15:29:28 +01:00
Christian
e4b940009f Feature: Auto-create customers from vTiger accounts when linking contacts 2025-12-22 15:20:29 +01:00
Christian
e541758c44 Add: Sync diagnostics endpoint for troubleshooting contact linking 2025-12-22 15:14:31 +01:00
Christian
6d949d7060 Refactor: Komplet omskrivning af kontakt sync med simpel logik 2025-12-22 15:05:40 +01:00
Christian
0fb404dff5 Fix: Rettet indentation fejl i kontakt linking kode 2025-12-22 14:41:44 +01:00
Christian
0b8a4ff5d0 Debug: Rettet debug logging counter for kontakter 2025-12-22 14:36:55 +01:00
Christian
82ecfda404 Debug: Tilføjet logging af account_id værdier for kontakter 2025-12-22 14:34:07 +01:00
Christian
6398a7ca5f Debug: Ændret logging level for kontakt linking fejl (debug → info) 2025-12-22 14:25:41 +01:00
Christian
ddcf64ae78 Fix: Tjek for duplicate vtiger_id før update (undgår constraint violation) 2025-12-22 14:15:17 +01:00
Christian
0b6d286332 Debug: Tilføjet bedre logging til vTiger matching for at identificere problem 2025-12-22 14:13:44 +01:00
Christian
64935b5808 Fix: Tilføjet pagination til kontakter + forbedret relation linking 2025-12-22 13:24:41 +01:00
Christian
62fc3cb4dd Fix: Check for existing customer by CVR også (undgå duplicate key error) 2025-12-22 13:18:36 +01:00
Christian
198c6c56f4 Fix: Truncate country code til max 2 chars (ISO format) 2025-12-22 13:17:03 +01:00
Christian
a9f5714662 Feature: Omstruktureret sync - e-conomic er nu primær kilde, vTiger linker bagefter 2025-12-22 13:02:24 +01:00
Christian
e5dc0f64d3 Fix: Rettet vTiger pagination - bruger ID-baseret filtering i stedet for LIMIT OFFSET 2025-12-22 12:59:12 +01:00
Christian
94781227b2 Fix: Implementeret pagination i vTiger sync for at hente ALLE kunder (batch size 200) 2025-12-22 12:53:11 +01:00
Christian
af6e868828 Fix: Tilføjet manglende VTIGER_ENABLED og ECONOMIC_ENABLED fields i Settings 2025-12-22 11:44:13 +01:00
Christian
187b72238d Fix: Fjernet LIMIT fra vTiger sync for at hente ALLE kunder og kontakter 2025-12-22 11:39:07 +01:00
Christian
41f7ae991c Fix: Rettet test-economic endpoint - fjernet ikke-eksisterende get_self() kald 2025-12-22 11:17:36 +01:00
Christian
7fd596612c Feature: Tilføjet /api/v1/system/test-economic endpoint til at teste e-conomic API forbindelse 2025-12-22 11:15:16 +01:00
Christian
35447cbd4f Feature: Tilføjet /api/v1/settings/sync-from-env endpoint til at synkronisere .env værdier ind i settings database 2025-12-22 11:04:09 +01:00
Christian
c5ce819a15 Fix: Rettet typo i e-conomic sync (verifiot_matched_count → verified_count) og tilføjet not_matched til return value 2025-12-22 10:48:04 +01:00
Christian
8b71524437 Add verified count to e-conomic sync (separate new matches from existing verifications) 2025-12-19 16:56:39 +01:00
Christian
030071e8d5 Improve e-conomic sync: Only match new customers, verify existing ones 2025-12-19 16:54:57 +01:00
Christian
5d8617bed3 Fix: Add pagination for e-conomic customers (max 1000 per page) 2025-12-19 16:53:39 +01:00
Christian
f6303fa804 Fix: Change Customer schema datetime fields to str for proper serialization 2025-12-19 16:45:22 +01:00
Christian
c9af509e1c Implement e-conomic customer sync and CVR search (get_customers + search_customer_by_cvr) 2025-12-19 16:41:11 +01:00
Christian
55478c20d3 Add detailed sync logging with precise changes (oprettet/opdateret/linket med firma/CVR info) 2025-12-19 16:36:41 +01:00
Christian
c8e005dd07 Fix: Only fetchall() when query has RETURNING clause or is SELECT 2025-12-19 16:30:03 +01:00
Christian
3f66bd07e6 Fix: Remove WHERE clauses and cf_854 field from vTiger queries (API doesn't support empty string comparison) 2025-12-19 15:34:49 +01:00
Christian
8bc633d59c Fix: Convert vTiger SQL queries to single-line (API requires no line breaks) 2025-12-19 15:28:25 +01:00
Christian
c2cf8cf5a3 Enhance sync logging with detailed stats (behandlet/oprettet/opdateret/sprunget over) 2025-12-19 15:19:36 +01:00
Christian
ed0491c567 Add showNotification function for sync alerts 2025-12-19 13:24:16 +01:00
Christian
6e2a32165e Fix: Close tags grid div properly in settings
Missing closing div tag and malformed comment caused sync tab to be empty
2025-12-19 13:12:33 +01:00
Christian
7c69cb22e7 Feature: Add sync page to settings
- Add Sync navigation tab in settings
- Sync UI with status cards (total, vTiger, e-conomic)
- Action cards for vTiger and e-conomic sync
- Sync log with real-time updates
- JavaScript functions for sync operations
- Backend sync router with vTiger account sync
- Backend vTiger contacts sync with customer linking
- Placeholder for e-conomic sync (needs get_customers method)
- Name normalization for company matching
- CVR number matching and validation
2025-12-19 13:09:42 +01:00
Christian
a011f36385 Feature: Add tags administration to settings page
- Add Tags navigation tab in settings
- Modern card-based grid layout for tags
- Quick stats dashboard (6 KPI cards)
- Smart filtering (type + inactive toggle)
- Create/Edit/Delete functionality
- Color picker with hex input sync
- Auto-color suggestion based on tag type
- Bootstrap Icons selector
- Responsive 3-column layout
2025-12-19 08:06:56 +01:00
Christian
15f39f13ce Fix: Replace execute_query_single with execute_query in email router
execute_query_single function does not exist in database module.
All calls should use execute_query instead.
2025-12-19 07:56:05 +01:00
Christian
fdac8b855e Fix: Strip whitespace from env vars before validation
Pydantic cannot parse 'true   ' (with trailing spaces) as boolean.
Added field_validator to automatically strip whitespace from all string inputs.
2025-12-17 20:58:01 +01:00
Christian
2361bd2277 Fix: Add missing env vars to Settings class and remove inline comments from .env
- Added API_RELOAD, CORS_ORIGINS to Settings
- Added deployment-specific vars: POSTGRES_*, RELEASE_VERSION, GITEA_URL, GITHUB_TOKEN, GITHUB_REPO
- Removed inline comments from boolean values (Pydantic can't parse them)
- Updated CORS middleware to use CORS_ORIGINS with fallback to ALLOWED_ORIGINS
2025-12-17 17:28:50 +01:00
Christian
84485bd294 feat: Implement ticket contacts management with flexible roles and CRUD operations 2025-12-17 16:38:08 +01:00
Christian
0502a7b080 feat: Implement central tagging system with CRUD operations, entity tagging, and workflow management
- Added API endpoints for tag management (create, read, update, delete).
- Implemented entity tagging functionality to associate tags with various entities.
- Created workflow management for tag-triggered actions.
- Developed frontend views for tag administration using FastAPI and Jinja2.
- Designed HTML template for tag management interface with Bootstrap styling.
- Added JavaScript for tag picker component with keyboard shortcuts and dynamic tag filtering.
- Created database migration scripts for tags, entity_tags, and tag_workflows tables.
- Included default tags for initial setup in the database.
2025-12-17 07:56:33 +01:00
Christian
fadf7258de feat: Implement internal comments for customer subscriptions with database support 2025-12-16 22:07:20 +01:00
Christian
ffb3d335bc feat: Add Simply-CRM integration setup documentation and configuration details
docs: Create vTiger & Simply-CRM integration setup guide with credential requirements

feat: Implement ticket system enhancements including relations, calendar events, templates, and AI suggestions

refactor: Update ticket system migration to include audit logging and enhanced email metadata
2025-12-16 15:36:11 +01:00
Christian
3806c7d011 feat(ticket-module): Implement ticket system with comprehensive database schema, permissions, and testing suite
- Added migration 025 for the Ticket System, creating tables for tickets, comments, attachments, worklogs, prepaid cards, and audit logs.
- Introduced migration 026 to add ticket-related permissions to the auth system and assign them to user groups.
- Developed a test suite for the Ticket Module, validating database schema, ticket number generation, prepaid card constraints, service logic, worklog creation, audit logging, and views.
2025-12-15 23:40:23 +01:00
Christian
3fb43783a6 feat: Implement Email Workflow System with comprehensive documentation and migration scripts
- Added Email Workflow System with automated actions based on email classification.
- Created database schema with tables for workflows, executions, and actions.
- Developed API endpoints for CRUD operations on workflows and execution history.
- Included pre-configured workflows for invoice processing, time confirmation, and bankruptcy alerts.
- Introduced user guide and workflow system improvements for better usability.
- Implemented backup system for automated backup jobs and notifications.
- Established email activity log to track all actions and events related to emails.
2025-12-15 12:28:12 +01:00
Christian
38fa3b6c0a feat: Add subscriptions lock feature to customers
- Added a new column `subscriptions_locked` to the `customers` table to manage subscription access.
- Implemented a script to create new modules from a template, including updates to various files (module.json, README.md, router.py, views.py, and migration SQL).
- Developed a script to import BMC Office subscriptions from an Excel file into the database, including error handling and statistics reporting.
- Created a script to lookup and update missing CVR numbers using the CVR.dk API.
- Implemented a script to relink Hub customers to e-conomic customer numbers based on name matching.
- Developed scripts to sync CVR numbers from Simply-CRM and vTiger to the local customers database.
2025-12-13 12:06:28 +01:00
Christian
361f2fad5d feat: Implement vTiger integration for subscriptions and sales orders
- Added a new VTigerService class for handling API interactions with vTiger CRM.
- Implemented methods to fetch customer subscriptions and sales orders.
- Created a new database migration for BMC Office subscriptions, including table structure and view for totals.
- Enhanced customer detail frontend to display subscriptions and sales orders with improved UI/UX.
- Added JavaScript functions for loading and displaying subscription data dynamically.
- Created tests for vTiger API queries and field inspections to ensure data integrity and functionality.
2025-12-11 23:14:20 +01:00
Christian
c4c9b8a04a feat: Enhance email actions UI with improved layout and attachment handling 2025-12-11 12:57:14 +01:00
Christian
7f325b5c32 feat: Implement email management UI with FastAPI and keyword-based classification
- Added FastAPI router for serving email management UI at /emails
- Created Jinja2 template for the email frontend
- Developed SimpleEmailClassifier for keyword-based email classification
- Documented email UI implementation details, features, and API integration in EMAIL_UI_IMPLEMENTATION.md
2025-12-11 12:45:29 +01:00
Christian
8791e34f4e feat: Implement email processing system with scheduler, fetching, classification, and rule matching
- Added EmailProcessorService to orchestrate email workflow: fetching, saving, classifying, and matching rules.
- Introduced EmailScheduler for background processing of emails every 5 minutes.
- Developed EmailService to handle email fetching from IMAP and Microsoft Graph API.
- Created database migration for email system, including tables for email messages, rules, attachments, and analysis.
- Implemented AI classification and extraction for invoices and time confirmations.
- Added logging for better traceability and error handling throughout the email processing pipeline.
2025-12-11 02:31:29 +01:00
Christian
a230071632 feat: Add customer time pricing management page with dynamic features
- Implemented a new HTML page for managing customer time pricing with Bootstrap styling.
- Added navigation and responsive design elements.
- Integrated JavaScript for loading customer data, editing rates, and handling modals for time entries and order creation.
- Included theme toggle functionality and statistics display for customer rates.
- Enhanced user experience with toast notifications for actions performed.

docs: Create e-conomic Write Mode guide

- Added comprehensive documentation for exporting approved time entries to e-conomic as draft orders.
- Detailed safety flags for write operations, including read-only and dry-run modes.
- Provided activation steps, error handling, and best practices for using the e-conomic integration.

migrations: Add user_company field to contacts and e-conomic customer number to customers

- Created migration to add user_company field to contacts for better organization tracking.
- Added e-conomic customer number field to tmodule_customers for invoice export synchronization.
2025-12-10 18:29:13 +01:00
Christian
34555d1e36 feat(timetracking): Implement time tracking module with frontend views, HTML templates, and database migrations
- Added FastAPI router for time tracking views including dashboard, wizard, and orders.
- Created HTML templates for the time tracking wizard with responsive design and Bootstrap integration.
- Developed SQL migration script for the time tracking module, including tables for customers, cases, time entries, orders, and audit logs.
- Introduced a script to list all registered routes, focusing on time tracking routes.
- Added test script to verify route registration and specifically check for time tracking routes.
2025-12-09 22:46:30 +01:00
Christian
3a8288f5a1 feat: Implement quick analysis on PDF upload for CVR, document type, and number extraction
- 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.
2025-12-09 14:54:33 +01:00
Christian
890bd6245d feat: Add template editing functionality and improve file loading logic
- Added an "Edit" button for templates in the templates list, redirecting to the template builder.
- Enhanced loadPendingFiles function to filter files by vendor ID, displaying a message if no files are found.
- Modified openTestModal to load vendor-specific files based on the selected template.
- Updated Ollama model configuration for improved JSON extraction.
- Refactored Ollama service to support different API formats based on model type.
- Implemented lazy loading of templates in TemplateService for better performance.
- Added VAT note extraction for invoice line items.
- Updated Docker Compose configuration for Ollama model settings.
2025-12-08 23:46:18 +01:00
Christian
18b0fe9c05 feat: Enhance billing frontend with Jinja2 templates and improve invoice handling
- Updated billing frontend views to use Jinja2 templates for rendering HTML pages.
- Added support for displaying supplier invoices, template builder, and templates list with titles.
- Introduced a new configuration setting for company CVR number.
- Enhanced OllamaService to support credit notes in invoice extraction, including detailed JSON output format.
- Improved PDF text extraction using pdfplumber for better layout handling.
- Added a modal for editing vendor details with comprehensive fields and validation.
- Implemented invoice loading and display functionality in vendor detail view.
- Updated vendor management to remove priority handling and improve error messaging.
- Added tests for AI analyze endpoint and CVR filtering to ensure correct behavior.
- Created migration script to support credit notes in the database schema.
2025-12-08 09:15:52 +01:00
Christian
dcb4d8a280 feat: Implement supplier invoices management with e-conomic integration
- Added FastAPI views for supplier invoices in the billing frontend.
- Created EconomicService for handling e-conomic API interactions, including safety modes for read-only and dry-run operations.
- Developed database migration for supplier invoices, including tables for invoices, line items, and settings.
- Documented kassekladde module features, architecture, API endpoints, and usage guide in KASSEKLADDE.md.
- Implemented views for overdue invoices and pending e-conomic sync.
2025-12-07 03:29:54 +01:00
Christian
974876ac67 feat: Implement DEV Portal with Kanban board, idea management, and workflow editor
- Added backend routes for DEV Portal dashboard and workflow editor
- Created frontend templates for portal and editor using Jinja2
- Integrated draw.io for workflow diagram editing and saving
- Developed API endpoints for features, ideas, and workflows management
- Established database schema for features, ideas, and workflows
- Documented DEV Portal functionality, API endpoints, and database structure
2025-12-06 21:27:47 +01:00
Christian
3dfc5086c0 feat: Add global search functionality and redirect root to dashboard 2025-12-06 13:13:05 +01:00
Christian
3a35042788 feat: Implement Vendors API and Frontend
- Added a new API router for managing vendors with endpoints for listing, creating, updating, retrieving, and deleting vendors.
- Implemented frontend views for displaying vendor lists and details using Jinja2 templates.
- Created HTML templates for vendor list and detail pages with responsive design and dynamic content loading.
- Added JavaScript functionality for vendor management, including pagination, filtering, and modal forms for creating new vendors.
- Introduced a settings table in the database for system configuration and extended the users table with additional fields.
- Developed a script to import vendors from an OmniSync database into the PostgreSQL database, handling errors and logging progress.
2025-12-06 11:04:19 +01:00
Christian
050e886f22 Add Material Blue design templates for dashboard and customer overview pages 2025-12-06 02:22:01 +01:00
Christian
13f23316a4 Initial BMC Hub setup 2025-12-05 14:22:39 +01:00