Commit Graph

841 Commits

Author SHA1 Message Date
Dries Peeters 1469a565de feat: improve Docker compose setup and HTTPS certificate generation
- Update docker-compose files with improved service configuration
- Add Dockerfile.certgen for automated certificate generation
- Enhance HTTPS auto-setup documentation
- Update Docker compose setup documentation
2026-01-07 20:04:46 +01:00
Dries Peeters 44b5a3ac16 feat: enhance OIDC metadata fetching with DNS resolution strategies
- Add multiple DNS resolution strategies (socket, getaddrinfo, auto)
- Implement IP address caching with TTL for improved performance
- Add retry logic with exponential backoff for metadata fetching
- Support Docker internal service name resolution
- Add connection pooling and optimized HTTP session handling
- Improve error classification and diagnostics
- Add comprehensive OIDC configuration options in config.py
- Update OIDC initialization in app factory with lazy loading support
- Add background metadata refresh scheduling
- Update documentation with troubleshooting guide and setup instructions
2026-01-07 20:04:43 +01:00
Dries Peeters b00d75782f Fix template permissions and setup configuration
- Add permission check for payment gateway edit button
- Fix project view template permission check for budget analysis link
- Update setup.py configuration
2026-01-07 13:19:04 +01:00
Dries Peeters e6ae7dd208 Improve CalDAV integration and integration service
- Enhance CalDAV calendar integration with improved event handling and error management
- Update integration service to support admin override for testing integrations
- Fix integration route handling for per-user vs global integrations
- Improve test_connection method to properly handle admin access and global integrations
2026-01-07 13:18:56 +01:00
Dries Peeters 14d673a4a8 Allow auto-imported time entries without project or client
- Add migration to update check constraint allowing NULL project_id and client_id for source='auto' entries
- Update TimeEntry model validation to allow entries without project/client when source='auto'
- Update TimeEntryCreateSchema to allow entries without project/client when source='auto'
- Enables calendar integrations to import entries that don't have project/client mapping yet
2026-01-07 13:18:40 +01:00
Dries Peeters 1bc4074f6b Fix permission checks and update version to 4.9.11
- Fix has_any_permission() function calls: change from list syntax to argument syntax in base.html, clients/view.html, and projects/view.html
- Add permission checks to navigation menu items: Issues menu now requires view_all_issues or create_issues permission, Payment Gateways requires manage_payment_gateways permission
- Add delete_projects permission to Manager role in permissions_seed.py
- Bump version to 4.9.11
2026-01-07 05:54:38 +01:00
Dries Peeters 7975eeb96d chore: bump version to 4.9.10 2026-01-06 21:51:31 +01:00
Dries Peeters 7322f0e42e feat: add integration setup wizards for all providers
- Add setup wizard system for guided integration configuration
- Create wizard templates for all integration providers:
  * Asana, GitHub, GitLab, Jira, Microsoft Teams
  * Outlook Calendar, QuickBooks, Trello, Xero
- Add wizard_base.html template with common wizard functionality
- Implement setup_wizard route with provider detection
- Update integration list and manage pages with wizard links
- Add has_setup_wizard() helper to check wizard availability
- Create integration_wizard.js for wizard JavaScript functionality
- Improve UX with step-by-step guided setup process
2026-01-06 21:51:22 +01:00
Dries Peeters c844e97741 feat: add OIDC setup wizard with guided configuration
- Add multi-step OIDC setup wizard with progress indicator
- Implement test connection endpoint with DNS and metadata validation
- Add configuration validation endpoint
- Create interactive wizard UI with step-by-step guidance
- Update OIDC debug page to link to setup wizard
- Support testing connection before finalizing configuration
- Add comprehensive error handling and user feedback
2026-01-06 21:51:13 +01:00
Dries Peeters dd666772ac feat: improve OIDC initialization with metadata fetching utility
- Integrate oidc_metadata utility into app initialization
- Use fetch_oidc_metadata() before registering OAuth client
- Add config options for metadata fetch timeout and retry behavior
- Provide better error handling and logging for OIDC setup failures
- Gracefully fall back to Authlib's metadata fetch if utility fails
2026-01-06 21:51:07 +01:00
Dries Peeters 4437488630 feat: add OIDC metadata utility with DNS troubleshooting support
- Add oidc_metadata.py utility module with retry logic and DNS testing
- Implement fetch_oidc_metadata() with exponential backoff retry
- Add test_dns_resolution() for proactive DNS diagnostics
- Create TROUBLESHOOTING_OIDC_DNS.md documentation
- Improves handling of DNS resolution errors in containerized environments
2026-01-06 21:51:02 +01:00
Dries Peeters 2101d5498e feat: Add issue creation and enhance permissions system
- Add issue creation functionality with new route and template
  * Implement new_issue() route with validation and permission checks
  * Create issues/new.html template for issue creation form
  * Add 'Create Issue' button to issues list with permission check

