Commit Graph

43 Commits

Author SHA1 Message Date
Christian
d704a2f780 Debug: Tilføj console.log for at tracke entry loading i wizard 2026-01-02 16:40:03 +01:00
Christian
1c12014c5a Fix: Load specific entry viser nu korrekt entry selv hvis den ikke er pending 2026-01-02 16:34:59 +01:00
Christian
0b06276963 Fix: displayCaseEntries viser nu korrekt den ønskede entry i stedet for altid første entry 2026-01-02 16:25:13 +01:00
Christian
26fda2e419 Fix: Brug korrekt funktion og setup til at vise specifik time entry i wizard 2026-01-02 16:17:46 +01:00
Christian
1356c251e9 Fix: Tilføj manglende except block i get_customer_time_entries 2026-01-02 16:08:59 +01:00
Christian
bf72fc4a49 Fix: Wizard kan nu hoppe direkte til specifik tidsregistrering via time_id parameter 2026-01-02 15:53:00 +01:00
Christian
8100432079 Vis case titel fra vTiger i fakturalinje beskrivelse 2026-01-02 15:27:46 +01:00
Christian
ffbaf6190a Fjern oprundingsinfo fra fakturalinje beskrivelse 2026-01-02 15:17:46 +01:00
Christian
acc89d9f09 Fix: Fjern dato-mønstre fra fakturalinjer + vis oprunding i minutter 2026-01-02 15:12:05 +01:00
Christian
cbc05b52ce fix: Use execute_query_single for case details (v1.3.83)
- Fix get_case_details using execute_query instead of execute_query_single
- execute_query returns list, execute_query_single returns dict
- Prevents 500 error when loading case details
2026-01-02 13:01:20 +01:00
Christian
45d4f78006 debug: Add detailed logging to approval flow (v1.3.82)
- Add logging before approval object creation
- Add logging after approval object creation
- Add logging before database update
- Add logging after database update
- Add time_id to error messages
- This will help diagnose 500 errors on production
2026-01-02 12:58:53 +01:00
Christian
420507027a fix: Remove ge constraint from rounded_to field (v1.3.81)
- Remove ge=0.25 constraint that prevents None values
- Optional fields should accept None without validation
- Fixes approval validation error
2026-01-02 12:56:27 +01:00
Christian
e45b1ed19e fix: Remove float() conversion for Decimal fields (v1.3.78)
- Let Pydantic handle Decimal conversion
- Send approved_hours as Decimal, not float
- Send rounded_to as Decimal, not float
- Add exc_info=True to error logging
2026-01-02 12:51:12 +01:00
Christian
17cd871909 fix: Add Body() annotation to approval endpoint (v1.3.77)
- Add Body(...) to request parameter
- Import Body from fastapi
- Fix FastAPI body parameter handling
2026-01-02 12:49:19 +01:00
Christian
7cb38663bc fix: Timetracking wizard approval endpoint (v1.3.76)
- Fix parameter handling in approve_time_entry endpoint
- Change from query params to body Dict[str, Any]
- Send all required fields to wizard.approve_time_entry()
- Calculate rounded_to if auto-rounding enabled
- Add approval_note, billable, is_travel fields
- Add Dict, Any imports
2026-01-02 12:45:25 +01:00
Christian
bbb9ce8487 Add debug endpoint for timetracking invoice field diagnostics 2026-01-02 00:01:12 +01:00
Christian
0dd24c6420 fix: better error handling for order generation (v1.3.62)
- Added more specific error message when customer not found
- Added debug logging to check customer object type
- Changed error from 'Customer not found' to include customer_id
- Helps diagnose 'string indices must be integers' error
2025-12-24 09:39:31 +01:00
Christian
d228362617 fix: parse customer_rate as float in wizard (v1.3.61)
- Fixed customer_rate being returned as string from DB (NUMERIC type)
- Added parseFloat() when using customer_rate in calculations
- Fixes customer stats showing '-' instead of actual hourly rate
- Applied to loadCustomerContext(), displayCaseEntries(), and approveEntry()
2025-12-24 09:35:46 +01:00
Christian
38a47f4d27 fix: wizard customer_rate field name mismatch (v1.3.55)
- Changed wizard.html to use customer_rate instead of customer_hourly_rate
- Fixes issue where wizard displayed default 1200 DKK instead of customer-specific hourly rate
- Backend API returns customer_rate field (from TModuleTimeWithContext model)
- Frontend now correctly reads customer_rate from API response
- Affected lines: 571, 807, 1084 in wizard.html
2025-12-23 15:12:45 +01:00
Christian
64e85da71c Fix: Use absolute URL for bulk rate update to avoid path resolution issues (v1.3.54) 2025-12-23 15:03:49 +01:00
Christian
641698be8b Fix: Bulk customer rate update using request body (v1.3.53)
Fixed API endpoint to accept JSON request body instead of query params:
- Added TModuleBulkRateUpdate Pydantic model
- Changed endpoint to accept request body
- Fixed parameter references to use request.customer_ids and request.hourly_rate
- Added migration for hourly_rate_updated and time_card_toggled event types

