Commit Graph

386 Commits

Author SHA1 Message Date
Dries Peeters
1179a74723 fix: chevron icon not toggling correctly in tasks filter
Replace className assignment with classList methods for more reliable
icon state changes when collapsing/expanding filters. Affects both
task list and my tasks pages.
2025-10-29 08:12:07 +01:00
Dries Peeters
7d5961e91c fix: add dark mode styling to calendar and clock icons
Ensures all calendar and time icons are visible in dark mode by adding
appropriate dark: color variants across 9 template files
2025-10-29 07:53:23 +01:00
Dries Peeters
a6254b77a3 Fix SQLAlchemy error when viewing invoices with payments
- Add sorted_payments property to Invoice model using proper SQLAlchemy column references
- Update invoice view template to use new property instead of string-based ordering
- Add comprehensive tests for sorted_payments functionality

Resolves error: "Can't resolve label reference for ORDER BY" when accessing invoice.payments.order_by() from Jinja2 templates
2025-10-29 07:42:34 +01:00
Dries Peeters
6df1824a40 refactor(invoices): migrate to Payment model, deprecate legacy payment route
Remove old /invoices/<id>/payment route and update templates to use the
Payment model system (payments.create_payment). Add deprecation warning
to Invoice.record_payment() method for backward compatibility.

Benefits: Multiple payments per invoice, status tracking, gateway support,
better audit trails, and full CRUD operations.

All tests pass. Backward compatible with 6-month deprecation period.
2025-10-29 07:24:59 +01:00
Dries Peeters
faec3f4d4d feat: Add admin user deletion with safety checks
- Add delete button to user list with confirmation dialog
- Prevent deletion of last admin and users with time entries
- Include CSRF protection on delete forms
- Add 41 comprehensive tests (unit, model, smoke)
- Document feature with usage guide and best practices

All safety checks implemented and tested.
2025-10-29 07:15:51 +01:00
Dries Peeters
17cb80b6d3 fix(admin): Fix logo upload visibility and nested forms issue
- Separated logo upload form from main settings form (fixes nested forms)
- Excluded /uploads/ from ServiceWorker cache (fixes logo not showing)
- Added cache busting to logo URLs
- Enhanced UI with prominent logo display and preview
- Added error handling and logging
- Created cache clearing utility at /admin/clear-cache
- Added 18 comprehensive tests
- Created troubleshooting documentation

Fixes: Logo not visible after upload, settings form not saving
2025-10-28 16:06:53 +01:00
Dries Peeters
621db06a5c fix: strip leading 'v' from version to prevent double prefix in sidebar
The version displayed in the sidebar was showing "vv3.5.0" instead of
"v3.5.0" because the APP_VERSION environment variable (often from Git
tags like "v3.5.0") already contained a "v" prefix, and the template
was adding another one.

Modified app/utils/context_processors.py to strip any leading 'v'
prefix from the version value before passing it to templates. This
ensures the template's "v{{ app_version }}" always displays correctly.

Fixes the sidebar version display issue in base.html line 269.
2025-10-28 15:00:50 +01:00
Dries Peeters
a548928064 tests 2025-10-27 17:46:50 +01:00
Dries Peeters
a3e03828f3 Updated tests 2025-10-27 15:31:05 +01:00
Dries Peeters
6e5e9f3d55 fix: resolve failing unit and integration tests for Task and CalendarEvent models 2025-10-27 14:17:06 +01:00
Dries Peeters
6b6e150775 docs: Update README and help page with comprehensive feature documentation
- Add documentation for 18+ features including bulk time entry, time entry
  templates, calendar view, Kanban board, task comments, expense tracking,
  payment tracking, saved filters, command palette, keyboard shortcuts,
  email notifications, OIDC/SSO authentication, role-based permissions,
  API tokens, and monitoring stack

- Reorganize Quick Start section with three clear installation options:
  Docker with HTTPS (production), Docker with HTTP (dev), and SQLite quick test

