- Webhook models: remove duplicate index definitions so db.create_all()
no longer raises 'index already exists' (columns already have index=True)
- ImportService: fix circular import by late-importing ClientService,
ProjectService, TimeTrackingService in __init__
- reports: fix F823 by renaming unpack variable _ to _entry_count to avoid
shadowing gettext _ in export_task_excel()
- Code quality: add .flake8 with extend-ignore so flake8 CI passes;
simplify pyproject.toml isort config (drop unsupported options)
- Format: run black and isort on app/
- tests: restore minimal app fixture in test_import_export_models
- In _on_page(), only skip IMAGE elements when their rect does not
intersect the page (was skipping when top-left was outside, which
hid overflowing images).
- Coerce element x, y, width, height to float to avoid type issues.
- In _draw_image_on_canvas(), clip all image drawing to the page
rectangle (beginPath + rect + clipPath) so the visible portion
is shown and overflow is clipped like in the preview.
- Try template image file path before get_image_base64 for more
reliable loading across deployments.
- Add INFO log when drawing template images for debugging.
Fixes#537 (export not showing decorative image when over border).
Decorative images now survive save/load and no longer cause a black PDF preview:
- Sync imageUrl onto groups before generateCode() so template_json has
correct source (invoice and quote layout editors).
- Inject name/imageUrl into design_json with position-based matching so
reordering does not swap or drop URLs.
- Restore name and imageUrl from saved JSON onto canvas on load
(synchronous) so Konva custom attrs are not required.
- Omit decorative image elements with empty source from template_json;
placeholders stay visible in the editor but are not sent to ReportLab.
- ReportLab: explicitly skip decorative images with empty source; validate
base64 data URI payload and decode in try/except to avoid bad PDF output.
Documentation: PDF_LAYOUT_CUSTOMIZATION.md and PDF_EDITOR_ENHANCED_FEATURES.md
updated with decorative image description, state persistence details, and
troubleshooting. CHANGELOG.md updated under [Unreleased] Fixed.
- Admin PDF preview: build all_line_items on invoice wrapper and resolve
table data from element data source (invoice.all_line_items or
invoice.items) so preview matches exported PDF.
- ReportLab: when template uses invoice.items, append both extra_goods
and expenses to table data so all line types appear in PDF.
- Export PDF: explicitly load items, extra_goods, and expenses before
generation so data is in session.
- Docs: recommend invoice.all_line_items for custom templates; document
backward compatibility and preview behavior.
Refs #503
Co-authored-by: Cursor <cursoragent@cursor.com>
PDF invoices were missing extra goods (and expenses) because the ReportLab
template renderer only used invoice.items as the table data source.
- Add invoice.all_line_items to template context: merged list of items,
extra_goods, and expenses with normalized description/quantity/price fields
- Update default template schema to use invoice.all_line_items instead of
invoice.items for the items table
- Add migration to update existing saved templates with the new data source
- Update PDF layout designer: add all_line_items and extra_goods loop options,
default items table to all_line_items
- Add expenses to fallback ReportLab generator for consistency with
pdf_default.html
Fixes#503
Co-authored-by: Cursor <cursoragent@cursor.com>
Fixes issue #432 where decorative images would disappear after saving
the layout and PDF preview would show mostly black.
Root causes:
- Konva's toJSON() doesn't serialize custom attributes like imageUrl
- Warning system adds 'element-overlap' suffix to names, breaking exact matches
- PDF generation tried to render images with empty/invalid sources
Fixes applied:
1. Serialization fixes (quote_pdf_layout.html, pdf_layout.html):
- Manually inject imageUrl into JSON after Konva serialization
- Store imageUrl in a map before serialization and match by position/index
- Ensure primary name is 'decorative-image' before serialization
- Fix name matching to handle 'decorative-image element-overlap' names
2. Restoration fixes (quote_pdf_layout.html, pdf_layout.html):
- Search for decorative images using .includes() instead of exact match
- Match by position when searching saved JSON for imageUrl
- Create placeholder elements when imageUrl is missing
- Ensure decorative image groups remain visible even without imageUrl
3. PDF generation fixes (pdf_generator_reportlab.py):
- Skip decorative images with empty/invalid sources gracefully
- Log warnings instead of attempting to render invalid images
- Prevents black screen in PDF preview
4. Enhanced logging:
- Added [INVOICE] and [SAVE]/[LOAD] prefixes for better debugging
- Verify imageUrl presence in JSON before saving and after loading
The fixes ensure decorative images are properly saved with their imageUrl
attribute, correctly restored on load, and don't break PDF generation when
the image source is missing or invalid.
- Add decorative image element to PDF Layout Designer for both invoice and quote templates
- Implement template-level decorative image upload and management
- Add backend routes for template image upload and serving
- Update PDF generation (HTML preview and ReportLab) to handle template images with transparency preservation
- Sync all decorative image functionality between invoice and quote PDF layout editors
Fixes:
- Fix upload button not opening file picker in invoice template (use fresh DOM references)
- Fix element name matching to handle 'decorative-image element-overlap' format (use .includes() instead of strict equality)
- Fix image restoration after page reload with enhanced JSON searching and position matching
- Fix image persistence in Konva.js serialization/deserialization
Improvements:
- Enhanced image restoration logic with fallback mechanisms
- Improved error handling and console logging for debugging
- Better handling of transparent backgrounds in PDF export
- Consistent behavior between invoice and quote template editors
- Add page dimension validation in PDF generators to prevent content
from being drawn outside page boundaries
- Fix page number positioning in fallback PDF generator to ensure
they stay within page margins
- Add boundary constraints for absolutely positioned elements in
ReportLab template renderer
- Prevent rendering errors when elements exceed page dimensions
- Add ReportLab template renderer with JSON-based template system
- Implement template schema validation and helper functions
- Add database migration for template_json columns
- Update visual editor to generate ReportLab JSON alongside HTML/CSS
- Maintain backward compatibility with legacy templates
- Add comprehensive migration documentation
BREAKING CHANGE: Existing PDF templates need to be saved again through
the visual editor to generate the new template_json format. Templates
will continue to work using the legacy fallback generator until saved.