6.0 KiB
Installation Manual Integration in Quote Generation
Overview
Updated the quote and PDF generation services to use installation manuals (montagevejledninger) from the database instead of hardcoded descriptions.
Changes Made
1. pdfGenerationService.js
Location: backend/src/services/pdfGenerationService.js
Changes:
- ✅ Made
generateWorkDescription()async - ✅ Queries
installation_manualstable for each material - ✅ Extracts installation steps and key points from database
- ✅ Displays top 5 installation steps per material
- ✅ Shows key points/tips for each material
- ✅ Falls back to generic descriptions if no manual found
- ✅ Updated HTML generation to
awaitthe async method
Example Output:
MONTAGE INSTRUKTIONER:
280 Montagevejledning Boelgepladetag (Cembrit)
1. Kontroller rethed på lægter og spær med retholt eller snor
2. Monter Cembrit Plastudhængsklodser med ventilation ved tagfod
3. Fastgør lægter i henhold til gældende anvisninger
4. Placer Cembrit Bølgeplader på lægterne
5. Monter 2 tagskruer i hver bølgeplade
Vigtige punkter:
• Sørg for minimum 14˚ taghældning
• Fjern bore- og skærestøv straks efter bearbejdning
• Opbevar plader på tørt og plant underlag
2. quoteTemplateService.js
Location: backend/src/services/quoteTemplateService.js
Changes:
- ✅ Made
generateWorkDescription()async - ✅ Same installation manual integration as pdfGenerationService
- ✅ Includes Smart Pakker descriptions (already existing)
- ✅ Includes task descriptions from
project_taskstable - ✅ Updated call site to
awaitthe method
Priority Order:
- Smart Pakker descriptions (if available)
- Task descriptions from database (if available)
- Installation manual steps (from materials)
- Fallback to generic material-based descriptions
3. Database Integration
Table Used: installation_manuals
Key Columns:
product_name- Material name (used for matching)manufacturer- Manufacturer nameinstallation_steps- JSON array of installation stepskey_points- JSON array of important tips/notestime_estimate_per_unit- Time estimate for labor calculationsrequired_tools- JSON array of required toolssafety_requirements- JSON array of safety notes
Query Logic:
SELECT product_name, manufacturer, installation_steps, key_points
FROM installation_manuals
WHERE LOWER(product_name) LIKE LOWER('%material_name%')
ORDER BY created_at DESC
LIMIT 1
Benefits
1. Data-Driven Descriptions
- No more hardcoded descriptions
- Descriptions come from actual installation manuals
- Easy to update via database
2. Professional & Accurate
- Real manufacturer installation instructions
- Step-by-step guidance
- Safety notes and key points included
3. Scalable
- Add new materials by uploading their installation manuals
- System automatically finds and uses them
- No code changes needed for new materials
4. Fallback Safety
- If no manual found, falls back to generic descriptions
- Never shows empty descriptions
- Maintains professional appearance
Usage
Adding New Installation Manuals
Upload a PDF and the system will extract:
- Product name and manufacturer
- Installation steps (parsed into array)
- Key points and safety notes
- Time estimates for labor
Or insert directly via SQL:
INSERT INTO installation_manuals
(product_name, manufacturer, installation_steps, key_points)
VALUES (
'Cembrit Bølgeplader B7',
'Cembrit',
'["Step 1", "Step 2", "Step 3"]',
'["Vigtig punkt 1", "Vigtig punkt 2"]'
);
Testing
Generate a quote for a project:
curl -X POST http://localhost:4031/api/quotes/generate-static \
-H "Content-Type: application/json" \
-d '{"projectId": 19, "calculationId": 1}'
The work description will now include installation manual steps!
Related Services
OpenAI Service Integration
The openaiService.js can be used to:
- Generate enhanced quote text with AI
- Refine existing quotes based on feedback
- Classify and clean OCR-extracted installation manuals
Smart Package Management
The smartPackageManagementService.js already uses installation manuals for:
- Package work descriptions
- Task step-by-step instructions
- Time estimates per task
Database Schema
Current installation_manuals table structure:
id INT(11) AUTO_INCREMENT
product_name VARCHAR(255)
manufacturer VARCHAR(255)
manual_url TEXT
manual_filename VARCHAR(255)
manual_type ENUM('installation','manual','safety')
installation_steps LONGTEXT (JSON)
time_estimate_per_unit DECIMAL(5,2)
time_unit ENUM('per_sqm','per_piece','per_project')
required_tools LONGTEXT (JSON)
safety_requirements LONGTEXT (JSON)
material_requirements LONGTEXT (JSON)
skill_level ENUM('let','medium','svær')
weather_conditions TEXT
key_points LONGTEXT (JSON)
created_at TIMESTAMP
updated_at TIMESTAMP
Next Steps
Recommended Improvements:
- Add more installation manuals - Upload PDFs for common materials
- AI Enhancement - Use OpenAI to enhance descriptions when needed
- Multi-language Support - Store manuals in multiple languages
- Image Support - Include diagrams from installation manuals
- Video Links - Add links to installation video tutorials
Status
✅ COMPLETED - Backend services updated and restarted (54th restart) ✅ TESTED - Installation manual from database successfully parsed ✅ FALLBACK - Generic descriptions work when manual not found ⏳ PENDING - Test with real project containing materials with manuals
Files Changed
/backend/src/services/pdfGenerationService.js- Made async, added manual lookup/backend/src/services/quoteTemplateService.js- Made async, added manual lookup- PM2 restart count: 54
Date: 2025-10-25
Author: GitHub Copilot
Status: Deployed to production