Commit Graph

97 Commits

Author SHA1 Message Date
alexpolo1
f9484eff3a feat: Enhance project quote generation with hierarchical structure and detailed prompts
- Updated AI prompt in projectQuoteGenerationService.js to include a hierarchical task description format for professional quotes.
- Added critical rules for AI to follow, emphasizing action words and specific material descriptions.
- Created comprehensive documentation for the updated quote system, including examples and guidelines for AI prompts.
- Developed a new layout template for quotes to improve readability and professionalism.
- Established a detailed guide on professional quote structure based on Mikael Holck's standards.
2025-10-30 18:58:22 +00:00
alexpolo1
4a372d2e28 clean up 2025-10-30 18:28:58 +00:00
alexpolo1
2186362e3c Implement Bygma PDF Scraper, Custom Task Creation, Customer Search, and Manual Retrieval Features
- Added `scrape_fixed_v2.py` for scraping installation manuals from Bygma using Playwright.
- Created `test-custom-task.js` to test custom task creation in the smart packages API.
- Developed `test-customer-search.html` for testing customer search functionality with auto-fill capabilities.
- Implemented `test-manuals.html` for testing the retrieval and display of installation manuals.
- Added SQL script `test_project_21_materials.sql` to insert test materials for project 21 and check for manual availability.
2025-10-30 18:04:41 +00:00
alexpolo1
8a44b44770 feat: Add Ordrestyring report integration and profit margin analysis documentation 2025-10-26 08:59:27 +00:00
alexpolo1
d4d3eb3d00 feat: Implement Bygma Prisbog import script to handle CSV import of 54,558 products
feat: Create Python script to scrape 10 installation manuals from Bygma, focusing on construction materials

feat: Develop script to scrape installation manual from Bygma by VareNr, including AI analysis and database storage

feat: Add script to scrape Swedoor Snap-In Karmsat installation manual using product name from URL

chore: Create start script for PM2 to manage services with correct node path

test: Add comprehensive test script for quote generation and PDF endpoints

test: Implement CSV parser tests to verify product presence and data integrity

test: Create readline test script to efficiently read and search for product in CSV
2025-10-26 08:15:46 +00:00
alexpolo1
dc4a470a58 feat: Implementere erfaringsbaserede SmartPackages med varenumre og geometri-beregning
- Oprettet create-packages-simple.js til at generere SmartPackages med detaljerede materialelister og installationstider.
- Oprettet create-packages-v3.js som en minimal version til oprettelse af basis erfaringspakker.
- Tilføjet test-markup-sliders.js for at teste markup sliders for materialer og final review.
- Implementeret test-package-calculation.js til at teste geometri-beregninger for SmartPackages.
- Oprettet test-stern-til-kip-formula.js for at validere brugen af stern_til_kip variabel i formler.
- Tilføjet test-stern-to-ridge-height.js for at sikre korrekt gemning af højde stern til kip i databasen.
2025-10-25 04:52:26 +00:00
alexpolo1
9f7ff8456b Refactor Smart Package Management Service and Frontend Components
- Removed `package_type` from the Smart Package creation process in the backend.
- Updated SQL queries and data handling in `smartPackageManagementService.js` to reflect the removal of `package_type`.
- Simplified the Smart Package form component by removing unnecessary navigation hooks and parameters.
- Adjusted the Smart Packages main component to handle editing and creating packages without direct navigation.
- Enhanced the Smart Packages menu to use callback functions for section changes instead of routing.
- Implemented a new script to create Smart Packages from Ordrestyring cases, including detailed logging and error handling.
- Added a test script to explore cases from Ordrestyring, providing insights into available cases and their details.
- Updated last_sync_status.json with new sync data.
2025-10-24 07:45:19 +00:00
alexpolo1
a632107999 feat: Migrate planning calendar endpoint to GraphQL and remove deprecated services
- Updated `/api/planning/calendar` to use GraphQL for fetching hours data.
- Removed deprecated calendar sync service files.
- Adjusted employee fetching logic to utilize GraphQL for active employees.
- Cleaned up and refactored related code for better maintainability.
- Added comprehensive tests for migration and cleanup, ensuring all endpoints function correctly.
- Documented migration status and test results in KALENDER_CLEANUP_COMPLETE.md.
2025-10-23 22:21:37 +00:00
alexpolo1
1d96d69a58 feat(graphql): Implement comprehensive GraphQL queries for hours, hour types, and business hours
feat(graphql): Create a GraphQL client for improved API interaction and error handling

