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
f3a3a40480
Add project custom fields and file attachments for projects and clients
...
This commit introduces two major features:
1. Project Custom Fields: Add custom_fields JSON column to projects table (migration 085), support for flexible custom data storage, display and edit in project views
2. File Attachments System: Add project_attachments and client_attachments tables (migration 086), new ProjectAttachment and ClientAttachment models, full CRUD operations, file upload/download/delete, client-visible attachments support
Additional improvements: Enhanced data tables, updated project/client/invoice/timer views, improved UI for attachments and custom fields management
2025-12-03 08:30:15 +01:00