Commit Graph

831 Commits

Author SHA1 Message Date
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
Dries Peeters 753b98d272 feat: add Peppol e-invoicing and stock lot valuation
Add Peppol BIS Billing 3.0 (UBL) invoice sending via a configurable access point, including admin-configurable settings, per-invoice send history, and documentation/README updates.

Also introduce stock lots/allocations (valuation layers) with supporting inventory route/report/UI updates and hardened startup migration handling.
2026-01-03 07:00:30 +01:00
Dries Peeters c5666f5eae Merge pull request #384 from DRYTRIX/rc/v4.8.12
fix: make migration 081 tolerant of existing settings columns
v4.8.12
2026-01-02 19:08:30 +01:00
Dries Peeters 1ea87c81e5 fix: make migration 081 tolerant of existing settings columns
Some legacy/partially-upgraded databases already have one or more integration OAuth columns in settings (e.g. google_calendar_client_id). Only add missing columns and set defaults for columns that exist so upgrades don't fail with DuplicateColumn.

Bump version to 4.8.12.
2026-01-02 19:05:46 +01:00
Dries Peeters 51a1af4e66 Merge pull request #383 from DRYTRIX/rc/v4.8.11
Rc/v4.8.11
v4.8.11
2026-01-02 17:22:35 +01:00
Dries Peeters bd59488132 fix: make template-related migrations idempotent
Avoid DuplicateTable/duplicate index errors on partially-migrated databases by skipping creation of existing template tables (quote_templates, project_templates, time_entry_templates) and only creating missing indexes/columns.

Also bump version to 4.8.11.
2026-01-02 17:19:19 +01:00
Dries Peeters dcc4f87769 fix: make migration 075 idempotent for existing link_templates
Skip creating link_templates when it already exists and only create missing indexes, so partially-migrated customer databases can continue upgrading.
2026-01-02 17:12:18 +01:00
Dries Peeters 037b45a3c4 Merge pull request #382 from DRYTRIX/rc/v4.8.10
Rc/v4.8.10
v4.8.10
2026-01-02 16:05:11 +01:00
Dries Peeters dd4a5e2f21 Update cd-release.yml 2026-01-02 16:02:04 +01:00
Dries Peeters 7f209751ab fix: harden Alembic upgrades on legacy databases
Prevent Postgres upgrades from failing when alembic_version.version_num is too small for long revision IDs, and add an alias migration to bridge older installs that recorded '067_add_integration_credentials'.
2026-01-02 15:53:51 +01:00
Dries Peeters 71a71d0536 Merge pull request #381 from DRYTRIX/rc/v4.8.9
Rc/v4.8.9
v4.8.9
2026-01-02 07:55:23 +01:00