chore(deprecated): Disable deprecated REST endpoints and notify users of changes

feat(mapping): Develop a script to map Bygma products to categories based on varegrp codes

chore(lock): Update lock file for ordrestyring comprehensive sync

test(graphql): Add tests for new GraphQL endpoints and identify unused code

test(migration): Complete migration tests for GraphQL endpoints and cleanup

test(calendar): Implement tests for calendar and hours GraphQL integration

test(offer): Create tests for GraphQL offer creation endpoint

test(work-breakdown): Add tests for work breakdown and case details endpoints
2025-10-23 22:01:33 +00:00
alexpolo1
a0c5beb738 feat: new bygma webpage crawler, and graphql api full feature set to replace api v2 2025-10-23 13:22:30 +00:00
alexpolo1
0a44cb0ab3 feat: Add API endpoints for fetching tasks and package categories, enhance routing and logging in SmartPackages 2025-10-22 21:25:56 +00:00
alexpolo1
2d7218d67e feat: Implement TaskDialog component for managing tasks in smart packages
- Added TaskDialog component with functionality to create and edit tasks.
- Integrated form validation and error handling for task inputs.
- Implemented step management within tasks, including adding and deleting steps.
- Styled TaskDialog with CSS for improved user experience.

feat: Create SmartPackagesRoutes for navigation and routing

- Established routing for smart packages, including create and edit functionalities.
- Added loading state management for better user feedback during data fetching.
- Integrated SmartPackagesMenu for navigation within the smart packages section.

feat: Add utility functions for formatting data

- Implemented formatting utilities for currency, time, date, and percentages.
- Ensured consistent formatting across the application for better readability.

chore: Update database schema for smart packages

- Extended material_packages table with new fields for estimated hours, hourly rate, and difficulty level.
- Created smart_package_tasks and smart_package_steps tables for task management.
- Added foreign key relationships and indexes for improved database performance.

test: Add API tests for smart packages functionality

- Created test suite for validating smart packages API endpoints.
- Included tests for CRUD operations on smart packages and retrieval of categories and types.
2025-10-22 19:29:21 +00:00
alexpolo1
2c121882bc feat: Enhance CalendarGrid with status filters and improved event handling 2025-10-21 15:21:02 +00:00
alexpolo1
d4fb536198 feat: Filter calendar to show only employees with events
- CalendarGrid now only displays employees who have calendar entries
- Filters by current week - if employee has no events in displayed week, they are hidden
- Reduces clutter and matches user preference to see only active employees
- Dynamic filtering updates when navigating between weeks
- Employee count in footer shows only visible employees with data
2025-10-21 08:47:23 +00:00
alexpolo1
598c0b073c feat: Show customer names in calendar instead of task descriptions
- Calendar now displays customer name as event title (highest priority)
- Fetches customer_number from cases table
- Looks up customer_name from debtors table
- Title priority: 1) customer name, 2) event text/header, 3) case description, 4) type.title
- Added customer_number and customer_name fields to calendar response
- Example: Shows 'Lars Koch Magnussen' and 'Rasmus Gamrath' instead of 'Opgave 2603'
2025-10-21 08:00:04 +00:00
alexpolo1
2df6ee1e7c feat: Calendar shows task titles and integrates directly with Ordrestyring API
- Calendar endpoint now calls Ordrestyring /calendar API directly instead of local database
- Title priority: 1) event text/header, 2) case description from DB, 3) type.title
- Fetches case descriptions from both cases and ordrestyring_cases tables
- Uses local user cache for performance (avoid N+1 queries)
- Maps calendar_type (hours/personal/planned) from API
- Shows proper event colors from type.color field
- Frontend rebuilt with updated calendar display
2025-10-21 07:51:32 +00:00
alexpolo1
f9648991c0 feat: Update CalendarGrid status color mapping and improve database query for calendar events 2025-10-21 07:23:41 +00:00
alexpolo1
f89506ca28 feat: Add new CalendarGrid component matching screenshot design 1-to-1
 New Features:
- CalendarGrid component with employee rows and day columns
- Full status color mapping (Åben, Lukket, Afsluttet, Murer/Tømrer statuser)
- Settings panel with filter options (Planlagt tid, Arbejdstid, etc.)
- Responsive grid layout matching exact screenshot design
- Time range display (07:00-15:30 format)
- Status indicators with proper colors:
  * Åben (green #22c55e)
  * Lukket (orange #f97316)
  * Afsluttet (red #dc2626)
  * Murer igangværende (blue #3b82f6)
  * Murer kommende (cyan #06b6d4)
  * Tømrer igangværende (dark green #059669)
  * Tømrer kommende (light green #10b981)
  * Bogført (gray #6b7280)
  * Ferie/Syg/Fri statuses

📋 Components Added:
- frontend/src/components/CalendarGrid.js
- frontend/src/components/CalendarGrid.css

🔧 Integration:
- Updated PlanningDashboard to use CalendarGrid instead of CalendarView
- Removed unused transformCalendarData function
- Clean import structure
2025-10-21 06:41:22 +00:00
alexpolo1
4a018d7862 fix: Complete codebase audit - 100% API test coverage with all errors fixed
 Fixes implemented:
- Fixed all 6 failing API endpoints (Bygma imports, prices, stats, orders, status-summary, analytics/materials)
- Disabled non-functional sync services (CalendarSync, Materials sync from Ordrestyring API)
- Removed duplicate PUT/DELETE /api/pricing/materials/:id endpoints
- Updated scrape_and_analyze_bygma.py to use service user from .env file
- Fixed analytics/materials query to use project_materials table with denormalized schema

📊 Test results:
- Created comprehensive-api-test.js testing 46 critical endpoints
- Success rate: 100% (46/46 passing)
- All Bygma endpoints working with direct SQL queries
- Orders endpoints protected with API key guards
- No more CalendarSync/Materials sync errors in logs

🗃️ Database schema discoveries:
- project_materials uses material_name (TEXT) not material_id (FK)
- material_prices has is_active not is_current
- bygma_import_log uses import_batch_id not batch_id
- All queries updated to match actual schema
2025-10-21 06:33:28 +00:00
alexpolo1
9cdc4c27b0 test: Add installation manual API tests to build script
- Added test for installation manual search endpoint
- Tests both found and not-found scenarios
- Validates JSON response structure
- Shows step count and tools count in test output
- Updated feature list to include installation manual feature
2025-10-20 10:43:14 +00:00
alexpolo1
adfbef5e3a ui: Improve installation manual button visibility and clean up Smart Packages page
- Changed manual button from icon-only to 'Montagevejledning' text
- Made button larger and more prominent with better styling
- Removed long calculation info box from Smart Packages page
- Cleaned up UI to give more space for actual package selection
- Updated button styling with better padding and hover effects
2025-10-20 10:40:27 +00:00
alexpolo1
2a640821a5 test: Add installation manual API test script 2025-10-20 10:35:59 +00:00
alexpolo1
f2198e9a47 docs: Add installation manual feature documentation 2025-10-20 10:35:26 +00:00
alexpolo1
8727535808 feat: Add installation manual viewer in MaterialsManager
- Added API endpoint /api/customer/installation-manual/search
- Added installation manual button to each material in the list
- Created modal to display installation steps, tools, safety requirements
- Added CSS styling for modal with gradient header and step-by-step view
- Integrated with existing Bygma scraper data in database
- Shows time estimates, weather conditions, and key points
- Mobile-responsive design with smooth animations
2025-10-20 10:34:44 +00:00
alexpolo1
d7f9dfd2da fix: Remove all emojis from scraper to fix ASCII encoding error 2025-10-20 10:21:41 +00:00
alexpolo1
f8512149b5 feat: Add automated Bygma installation manual scraper with AI analysis
Features:
- Automated login and PDF download from Bygma
- GPT-4o AI analysis of installation manuals
- Extracts: steps, time estimates, tools, safety, materials, skill level
- Direct database storage (installation_manuals table)
- Auto-cleanup: deletes PDFs after analysis to save space
- Node.js integration for quote generation

New files:
- scrape_and_analyze_bygma.py - Main automated scraper
- scrape_bygma_with_login.py - Simple download script
- analyze_manual_pdfs.py - Standalone PDF analyzer
- get_installation_tasks.js - Node.js quote integration
- demo_tilbud_opgave.js - Working demo
- BYGMA_AUTOMATION_README.md - Complete documentation

Database:
- installation_manuals table with JSON fields
- Sample data: 1 manual analyzed (Cembrit Bølgeplader)

Integration:
- getInstallationTask(productName, quantity) function
- Returns formatted task descriptions for quotes
- Time calculations: 2.5 hours/m² example

Cleanup:
- Removed old test scripts and debug files
- Removed downloaded PDFs (saved to database)
- Organized documentation files
2025-10-20 10:19:54 +00:00
alexpolo1
0a2c02b51b feat: Implement task categorization service with fuzzy matching and caching
- Added TaskCategorizationService to categorize tasks based on keywords in descriptions.
- Implemented fuzzy matching using Levenshtein distance for better keyword matching.
- Introduced caching for categories and keywords to optimize database queries.
- Added methods for categorizing individual tasks and batch processing for project tasks.
- Created SQL migration scripts for task_categories and category_keywords tables.
- Included default categories and keywords for initial setup.
- Enhanced project_tasks table with new columns for categorization data.
- Added statistics export functionality for category performance analysis.
2025-10-20 09:05:59 +00:00
alexpolo1
550b374e03 feat: Update last sync status and add intelligent help demo documentation 2025-10-15 21:55:18 +00:00
alexpolo1
27182828f2 feat: Simplify experience section for similar projects with a cleaner layout and concise information display 2025-10-15 13:18:07 +00:00
alexpolo1
72ebbc39d8 feat: Implement intelligent task estimation feature with backend service, API endpoint, and frontend integration
- Added ProjectExperienceService to calculate similar projects and scale hours based on area.
- Created API endpoint for fetching similar project experiences.
- Developed frontend components for automatic data fetching and displaying intelligent task estimates.
- Updated build and test scripts to include new features and ensure functionality.
- Added tests for the Experience API to validate responses and data integrity.
2025-10-15 13:07:13 +00:00
alexpolo1
5e9ab79d4f feat: Enhance project creation and flow with SmartPakke navigation
- Updated ProjectCreation component to include a button for direct navigation to SmartPakke.
- Improved ProjectFlow component to handle SmartPakke navigation and project selection logic.
- Added CSS styles for new buttons and layout adjustments in ProjectFlow.
- Introduced a calculation info box in SmartPackagesEnhanced to display detailed pricing and time estimates based on real project data.
- Implemented functionality to load similar projects based on keywords from selected packages.
- Added API endpoint to fetch similar projects based on project descriptions and names.
2025-10-15 12:22:36 +00:00
alexpolo1
6c9c5dd9db feat: Enhance calendar functionality with improved data retrieval and filtering options 2025-10-15 11:30:10 +00:00
alexpolo1
ea5394b0b6 feat: calender impprovements , carptender database 2025-10-15 09:57:16 +00:00
alexpolo1
1d79f4710d feat: Implement comprehensive analytics population and data synchronization
- Added SimpleAnalyticsPopulator class for populating project, employee, customer analytics, and daily metrics.
- Integrated MySQL database connections for tilbudgivern and ordrestyring_local databases.
- Developed sync_ordrestyring_data_old.sh script for comprehensive data synchronization from Ordrestyring API.
- Created test scripts for analytics API and services to validate functionality and data integrity.
- Introduced FixedHistoricalQuoteCalculator and HistoricalQuoteCalculator for generating quotes based on historical data.
- Implemented vary-profit-margins.js to introduce variability in profit margins based on project size and customer type.
2025-10-14 13:06:02 +00:00
alexpolo1
63c38c8cd3 feat: Implement quote creation in ordrestyring system with simulated response and logging 2025-10-14 06:10:47 +00:00
alexpolo1
d83571b669 Refactor code structure for improved readability and maintainability 2025-10-10 22:10:47 +00:00
alexpolo1
c571105a31 🚀 Major System Enhancement: Complete Smart Package System & Production Ready
 New Features:
- Complete Smart Package System with 6 B7 package types
- Enhanced geometry validation with ridgeHeight support
- Automatic material quantity calculations (2.13 plates/m², 2.17m batten/m²)
- Intelligent labor hour calculations (580 DKK/hour)
- Total price calculations with VAT (realistic 800 DKK/m² for B7 roofs)

🔧 Backend Improvements:
- Enhanced PackageService with real Bygma material integration
- Improved CustomerProjects API with package management
- ProjectMaterialService with advanced calculations
- Ridge height validation (0.5-8.0m range)

🎨 Frontend Enhancements:
- Enhanced geometry input component with validation
- Improved SmartPackage components with better UX
- Real-time package selection and pricing display

📦 Deployment & Operations:
- Complete database migration scripts
- Nginx configurations for production deployment
- Build and test automation scripts
- Implementation progress documentation

🧪 System Verification:
- Full end-to-end workflow testing completed
- All calculations validated with realistic pricing
- 165m² B7 project: 132,770 DKK total (competitive market rate)
- Ready for production carpenter use!
2025-10-10 19:39:55 +00:00
dd4dffb517 Add InlineSmartPackage component with styling and functionality
- Implemented InlineSmartPackage component for managing smart packages.
- Added CSS styles for layout, sections, and interactive elements.
- Integrated automatic material and labor calculations based on geometry data.
- Included profit margin settings and total price calculations.
- Enabled selection of predefined packages and dynamic updates of materials and tasks.
- Added functionality to add, update, and remove materials.
- Implemented task selection with detailed calculations for labor costs.
2025-09-26 15:29:47 +02:00
e82f2c7a8f feat: Enhance GeometryInput to auto-select roof type based on selected packages
style: Add form help text styling in ProjectFlow.css

fix: Update SmartPackagesEnhanced to use strict equality checks for isCustom

refactor: Modify unified-server.js to use material_name instead of sku and implement new project_packages table for package management

chore: Create new MCP server configuration files for deployment

chore: Add SQL script to introduce wall_height column in roof_geometry table

build: Implement build and test script for local development

docs: Provide instructions for updating proxy server configuration

chore: Add quick deploy script for streamlined deployment process

test: Create comprehensive test, build, and deploy script for Tilbudgivern
2025-09-26 14:36:19 +02:00
04c2623998 feat: Allow creation of editable copies for standard packages and update edit button behavior 2025-09-26 01:01:05 +02:00
06ec0f01c4 feat: Enhance quote generation with Smart Pakker integration and improved package handling 2025-09-26 00:34:36 +02:00
9f74ec8949 Add initial test suite configuration with Jest and Supertest
- Created package.json for the test suite "tilbudgivern-tests"
- Added scripts for running tests, watching tests, and generating coverage reports
- Included Jest and Supertest as development dependencies
- Configured Jest with a test environment, test match pattern, and coverage collection settings
- Specified coverage output directory
2025-09-26 00:14:38 +02:00
0a4f13b8ea Refactor and cleanup nginx configurations; remove obsolete files and update paths in unified-server.js and related scripts. Add debugging and production testing tools for improved diagnostics and deployment processes. 2025-09-24 21:19:26 +02:00
ae12fc0a44 feat: Implement Material Packages feature
- Added MaterialPackageService for handling CRUD operations on material packages.
- Introduced new API endpoints for creating, retrieving, updating, and deleting material packages.
- Developed frontend components for managing material packages, including forms for creating and listing packages.
- Implemented styling for the Material Packages interface.
- Created SQL setup script for material packages and related tables, including category mapping for Bygma standards.
2025-09-24 15:41:40 +02:00
e45aad27db feat: Update file paths in scripts and add LocalOrdrestyringAnalyzer class for database analysis 2025-09-24 15:27:29 +02:00
ae3ad4918b feat: Implement SmartPackages component and enhance database schema for custom packages and advanced features
- Added SmartPackages component for selecting roof types and packages based on area and search criteria.
- Integrated API calls to fetch packages based on selected roof type and area.
- Implemented package selection logic and summary display for selected packages.
- Enhanced database schema with new tables for custom packages, advanced geometry calculations, and time calculations.
- Added foreign key relationships and indexes for improved performance.
- Created default packages for various roof types and implemented a view for easy package selection.
- Developed a function to calculate total project costs including selected packages and labor costs.
- Added triggers to keep project total updated on package and time calculation changes.
2025-09-24 14:37:15 +02:00
55ed5fd686 Refactor code structure for improved readability and maintainability 2025-09-21 23:54:23 +02:00
23d20fb92b feat: Remove outdated PDF quote file and add enhanced SQL view for quotes
- Deleted the outdated PDF file `updated_real_project_quote.pdf`.
- Created a new SQL view `v_enhanced_quotes` to enhance quote data extraction with improved project and customer name handling, price extraction, labor cost calculation, material cost estimation, and project type icon mapping.
- Updated the existing SQL view `enhanced_quotes_view` to align with the new enhancements.
- Added comprehensive integration tests for the new system, including tests for project review status, reject functionality, and overall quote accessibility.
2025-09-21 23:14:13 +02:00
b2d835d09e feat: Add script to calculate work time based on git commits 2025-09-21 01:17:58 +02:00
7438d33fe9 feat: Implement on-demand PDF download for quotes and improve error handling 2025-09-21 01:15:19 +02:00