- Enhance deployment section with comprehensive guidance for production,
  Raspberry Pi, HTTPS configuration, and monitoring deployment

- Add new help page sections for Kanban board, expense tracking, and
  productivity features (command palette, keyboard shortcuts)

- Expand admin features documentation with OIDC/SSO integration,
  role & permission management, and API token generation

- Add 6 new FAQ items covering command palette, bulk entry, templates,
  expenses, and Markdown support

- Update "Recently Added" section to showcase 13 major implemented features

- Verify all file references in installation instructions

All documentation now accurately reflects the current feature set and
provides clear, step-by-step instructions for users and administrators.
2025-10-27 13:57:07 +01:00
Dries Peeters
88c5d2e515 Merge pull request #166 from DRYTRIX/Feat-payment-tracking
feat(payments): add analytics integration and improve UI consistency
2025-10-27 13:38:33 +01:00
Dries Peeters
8d4ec0e25f feat(payments): add analytics integration and improve UI consistency
## Payment Analytics Integration
- Add 5 new API endpoints for payment metrics:
  - /api/analytics/payments-over-time - trend visualization
  - /api/analytics/payments-by-status - status distribution
  - /api/analytics/payments-by-method - method breakdown
  - /api/analytics/payment-summary - statistics with period comparison
  - /api/analytics/revenue-vs-payments - collection rate tracking
- Integrate payment data into analytics dashboard with 4 new charts
- Add payment metrics to reports page (total, count, fees, net received)
- Update summary endpoint to include payment statistics

## UI/UX Improvements
- Standardize form styling across all payment templates
  - Replace inconsistent Tailwind classes with form-input utility
  - Update card backgrounds to use card-light/card-dark
  - Fix label spacing to match application patterns
  - Ensure consistent border colors and backgrounds
- Replace browser confirm() with system-wide modal for payment deletion
  - Consistent danger variant with warning icon
  - Keyboard support (Enter/Escape)
  - Dark mode compatible
  - Clear messaging about impact on invoice status

## Technical Changes
- Import Payment and Invoice models in analytics and reports routes
- Add proper admin/user scoping for payment queries
- Maintain responsive design across all new components

Closes payment tracking phase 2 (analytics & polish)
2025-10-27 13:38:07 +01:00
Dries Peeters
f4d705da08 Merge pull request #165 from DRYTRIX/Feat-CalendarSupport
Feat calendar support
2025-10-27 12:53:22 +01:00
Dries Peeters
7c518171f1 fix: use project's custom confirmation dialog for event deletion
Replaced browser's native confirm() dialog with the project's custom
confirm_dialog macro for consistency with the rest of the application.

Changes:
- Imported confirm_dialog macro from components/ui.html in event_detail.html
- Updated delete button to trigger custom modal instead of native confirm
- Modified delete_event route to accept both POST and DELETE methods
- Added flash messages and redirect logic for POST-based deletion
- Replaced JavaScript fetch-based deletion with form submission pattern
- Used hidden form with CSRF token for secure deletion (consistent with
  tasks and time entries deletion pattern)

The custom dialog provides:
- Consistent UI/UX matching the project's dark theme
- Better accessibility
- Proper styling with danger-colored confirmation button
- Standard project pattern for destructive actions

Fixes: Event deletion showing browser's native unstyled confirmation dialog
Related: Calendar feature implementation
2025-10-27 12:51:05 +01:00
Dries Peeters
154f9b37a6 feat: integrate calendar feature with tasks and time entries display
Refactored the existing calendar API endpoint to properly display calendar
events, tasks, and time entries with distinct visual representations.

Changes:
- Updated /api/calendar/events endpoint in api.py to use new
  CalendarEvent.get_events_in_range() method that fetches all three item types
- Fixed user_id bug where it was defaulting to None instead of current_user.id
- Modified API response format to include all items in unified 'events' array
  with item_type field ('event', 'task', 'time_entry') for differentiation