- Enhance inventory stock movement validation
  * Improve devaluation validation with proper error messages
  * Add stock availability checks before devaluation operations
  * Validate devaluation methods (percent/fixed) with proper bounds checking
  * Add better error handling for return and waste movements with devaluation
  * Improve user feedback with specific success messages

- Refine permission system for better granular control
  * Add comprehensive issue permissions (view_all_issues, view_own_issues, create_issues, edit_all_issues, edit_own_issues, delete_issues)
  * Add manage_payment_gateways permission
  * Update payment gateway routes to use manage_payment_gateways instead of admin_access
  * Assign new permissions to appropriate roles (admin, manager)
  * Add permission checks to UI elements (inventory menu, delete project button)

- Fix permission checks in templates
  * Update payment gateway list template to use correct permission
  * Add permission check for project delete button
  * Add permission check for inventory menu visibility
2026-01-06 20:54:56 +01:00
Dries Peeters 7274ce9a1d Version bump 2026-01-05 22:08:50 +01:00
Dries Peeters ad9bfbf1ed Fix client deletion errors and add invoice validation
This commit fixes multiple issues preventing client deletion and adds proper validation to prevent deletion when invoices exist.

Database Schema Fixes:

- Migration 103: Add missing quote_number column to quotes table

  - Handles migration from offer_number to quote_number

  - Generates quote numbers for existing quotes if needed

  - Creates required unique index

- Migration 104: Add all missing columns to quotes table

  - Adds subtotal, tax_amount, visible_to_client columns

  - Adds discount fields (discount_type, discount_amount, discount_reason, coupon_code)

  - Adds payment_terms column

  - Adds approval workflow columns (approval_status, approved_by, approved_at, rejected_by, rejection_reason)

  - Creates required indexes and foreign keys

- Migration 105: Fix client_notifications foreign key cascade

  - Updates client_notifications.client_id FK to ON DELETE CASCADE

  - Updates client_notification_preferences.client_id FK to ON DELETE CASCADE

  - Prevents NOT NULL constraint violations during client deletion

Model Updates:

- Add passive_deletes=True to ClientNotification.client relationship

- Add passive_deletes=True to ClientNotificationPreferences.client relationship

- Add passive_deletes=True to ClientAttachment.client relationship

- Update ClientNote.client relationship to use passive_deletes

Route Updates:

- Add invoice validation to delete_client() and bulk_delete_clients()

- Manually delete notifications before client deletion to prevent SQLAlchemy update issues

Fixes:

- Resolves IntegrityError when deleting clients with notifications

- Resolves missing quote_number column errors

- Resolves missing quotes table columns errors

