- Added new columns to supplier_invoice_lines for contra_account, line_purpose, resale_customer_id, resale_order_number, is_invoiced_to_customer, and invoiced_date.
- Created indexes for faster filtering by purpose and resale status.
- Introduced economic_accounts table to cache e-conomic chart of accounts with relevant fields and indexes.
- Added comments for documentation on new columns and tables.
- Included success message for migration completion.
- Added PostgreSQL client installation to Dockerfile for database interactions.
- Updated BackupScheduler to manage both backup jobs and email fetching jobs.
- Implemented email fetching job with logging and error handling.
- Enhanced the frontend to display scheduled jobs, including email fetch status.
- Introduced email upload functionality with drag-and-drop support and progress tracking.
- Added import_method tracking to email_messages for better source identification.
- Updated email parsing logic for .eml and .msg files, including attachment handling.
- Removed obsolete email scheduler service as functionality is integrated into BackupScheduler.
- Updated requirements for extract-msg to the latest version.
- Created migration script to add import_method column to email_messages table.
- 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
- 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
- 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
BREAKING CHANGES:
- vTiger sync: Never overwrites existing vtiger_id
- Contact sync: REPLACES links instead of appending (idempotent)
- E-conomic sync: Only updates fields it owns (address, city, postal, email_domain, website)
- E-conomic sync: Does NOT overwrite name or cvr_number anymore
ARCHITECTURE:
- Each data source owns specific fields
- Sync operations are now idempotent (can run multiple times)
- Clear documentation of field ownership in sync_router.py
- Contact links deleted and recreated on sync to match vTiger state
FIXED:
- Contact relationships now correct after re-sync
- No more mixed customer data from different sources
- Sorting contacts by company_count DESC (companies first)
- Added address field to UPDATE query in economic sync
- Added address field to INSERT query for new customers
- Fixes issue where address from e-conomic was not synced
- Prevents mixed data (København address with Lundby city/postal)
- Address is now synced along with city, postal_code, country
- 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
- 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()
- Fixed loadSyncStats() to correctly parse API response
- Customers API returns {customers: [...]} not array directly
- Added const data = await response.json() and data.customers
- Fixes sync stats counters showing NaN or incorrect values
- Added EconomicService.search_customer_by_name() method
- Added GET /api/v1/customers/{id}/search-economic endpoint
- Returns matching e-conomic customers by name (partial match)
- Helps find economic customer number for customers without CVR
- Shows customerNumber, name, CVR, email, city in results
- Added POST /api/v1/customers/{id}/link-economic endpoint
- Allows manually setting economic_customer_number for customers without CVR
- Useful for vTiger customers that can't auto-match via CVR or name
- Updates last_synced_at timestamp when linking
- Created VERSION file with current version
- Health endpoints now read version from VERSION file instead of hardcoded
- Fixes issue where health check showed wrong version
- main.py /health and /api/v1/system/health now show correct version
- Fixed UPDATE query to include economic_customer_number field
- Previously only set on INSERT, not UPDATE when matching by CVR
- Now e-conomic customer number is always synced as source of truth
- Fixes issue where customers synced from e-conomic were missing customer numbers
- 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
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
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
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.
- 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
- 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)
- 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
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
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
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
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
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