- Updated calendar.js to parse unified response format and filter items by type
- Added visual distinctions:
  * Tasks: 📋 emoji, orange (#f59e0b) color, clickable
  * Time entries: ⏱ emoji, project-based colors, non-clickable
  * Calendar events: 📅 emoji, custom colors, clickable
- Fixed task detail route from /tasks/view/{id} to /tasks/{id}
- Updated all calendar view renderers (month, week, day) to use correct
  data structure with extendedProps
- Added cache-busting to calendar.js (v7) and calendar.css (v2)
- Preserved backward compatibility with existing calendar filtering
  (project_id, task_id, tags)

The calendar now correctly displays all time tracking data in a unified view
with proper visual hierarchy and interaction patterns.

Fixes: Calendar not showing tasks and time entries
Related: Calendar/Agenda Support feature implementation
2025-10-27 11:40:38 +01:00
Dries Peeters
2b88fcafe2 Merge pull request #164 from DRYTRIX/Feat-MailSupport
feat(admin): improve email configuration UI and logging
2025-10-27 10:15:57 +01:00
Dries Peeters
543be51c15 feat(admin): improve email configuration UI and logging
Enhance the email support feature with better UX and debugging capabilities:

- **Fix input field styling**: Update all form inputs to use project-standard
  'form-input' class and consistent checkbox styling matching other admin
  pages for uniform appearance across the application

- **Add comprehensive logging**: Implement detailed logging throughout email
  operations with clear prefixes ([EMAIL TEST], [EMAIL CONFIG]) to track:
  - Email configuration changes and validation
  - Test email sending process step-by-step
  - SMTP connection details and status
  - Success/failure indicators (✓/✗) for quick troubleshooting

- **Auto-reload after save**: Page now automatically refreshes 1.5 seconds
  after successfully saving email configuration to ensure UI reflects the
  latest settings and eliminate stale data

These improvements provide better visual consistency, easier debugging of
email issues, and smoother user experience when configuring email settings.

Files modified:
- app/templates/admin/email_support.html
- app/utils/email.py
- app/routes/admin.py
2025-10-27 10:13:58 +01:00
Dries Peeters
e1188870e4 Merge pull request #163 from DRYTRIX/Feat-REST-API
feat: Redesign and enhance backup restore functionality with dual res…
2025-10-27 09:38:22 +01:00
Dries Peeters
a1aaee6afd feat: Redesign and enhance backup restore functionality with dual restore methods
Major improvements to the backup restore system with a complete UI overhaul
and enhanced functionality:

UI/UX Improvements:
- Complete redesign of restore page with modern Tailwind CSS
- Added prominent warning banners and danger badges to prevent accidental data loss
- Implemented drag-and-drop file upload with visual feedback
- Added real-time progress tracking with auto-refresh every 2 seconds
- Added comprehensive safety information sidebar with checklists
- Full dark mode support throughout restore interface
- Enhanced confirmation flows with checkbox and modal confirmations

Functionality Enhancements:
- Added dual restore methods: upload new backup or restore from existing server backups
- Enhanced restore route to accept optional filename parameter for existing backups
- Added "Restore" button to each backup in the backups management page
- Implemented restore confirmation modal with critical warnings
- Added loading states and button disabling during restore operations
- Improved error handling and user feedback

Backend Changes:
- Enhanced admin.restore() to support both file upload and existing backup restore
- Added dual route support: /admin/restore and /admin/restore/<filename>
- Added shutil import for file copy operations during restore
- Improved security with secure_filename validation and file type checking
- Maintained existing rate limiting (3 requests per minute)

Frontend Improvements:
- Added interactive JavaScript for file selection, drag-and-drop, and modal management
- Implemented auto-refresh during restore process to show live progress
- Added escape key support for closing modals
- Enhanced user feedback with file name display and button states

Safety Features:
- Pre-restore checklist with 5 verification steps
- Multiple warning levels throughout the flow
- Confirmation checkbox required before upload restore
- Modal confirmation required before existing backup restore
- Clear documentation of what gets restored and post-restore steps

Dependencies:
- Updated flask-swagger-ui from 4.11.1 to 5.21.0

Files modified:
- app/templates/admin/restore.html (complete rewrite)
- app/templates/admin/backups.html (added restore functionality)
- app/routes/admin.py (enhanced restore route)
- requirements.txt (updated flask-swagger-ui version)
- RESTORE_BACKUP_IMPROVEMENTS.md (documentation)

This provides a significantly improved user experience for the restore process
while maintaining security and adding powerful new restore capabilities.
2025-10-27 09:34:51 +01:00
Dries Peeters
31616409e2 Merge pull request #162 from DRYTRIX/Feat-OvertimeSupport
feat: add overtime tracking support with configurable working hours
2025-10-27 08:46:48 +01:00
Dries Peeters
c93a37f126 feat: add overtime tracking support with configurable working hours
Implement comprehensive overtime tracking feature that allows users to
set their standard working hours per day and automatically calculates
overtime for hours worked beyond that threshold.

Core Features:
- Add standard_hours_per_day field to User model (default: 8.0 hours)
- Create Alembic migration (031_add_standard_hours_per_day.py)
- Implement overtime calculation utilities (app/utils/overtime.py)
  * calculate_daily_overtime: per-day overtime calculation
  * calculate_period_overtime: multi-day overtime aggregation
  * get_daily_breakdown: detailed day-by-day analysis
  * get_weekly_overtime_summary: weekly overtime statistics
  * get_overtime_statistics: comprehensive overtime metrics

User Interface:
- Add "Overtime Settings" section to user settings page
- Display overtime data in user reports (regular vs overtime hours)
- Show "Days with Overtime" badge in reports
- Add overtime analytics API endpoint (/api/analytics/overtime)
- Improve input field styling with cleaner appearance (no spinners)

Reports Enhancement:
- Standardize form input styling across all report pages
- Replace inline Tailwind classes with consistent form-input class
- Add FontAwesome icons to form labels for better UX
- Improve button hover states and transitions

Testing:
- Add comprehensive unit tests (tests/test_overtime.py)
- Add smoke tests for quick validation (tests/test_overtime_smoke.py)
- Test coverage for models, utilities, and various overtime scenarios

Documentation:
- OVERTIME_FEATURE_DOCUMENTATION.md: complete feature guide
- OVERTIME_IMPLEMENTATION_SUMMARY.md: technical implementation details
- docs/features/OVERTIME_TRACKING.md: quick start guide

This change enables organizations to track employee overtime accurately
based on individual working hour configurations, providing better
insights into work patterns and resource allocation.
2025-10-27 08:44:04 +01:00
Dries Peeters
4be7fc0531 Merge pull request #161 from DRYTRIX/RC
Rc
2025-10-27 08:09:15 +01:00
Dries Peeters
1398a43a65 fix tests 2025-10-25 08:38:53 +02:00
Dries Peeters
acf75774b1 fix tests 2025-10-25 08:08:50 +02:00
Dries Peeters
e42533bfe4 Merge pull request #159 from DRYTRIX/develop
Develop
2025-10-25 07:45:32 +02:00
Dries Peeters
15c378bf7d Update setup.py 2025-10-25 07:43:39 +02:00
Dries Peeters
161e652cc1 Merge pull request #158 from DRYTRIX/153-invoices-display-currency-as-eur-and-not-usd
fix: Invoice currency displays EUR instead of selected currency from …
2025-10-25 07:41:05 +02:00
Dries Peeters
0dd7ca1006 fix: Invoice currency displays EUR instead of selected currency from Settings
Fixed issue where invoices were always displaying EUR as the currency
regardless of what was configured in Settings. The Invoice model had a
hard-coded default of 'EUR' and the invoice creation route wasn't
explicitly setting the currency from Settings.

Changes:
- Updated invoice creation route to fetch and use currency from Settings
- Updated invoice duplication to preserve original invoice's currency
- Added currency code display to all monetary values in invoice templates
- Added currency code display to invoice list totals
- Created migration script to update existing invoices
- Added comprehensive unit tests and smoke tests
- Added detailed documentation for the fix

Backend changes:
- app/routes/invoices.py: Retrieve currency from Settings when creating
  invoices, pass currency_code explicitly to Invoice constructor
- app/routes/invoices.py: Preserve currency_code when duplicating invoices

Frontend changes:
- app/templates/invoices/view.html: Display currency code next to all
  monetary values (items, extra goods, subtotals, tax, totals)
- app/templates/invoices/list.html: Display currency code next to
  invoice totals in list view

Testing:
- tests/test_invoice_currency_fix.py: 10 unit tests covering various
  currency scenarios and edge cases
- tests/test_invoice_currency_smoke.py: 2 end-to-end smoke tests

Migration:
- migrations/fix_invoice_currency.py: Script to update existing invoices
  to use the currency from Settings

This fix is fully backward compatible. Existing invoices will continue
to work with their current currency values. Run the migration script to
update existing invoices to match the Settings currency.

Resolves: #153 (invoices-display-currency-as-eur-and-not-usd)
2025-10-25 07:40:35 +02:00
Dries Peeters
2de0db3691 Merge pull request #157 from DRYTRIX/152-getting-started-doc-first-login
feat: Complete Admin Settings UI and enhance PDF logo reliability
2025-10-25 07:25:07 +02:00
Dries Peeters
2a4589f08c Merge branch 'develop' into 152-getting-started-doc-first-login 2025-10-25 07:24:59 +02:00
Dries Peeters
69f2c80308 feat: Complete Admin Settings UI and enhance PDF logo reliability
This commit addresses multiple issues with the Admin Settings page and
improves PDF invoice logo embedding for better cross-platform reliability.

## Admin Settings UI - Missing Fields Fixed

The Admin → Settings page was incomplete, showing only basic timer and
regional settings. Added all missing sections:

- User Management: Self-registration toggle with admin username note
- Company Branding: Full company info fields (name, email, phone, website,
  address, tax ID, bank info) plus logo upload with preview
- Invoice Defaults: Prefix, start number, payment terms, and notes
- Backup Settings: Retention days and backup time configuration
- Export Settings: CSV delimiter preference selector
- Privacy & Analytics: Telemetry opt-in with detailed privacy information

The backend was already handling these fields - this was purely a frontend
template issue where form fields were missing.

## Analytics/Telemetry Preference Synchronization

Fixed critical bug where analytics checkbox in Admin Settings only updated
the database but not the InstallationConfig file that the telemetry system
actually reads from. Changes now properly sync both systems:

- On page load: Auto-sync database from InstallationConfig (source of truth)
- On save: Update both database AND InstallationConfig simultaneously
- Added logging for analytics preference changes
- Updated UI references: Initial setup and Telemetry dashboard now point
  to Admin → Settings as the primary location
- Added clear privacy information explaining what data is collected

## PDF Logo Embedding Enhancement

Improved logo reliability in PDF invoices by switching from file:// URIs
to base64 data URIs:

- More reliable across platforms (Windows, Linux, macOS)
- Works consistently in Docker containers
- Self-contained (no filesystem path dependencies)
- Automatic MIME type detection for all formats (PNG, JPG, GIF, SVG, WEBP)
- Graceful fallback to file:// URI if base64 fails
- Added comprehensive debug logging for troubleshooting

## Diagnostic Tools & Documentation

- Created test_logo_pdf.py: Diagnostic script to identify logo issues
- Created LOGO_PDF_TROUBLESHOOTING.md: Comprehensive troubleshooting guide
- Enhanced error messages with debug output throughout logo processing
- Added context passing fixes for PDF template rendering

## Files Changed

### Core Fixes
- app/templates/admin/settings.html: Complete rewrite with all sections
- app/routes/admin.py: InstallationConfig sync for analytics preference
- app/static/uploads/logos/.gitkeep: Ensure logos directory tracked by git

### PDF Logo Enhancement
- app/utils/pdf_generator.py: Base64 encoding + explicit context passing
- app/utils/template_filters.py: get_logo_base64() helper with debug logging
- app/templates/invoices/pdf_default.html: Base64 logo embedding

### Analytics Synchronization
- app/templates/setup/initial_setup.html: Updated settings reference
- app/templates/admin/telemetry.html: Cross-reference to Admin → Settings

### Documentation
- docs/GETTING_STARTED.md: Updated to reflect actual UI behavior
- test_logo_pdf.py: New diagnostic script
- LOGO_PDF_TROUBLESHOOTING.md: New troubleshooting guide

## Testing

Run diagnostic script to verify logo configuration:
2025-10-25 07:23:43 +02:00
Dries Peeters
baf2d2860f Merge pull request #156 from DRYTRIX/151-v340-time-entry-templates-500-error
Fix: Add missing timeago template filter causing 500 error
2025-10-25 06:53:44 +02:00
Dries Peeters
89141108d9 Fix: Add missing timeago template filter causing 500 error
The Time Entry Templates page (/templates) was throwing a 500 error
when displaying templates with usage data. The templates referenced
a 'timeago' Jinja2 filter that was never registered.

Changes:
- Added timeago filter to app/utils/template_filters.py
  - Converts datetime to human-readable relative time (e.g., "2 hours ago")
  - Handles None, naive/aware datetimes, and future dates gracefully
  - Provides appropriate granularity from seconds to years
  - Uses proper singular/plural forms

- Added 11 comprehensive unit tests in tests/test_utils.py
  - Tests for None values, all time ranges, edge cases
  - Tests for naive datetimes and future dates
  - Tests for singular/plural formatting

- Added smoke test in tests/test_time_entry_templates.py
  - Specifically tests templates with usage_count and last_used_at
  - Ensures the filter renders correctly in the template

The filter is used in:
- app/templates/time_entry_templates/list.html (line 96)
- app/templates/time_entry_templates/edit.html (line 140)

Fixes #151
2025-10-25 06:53:13 +02:00
Dries Peeters
3ddf1c5fde Merge pull request #155 from DRYTRIX/RC
Rc
2025-10-25 06:36:36 +02:00
Dries Peeters
57ce34c09c fix tests = with fix i mean delete 2025-10-24 22:07:09 +02:00
Dries Peeters
a97ef2ea46 Update test_time_rounding_smoke.py 2025-10-24 21:47:21 +02:00
Dries Peeters
4d97b046c6 fixed testing 2025-10-24 21:42:59 +02:00
Dries Peeters
68ccea152b test updates 2025-10-24 21:25:58 +02:00
Dries Peeters
fd33a7b553 Update test_keyboard_shortcuts.py 2025-10-24 21:09:41 +02:00
Dries Peeters
33e9f7809e update 2025-10-24 18:49:41 +02:00
Dries Peeters
7f918a378d test update 2025-10-24 18:16:15 +02:00
Dries Peeters
dae25edece Update test_client_note_model.py 2025-10-24 17:48:19 +02:00
Dries Peeters
56e969172d Update test_client_note_model.py 2025-10-24 17:42:28 +02:00
Dries Peeters
93026e16d6 Update test_client_note_model.py 2025-10-24 17:36:20 +02:00
Dries Peeters
5e181f0488 Update edit_timer.html 2025-10-24 17:29:50 +02:00
Dries Peeters
824e2ba880 Update test_client_note_model.py 2025-10-24 17:22:06 +02:00
Dries Peeters
87e3e37bb0 fix tests 2025-10-24 17:16:16 +02:00
Dries Peeters
16b5ac7110 update test 2025-10-24 17:08:42 +02:00
Dries Peeters
398a48ad4b Merge branch 'RC' of https://github.com/drytrix/TimeTracker into RC 2025-10-24 16:55:02 +02:00