- Prevents deletion of clients with invoices (data integrity)
2026-01-05 22:07:50 +01:00
Dries Peeters 7f3c8a8819 Fix quotes template 2026-01-05 20:54:59 +01:00
Dries Peeters 596d2815f8 Create 102_add_missing_quotes_template_id.py 2026-01-05 20:50:24 +01:00
Dries Peeters c013adee80 Version Bump 2026-01-05 20:43:17 +01:00
Dries Peeters 6441d060b2 Make default_project_id optional for CalDAV integration
- Remove requirement for default_project_id in CalDAV sync
- Update config schema to mark default_project_id as optional
- Allow importing calendar events without a project assigned
- Update setup form to show project selection as optional
- Remove disabled state from submit button when no projects exist
- Fix number field handling to allow None values for optional fields
- Update sync logic to handle events without project assignment
2026-01-05 20:34:10 +01:00
Dries Peeters 1ae3360b61 Add CalDAV username/password authentication to manage page
- Add CalDAV-specific credential form in manage page (non-OAuth)
- Hide OAuth credentials section for CalDAV provider
- Add update_caldav_credentials action handler
- Allow users to update CalDAV credentials from manage page
- Fixes issue where username/password fields were missing after OAuth migration
2026-01-05 20:34:07 +01:00
Dries Peeters 96f6c19893 Fix admin access to per-user CalDAV integrations
- Add allow_admin_override parameter to get_integration() method
- Allow admins to view, test, and sync per-user integrations
- Fix 'Integration not found' errors for admins accessing CalDAV
- Update all integration routes to pass allow_admin_override flag
2026-01-05 20:34:03 +01:00
Dries Peeters 4ba9d4feb9 chore: bump version to 4.9.7 2026-01-05 19:33:03 +01:00
Dries Peeters 510b264ff0 feat: add input validation and sanitization for tasks and inventory
Add comprehensive input validation and sanitization to prevent
invalid data entry and improve security. This includes:

For tasks:
- Validate and sanitize task names with length constraints
- Validate priority values
- Improve error handling with proper user feedback

For inventory:
- Add required field validation for SKU and name
- Validate and sanitize SKU, name, description, category, and notes
- Add length constraints for all text fields
- Improve error messages for validation failures
- Add validation for date parsing in filters

These changes improve data quality and prevent potential security
issues from unsanitized user input.
2026-01-05 19:32:40 +01:00
Dries Peeters f160fac9c1 refactor: improve error handling with specific exceptions and logging
Replace bare except clauses with specific exception types and add
appropriate logging throughout the codebase. This improves:
- Debugging capabilities with proper error messages
- Code maintainability by catching specific exceptions
- Error tracking through structured logging

Changes include:
- Replace bare except: with specific exception types (JSONDecodeError,
  TypeError, ValueError, OSError, AttributeError, RuntimeError)
- Add logging for error conditions that were previously silently ignored
- Improve error messages with context information
2026-01-05 19:32:25 +01:00
Dries Peeters cb8d091126 Version Bump 2026-01-05 17:06:18 +01:00
Dries Peeters 9beda467c9 Fix migration 088: Make salesman splitting migration idempotent
Add existence checks before adding columns to report_email_schedules table
to prevent DuplicateColumn errors when columns already exist in the database.

This ensures the migration can be safely rerun and handles cases where
columns were manually added or migration partially completed.

Fixes: split_by_salesman and salesman_field_name columns in
report_email_schedules table
2026-01-05 17:00:44 +01:00
Dries Peeters 4d336ac54a feat: improve inventory lot grouping and add issues table migration
- Inventory: Group stock lots by warehouse, unit cost, lot type, and date
  to prevent duplicate display entries
- Inventory: Add total value calculation and display per warehouse
- Migration: Make 082_add_global_integrations migration idempotent with
  existence checks for columns and indexes
- Migration: Add 101_add_issues_table migration for client-reported issues
  tracking with multi-database support (SQLite, PostgreSQL, MySQL)