Resolves: 'Not Found' error and audit log constraint violations
2025-12-23 14:39:57 +01:00
Christian
246ad27fe3 Feature: Bulk customer hourly rate updates (v1.3.52)
Added bulk selection and update functionality for customer hourly rates:

Frontend (customers.html):
- Added checkbox column with select-all functionality
- Created bulk price update modal with customer list
- Implemented JavaScript for selection state management
- Shows selected count in UI badge
- Supports indeterminate state for partial selection

Backend (router.py):
- New POST /api/v1/timetracking/customers/bulk-update-rate endpoint
- Accepts {customer_ids: List[int], hourly_rate: float}
- Updates multiple customers in single SQL query
- Creates audit log entries for each updated customer
- Returns updated count

Use case: Select multiple customers and update hourly rate simultaneously
2025-12-23 14:31:10 +01:00
Christian
f8d9e0b252 Feature: Marker vTiger Timelog som faktureret (invoiced)
Når ordre eksporteres til e-conomic opdateres vTiger Timelog med:
- billed_via_thehub_id: Hub ordre ID (f.eks. 5)
- cf_timelog_invoiced: '1' (markér som faktureret)

Dette sikrer at timelogs i vTiger bliver markeret som fakturerede
og kan filtreres/rapporteres korrekt i vTiger.
2025-12-23 14:20:50 +01:00
Christian
acc78b03a3 UI: Vis Hub ordre ID i ordre detaljer efter eksport
- Tilføjet Hub ordre ID til success/info beskeder
- Viser at vTiger Timelog er opdateret med Hub ordre ID
- Gør det tydeligt at koblinger mellem Hub og vTiger er oprettet
2025-12-23 02:03:23 +01:00
Christian
807e7f6395 Feature: Opdater vTiger Timelog med Hub ordre ID efter eksport
- Tilføjet update_timelog_billed() metode til vtiger_sync.py
- Opdaterer billed_via_thehub_id felt i vTiger Timelog records
- Kaldes automatisk efter succesfuld e-conomic eksport
- Respekterer READ_ONLY og DRY_RUN safety flags
- Fejler ikke eksporten hvis vTiger update fejler (bare logger warning)
2025-12-23 01:44:14 +01:00
Christian
a2857f5e12 Fix: Tilføj case_number og Hub ordre nr til e-conomic
- Varetekst: Tilføj case_number tilbage (CC5784)
- Format: 'CC5784 / Arbejde konstant / 09.12.2025 - Marley'
- Tilføj Hub ordre nummer (TT-20251222-005) til otherReference felt
- otherReference vises som 'Øvrig ref' i e-conomic
2025-12-23 01:33:19 +01:00
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
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
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
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