- Version: Bump to 4.9.5
2026-01-05 16:23:30 +01:00
Dries Peeters 74e2f93f6e Update setup.py 2026-01-04 16:52:35 +01:00
Dries Peeters 8e484a925b feat: Add stock breakdown by valuation with devaluation percentages
Display remaining stock lots grouped by warehouse with devaluation breakdown. Shows quantities at different devaluation rates (e.g. 100pcs at 50%, 100pcs at 75%, 400pcs without devaluation).
2026-01-04 16:43:33 +01:00
Dries Peeters 482d79ce05 version bump to v4.9.3 2026-01-04 06:25:43 +01:00
Dries Peeters d1c3471ba4 docs: Add comprehensive implementation documentation
- Add ENHANCEMENT_PLAN_IMPLEMENTATION_STATUS.md
- Add ENHANCEMENT_PLAN_PROGRESS_SUMMARY.md
- Add COMMENT_ATTACHMENTS_IMPLEMENTATION.md
- Add COMMENT_ATTACHMENTS_OPTIMIZATION.md
- Add FINAL_IMPLEMENTATION_SUMMARY.md

Documentation covers all enhancements, implementation status,
remaining work, and optimization recommendations.
2026-01-04 06:23:55 +01:00
Dries Peeters 700c08b796 test: Add critical edge case tests for InvoiceService
- Add test_create_invoice_from_time_entries_with_tax
- Add test_create_invoice_from_time_entries_no_billable
- Add test_create_invoice_from_time_entries_invalid_project
- Add test_mark_invoice_as_sent_updates_time_entries
- Add test_update_invoice_status

These tests improve coverage for critical business logic including
tax calculations, validation, and status update workflows.
2026-01-04 06:23:51 +01:00
Dries Peeters fed49cea5b perf: Add eager loading for comment attachments in task view
- Add selectinload(Comment.attachments) to task comments query
- Prevent N+1 queries when displaying comments with attachments
- Improve performance for pages with multiple comments

This optimization reduces database queries from N+1 to a single
query for all attachments, significantly improving page load times.
2026-01-04 06:23:48 +01:00
Dries Peeters 31066e7f8d feat: Add comment attachment UI and file upload interface
- Display attachments below comment content with file type icons
- Add file upload form with toggle functionality
- Show download links and delete buttons (permission-based)
- Add JavaScript toggleAttachmentForm function
- Support PDF, image, document, and generic file type icons
- Display file size and metadata

Completes the comment attachments feature with full UI integration.
2026-01-04 06:23:44 +01:00
Dries Peeters b5c65b0ce8 feat: Add comment attachment routes and API support
- Add upload_comment_attachment route with file validation
- Add download_attachment route for file downloads
- Add delete_attachment route with permission checks
- Enhance Comment.to_dict() to include attachments array
- Support file size limits (10 MB) and type validation
- Proper error handling and file cleanup on errors

Routes follow existing attachment patterns from projects/clients.
2026-01-04 06:23:42 +01:00
Dries Peeters f205904742 feat: Add comment attachments model and migration
- Create CommentAttachment model following ProjectAttachment pattern
- Add database migration for comment_attachments table
- Register CommentAttachment in models __init__.py
- Support file uploads (images, PDFs, documents, archives)
- Include file metadata (size, type, uploader, timestamp)
- Cascade delete attachments when comments are deleted

Enables file attachments to comments for better team collaboration.
2026-01-04 06:23:39 +01:00
Dries Peeters 8933d29130 feat: Add offline mode UI indicator component
- Add offline-indicator.html component with sync queue panel
- Integrate offline indicator into base template
- Enhance offline-sync.js updateUI method for better integration
- Add visual feedback with status icons and colors
- Display pending sync items count and status
- Improve user experience for offline functionality

The offline indicator provides real-time feedback about sync status
and allows users to view pending sync operations.
2026-01-04 06:23:35 +01:00
Dries Peeters 8302cc56b8 Update setup.py 2026-01-04 05:17:17 +01:00
Dries Peeters 89ec9149f8 fix(startup): remove redundant traceback import causing UnboundLocalError
Remove redundant 'import traceback' statement inside exception handler
in docker/start-fixed.py. The traceback module is already imported at
the top of the file, and the local import was causing Python to treat
it as a local variable, leading to UnboundLocalError when the exception
handler didn't execute.
2026-01-04 04:34:58 +01:00
Dries Peeters a24d515247 fix(migrations): add idempotency checks to additional migrations
Add existence checks to older migrations (002, 004, 013, 021, 031, 034, 044,
046, 071, 086, 087) to prevent errors when objects already exist.

Also fixes syntax errors in migrations 046 and 086 where index creation
code was incorrectly placed outside try/except blocks.

All affected migrations now:
- Check for table/column/index existence before creating
- Handle existing objects gracefully with informative messages
- Have safe downgrade functions
- Use proper try/except error handling
2026-01-04 04:34:56 +01:00
Dries Peeters fc6e1bb733 fix(migrations): add idempotency checks to recent migrations
Add existence checks to recent migrations (032, 049, 053, 055, 058, 064, 099)
to prevent DuplicateTable and DuplicateColumn errors. These migrations now:

- Check if tables/columns exist before creating them
- Handle cases where objects already exist gracefully
- Provide informative messages about operations
- Have safe downgrade functions with existence checks

This makes migrations more resilient to partial failures and manual
schema changes.
2026-01-04 04:34:52 +01:00
Dries Peeters 1fa86d7706 fix(migrations): add idempotency check for invoice_peppol_transmissions table
Fix migration 098 to check if invoice_peppol_transmissions table exists
before creating it. This prevents DuplicateTable errors when the migration
is run on databases where the table was already created manually or
during a previous partial migration attempt.

The migration now:
- Checks for table existence before creating
- Handles existing tables gracefully
- Provides informative messages
- Has safe downgrade function
2026-01-04 04:34:48 +01:00
Dries Peeters a2156de296 Update setup.py 2026-01-03 20:48:40 +01:00
Dries Peeters f7fe8da015 i18n: update translations for all supported languages
- Update translation files for Arabic, German, English, Spanish
- Update Finnish, French, Hebrew, Italian translations
- Update Norwegian (nb/no) and Dutch translations
- Sync translations across all language files
2026-01-03 20:28:07 +01:00
Dries Peeters 6217dc69ae ui: enhance frontend JavaScript and admin settings
- Update enhanced-ui.js with improved functionality
- Enhance smart-notifications.js for better user feedback
- Improve toast-notifications.js messaging system
- Update admin settings template with better UX
2026-01-03 20:28:04 +01:00
Dries Peeters 29316570fa feat: improve project templates functionality
- Enhance project templates routes and handlers
- Update create and edit templates with better UX
- Improve template management and validation
2026-01-03 20:28:00 +01:00
Dries Peeters eb0cd0005e feat: enhance inventory management features
- Update stock movement model with improved functionality
- Enhance inventory routes and API endpoints
- Improve inventory templates for movements, reports, and stock items
- Add better history tracking and valuation reporting
2026-01-03 20:27:54 +01:00
Dries Peeters 7c169fb401 refactor: improve application initialization and migration handling
- Update app factory pattern with better error handling
- Enhance migration environment configuration
- Improve database initialization and recovery logic
- Add better support for bootstrap and migration modes
2026-01-03 20:27:51 +01:00
Dries Peeters 7dc430405d docs: add database recovery documentation and reset scripts
- Add comprehensive DATABASE_RECOVERY.md with automatic cleanup details
- Add cross-platform database reset scripts (bat, py, sh)
- Document automatic corruption detection and recovery
- Include manual recovery procedures and safety warnings
2026-01-03 20:27:48 +01:00
Dries Peeters e8bf79b325 build: precompile translations at Docker build time
- Add pybabel compile step in Dockerfile for faster startup
- Prevents runtime translation compilation overhead
- Gracefully handles missing Babel during build
2026-01-03 20:27:44 +01:00
Dries Peeters 9a6ede654f Merge pull request #386 from DRYTRIX/rc/v4.9.0
feat: add Peppol e-invoicing and stock lot valuation
v4.9.0
2026-01-03 07:02:27 +01:00