diff --git a/hesabixAPI/adapters/api/v1/report_templates.py b/hesabixAPI/adapters/api/v1/report_templates.py
index b70c7004..6963d8e2 100755
--- a/hesabixAPI/adapters/api/v1/report_templates.py
+++ b/hesabixAPI/adapters/api/v1/report_templates.py
@@ -19,6 +19,11 @@ from app.services.report_template_scope_registry import (
)
from app.services.report_template_gallery import list_gallery_items
from app.services.report_template_v2_service import migrate_builder_design_to_v2
+from app.services.report_template_v3_service import (
+ migrate_v2_design_to_v3,
+ studio_block_catalog,
+)
+from app.services.template_design_v3_compiler import compile_template_design_to_jinja_html
router = APIRouter(prefix="/report-templates", tags=["قالبهای گزارش", "گزارشها"])
@@ -599,6 +604,46 @@ async def preview_report_template(
raise ApiError("PDF_ERROR", f"PDF generation error: {e}", http_status=400) from e
+@router.post(
+ "/business/{business_id}/preview-html",
+ summary="پیشنمایش سریع HTML قالب",
+ description="بدون ذخیرهسازی و بدون تولید PDF؛ برای پیشنمایش زنده Studio.",
+)
+@require_business_access("business_id")
+async def preview_report_template_html(
+ request: Request,
+ business_id: int,
+ body: Dict[str, Any] = Body(...),
+ ctx: AuthContext = Depends(get_current_user),
+ db: Session = Depends(get_db),
+):
+ if not ctx.can_write_section("report_templates"):
+ raise ApiError("FORBIDDEN", "Missing permission: report_templates.write", http_status=403)
+ engine = str((body or {}).get("engine") or "").lower() or "jinja2"
+ content_html = (body or {}).get("content_html") or ""
+ content_css = (body or {}).get("content_css") or ""
+ if len(content_html) > 1_000_000 or len(content_css) > 1_000_000:
+ raise ApiError("PAYLOAD_TOO_LARGE", "HTML/CSS too large for preview", http_status=413)
+ temp = type("T", (), {
+ "engine": engine,
+ "content_html": content_html,
+ "content_css": content_css,
+ "header_html": (body or {}).get("header_html") or "",
+ "footer_html": (body or {}).get("footer_html") or "",
+ "paper_size": (body or {}).get("paper_size") or None,
+ "orientation": (body or {}).get("orientation") or None,
+ "margins": (body or {}).get("margins") or None,
+ "assets": _preview_assets(body or {}, engine),
+ })()
+ try:
+ rendered = ReportTemplateService.render_with_template(temp, (body or {}).get("context") or {})
+ except ApiError:
+ raise
+ except Exception as ex:
+ raise ApiError("TEMPLATE_ERROR", f"Render error: {ex}", http_status=400) from ex
+ return {"ok": True, "html": rendered}
+
+
@router.post(
"/business/{business_id}/preview-pdf",
summary="پیشنمایش PDF قالب (فقط سازندگان)",
@@ -715,6 +760,13 @@ async def report_template_schema(
{"name": "business_logo_data_uri", "desc": "لوگوی کسبوکار"},
{"name": "invoice_footer_note", "desc": "یادداشت پاورقی"},
{"name": "invoice_verify_qr_data_uri", "desc": "QR تأیید فاکتور"},
+ {"name": "show_line_discount_column", "desc": "نمایش ستون تخفیف سطری"},
+ {"name": "show_line_tax_column", "desc": "نمایش ستون مالیات سطری"},
+ {"name": "show_line_amount_before_discount_column", "desc": "نمایش مبلغ پیش از تخفیف"},
+ {"name": "show_line_amount_before_tax_column", "desc": "نمایش مبلغ پیش از مالیات"},
+ {"name": "show_summary_discount", "desc": "نمایش تخفیف در جمعبندی"},
+ {"name": "show_summary_tax", "desc": "نمایش مالیات در جمعبندی"},
+ {"name": "show_summary_amount_without_tax", "desc": "نمایش مبلغ بدون مالیات در جمعبندی"},
]
data["sample_context"].update(
{
@@ -727,6 +779,8 @@ async def report_template_schema(
"issue_date": "1403/10/01",
"subtotal": 1000000,
"discount_total": 50000,
+ "discount_summary_display": "۵٪ (50,000)",
+ "amount_without_tax": 950000,
"tax_total": 85500,
"payable_total": 1035500,
},
@@ -738,7 +792,12 @@ async def report_template_schema(
"quantity_display": "2",
"unit_display": "عدد",
"unit_price": 250000,
- "line_total": 500000,
+ "discount": 25000,
+ "discount_display": "۵٪ (25,000)",
+ "amount_before_discount": 500000,
+ "amount_before_tax": 475000,
+ "tax_amount": 42750,
+ "line_total": 517750,
},
{
"product_name": "کالای نمونه ۲",
@@ -747,7 +806,12 @@ async def report_template_schema(
"quantity_display": "1",
"unit_display": "عدد",
"unit_price": 500000,
- "line_total": 500000,
+ "discount": 25000,
+ "discount_display": "۵٪ (25,000)",
+ "amount_before_discount": 500000,
+ "amount_before_tax": 475000,
+ "tax_amount": 42750,
+ "line_total": 517750,
},
],
"buyer": {"name": "مشتری نمونه"},
@@ -755,6 +819,15 @@ async def report_template_schema(
"payments": [{"method_name": "نقد", "amount": 500000}],
"invoice_footer_note": "این یک پیشنمایش نمونه است.",
"show_invoice_verify_qr": False,
+ "show_line_discount_column": True,
+ "show_line_tax_column": True,
+ "show_line_amount_before_discount_column": True,
+ "show_line_amount_before_tax_column": True,
+ "show_summary_discount": True,
+ "show_summary_tax": True,
+ "show_summary_amount_without_tax": True,
+ "has_line_discount": True,
+ "has_line_tax": True,
"generated_at": "1403/10/01 12:00",
"issuer_name": "کاربر نمونه",
"is_fa": True,
@@ -1015,7 +1088,30 @@ async def report_template_gallery(
ctx: AuthContext = Depends(get_current_user),
db: Session = Depends(get_db),
):
- return {"items": list_gallery_items(module_key=module_key, subtype=subtype)}
+ items = list_gallery_items(module_key=module_key, subtype=subtype)
+ for item in items:
+ try:
+ item["studio_design"] = migrate_v2_design_to_v3(item["default_design"])
+ except ValueError:
+ # Scopeهایی که هنوز وارد Studio v3 نشدهاند، با ویرایشگر v2 باز میشوند.
+ pass
+ return {"items": items}
+
+
+@router.get(
+ "/business/{business_id}/studio-blocks",
+ summary="کاتالوگ بلوکهای Studio v3",
+)
+@require_business_access("business_id")
+async def report_template_studio_blocks(
+ request: Request,
+ business_id: int,
+ module_key: str,
+ subtype: Optional[str] = None,
+ ctx: AuthContext = Depends(get_current_user),
+ db: Session = Depends(get_db),
+):
+ return {"items": studio_block_catalog(module_key, subtype)}
@router.post(
@@ -1060,10 +1156,8 @@ async def compile_v2_design_endpoint(
design = (body or {}).get("design") or {}
if not isinstance(design, dict):
raise ApiError("VALIDATION_ERROR", "design must be an object", http_status=400)
- from app.services.template_design_v2_compiler import compile_v2_design_to_jinja_html
-
try:
- html, css, header, footer = compile_v2_design_to_jinja_html(design)
+ html, css, header, footer = compile_template_design_to_jinja_html(design)
except Exception as ex:
raise ApiError("COMPILE_ERROR", str(ex), http_status=400)
return {
@@ -1074,6 +1168,82 @@ async def compile_v2_design_endpoint(
}
+@router.post(
+ "/business/{business_id}/validate-studio-design",
+ summary="اعتبارسنجی طراحی Studio",
+)
+@require_business_access("business_id")
+async def validate_studio_design_endpoint(
+ request: Request,
+ business_id: int,
+ body: Dict[str, Any] = Body(...),
+ ctx: AuthContext = Depends(get_current_user),
+ db: Session = Depends(get_db),
+):
+ if not ctx.can_write_section("report_templates"):
+ raise ApiError("FORBIDDEN", "Missing permission: report_templates.write", http_status=403)
+ module_key = str((body or {}).get("module_key") or "")
+ subtype_raw = (body or {}).get("subtype")
+ subtype = str(subtype_raw) if subtype_raw not in (None, "") else None
+ design = (body or {}).get("design") or {}
+ if not isinstance(design, dict):
+ raise ApiError("VALIDATION_ERROR", "design must be an object", http_status=400)
+ return ReportTemplateService.validate_template_v2_design_scope(module_key, subtype, design)
+
+
+@router.post(
+ "/business/{business_id}/compile-studio-design",
+ summary="کامپایل طراحی Studio به HTML/CSS",
+)
+@require_business_access("business_id")
+async def compile_studio_design_endpoint(
+ request: Request,
+ business_id: int,
+ body: Dict[str, Any] = Body(...),
+ ctx: AuthContext = Depends(get_current_user),
+ db: Session = Depends(get_db),
+):
+ if not ctx.can_write_section("report_templates"):
+ raise ApiError("FORBIDDEN", "Missing permission: report_templates.write", http_status=403)
+ design = (body or {}).get("design") or {}
+ if not isinstance(design, dict):
+ raise ApiError("VALIDATION_ERROR", "design must be an object", http_status=400)
+ try:
+ html, css, header, footer = compile_template_design_to_jinja_html(design)
+ except Exception as ex:
+ raise ApiError("COMPILE_ERROR", str(ex), http_status=400)
+ return {
+ "content_html": html,
+ "content_css": css,
+ "header_html": header,
+ "footer_html": footer,
+ }
+
+
+@router.post(
+ "/business/{business_id}/migrate-v2-to-v3",
+ summary="تبدیل طراحی Studio v2 به v3",
+)
+@require_business_access("business_id")
+async def migrate_v2_to_v3_endpoint(
+ request: Request,
+ business_id: int,
+ body: Dict[str, Any] = Body(...),
+ ctx: AuthContext = Depends(get_current_user),
+ db: Session = Depends(get_db),
+):
+ if not ctx.can_write_section("report_templates"):
+ raise ApiError("FORBIDDEN", "Missing permission: report_templates.write", http_status=403)
+ design = (body or {}).get("design") or {}
+ if not isinstance(design, dict):
+ raise ApiError("VALIDATION_ERROR", "design must be an object", http_status=400)
+ try:
+ migrated = migrate_v2_design_to_v3(design)
+ except Exception as ex:
+ raise ApiError("MIGRATION_ERROR", str(ex), http_status=400)
+ return {"design": migrated}
+
+
@router.post(
"/business/{business_id}/migrate-builder-to-v2",
summary="تبدیل طراحی Builder قدیمی به Studio v2",
@@ -1101,5 +1271,3 @@ async def migrate_builder_to_v2(
raise ApiError("MIGRATION_ERROR", str(ex), http_status=400)
validation = ReportTemplateService.validate_template_v2_design_scope(module_key, subtype, design)
return {"design": design, **validation}
-
-
diff --git a/hesabixAPI/app/services/report_template_service.py b/hesabixAPI/app/services/report_template_service.py
index ab5e0a58..2cec0b33 100755
--- a/hesabixAPI/app/services/report_template_service.py
+++ b/hesabixAPI/app/services/report_template_service.py
@@ -16,9 +16,10 @@ from adapters.db.models.report_template import ReportTemplate
from adapters.db.models.report_template_status_event import ReportTemplateStatusEvent
from app.core.responses import ApiError
from app.services.template_builder_compiler import compile_design_to_jinja_html
-from app.services.template_design_v2_compiler import compile_v2_design_to_jinja_html
+from app.services.template_design_v3_compiler import compile_template_design_to_jinja_html
from app.services.report_template_scope_registry import get_scope_meta, is_known_scope
from app.services.report_template_v2_service import validate_v2_design
+from app.services.report_template_v3_service import is_v3_design, validate_v3_design
logger = logging.getLogger(__name__)
@@ -219,6 +220,8 @@ class ReportTemplateService:
subtype: Optional[str],
design: Dict[str, Any],
) -> Dict[str, List[str]]:
+ if is_v3_design(design):
+ return validate_v3_design(module_key, subtype, design)
return validate_v2_design(module_key, subtype, design)
@staticmethod
@@ -527,7 +530,7 @@ class ReportTemplateService:
assets = getattr(template, "assets", None) or {}
if engine_name == "template_v2":
design = assets.get("template_design") or assets.get("design") or {}
- html, css, header_html, footer_html = compile_v2_design_to_jinja_html(design)
+ html, css, header_html, footer_html = compile_template_design_to_jinja_html(design)
else:
design = assets.get("builder_design") or assets.get("design") or {}
html, css, header_html, footer_html = compile_design_to_jinja_html(design)
@@ -893,4 +896,3 @@ class ReportTemplateService:
errors.append(f"خطای رندر: {str(e)}")
return errors
-
diff --git a/hesabixAPI/app/services/report_template_v3_service.py b/hesabixAPI/app/services/report_template_v3_service.py
new file mode 100644
index 00000000..15135a5f
--- /dev/null
+++ b/hesabixAPI/app/services/report_template_v3_service.py
@@ -0,0 +1,297 @@
+from __future__ import annotations
+
+import re
+from copy import deepcopy
+from typing import Any
+
+from jinja2 import BaseLoader, TemplateSyntaxError
+from jinja2.sandbox import SandboxedEnvironment
+
+from app.services.report_template_gallery import get_family, is_v2_design
+
+_HEX_COLOR_RE = re.compile(r"^#[0-9a-fA-F]{3,8}$")
+_ID_RE = re.compile(r"^[a-zA-Z0-9_-]{1,80}$")
+_KEY_RE = re.compile(r"^[a-zA-Z_][a-zA-Z0-9_]*$")
+
+
+_BLOCKS: dict[str, dict[str, Any]] = {
+ "brand_header": {
+ "label_fa": "سربرگ و برند",
+ "allowed_regions": ["header"],
+ "max_instances": 1,
+ "default_props": {},
+ },
+ "party_info": {
+ "label_fa": "اطلاعات طرف حساب",
+ "allowed_regions": ["body"],
+ "max_instances": 2,
+ "default_props": {"role": "buyer", "title": "خریدار"},
+ },
+ "invoice_lines": {
+ "label_fa": "جدول اقلام",
+ "allowed_regions": ["body"],
+ "max_instances": 1,
+ "required": True,
+ "default_props": {},
+ },
+ "invoice_totals": {
+ "label_fa": "جمعبندی مالی",
+ "allowed_regions": ["body"],
+ "max_instances": 1,
+ "default_props": {},
+ },
+ "payments": {
+ "label_fa": "پرداختها",
+ "allowed_regions": ["body"],
+ "max_instances": 1,
+ "default_props": {},
+ },
+ "note": {
+ "label_fa": "یادداشت فاکتور",
+ "allowed_regions": ["body", "footer"],
+ "max_instances": 1,
+ "default_props": {},
+ },
+ "signatures": {
+ "label_fa": "امضاها",
+ "allowed_regions": ["body", "footer"],
+ "max_instances": 1,
+ "default_props": {"show_seller": True, "show_buyer": True},
+ },
+ "qr": {
+ "label_fa": "کد QR",
+ "allowed_regions": ["body", "footer"],
+ "max_instances": 1,
+ "default_props": {},
+ },
+ "footer_meta": {
+ "label_fa": "اطلاعات چاپ",
+ "allowed_regions": ["footer"],
+ "max_instances": 1,
+ "default_props": {"show_print_time": True, "show_preparer": True},
+ },
+ "custom_text": {
+ "label_fa": "متن دلخواه",
+ "allowed_regions": ["header", "body", "footer"],
+ "default_props": {"text": "متن دلخواه"},
+ },
+ "divider": {
+ "label_fa": "خط جداکننده",
+ "allowed_regions": ["header", "body", "footer"],
+ "default_props": {"style": "solid"},
+ },
+ "spacer": {
+ "label_fa": "فاصله",
+ "allowed_regions": ["header", "body", "footer"],
+ "default_props": {"height": 12},
+ },
+}
+
+
+def is_v3_design(design: dict[str, Any]) -> bool:
+ try:
+ return int(design.get("schema_version") or 0) == 3
+ except Exception:
+ return False
+
+
+def studio_block_catalog(module_key: str, subtype: str | None) -> list[dict[str, Any]]:
+ if module_key != "invoices" or (subtype or "") not in ("detail", "receipt"):
+ return []
+ return [
+ {"type": block_type, **deepcopy(definition)}
+ for block_type, definition in _BLOCKS.items()
+ ]
+
+
+def _block(block_id: str, block_type: str, props: dict[str, Any] | None = None) -> dict[str, Any]:
+ return {
+ "id": block_id,
+ "type": block_type,
+ "visible": True,
+ "props": deepcopy(props or {}),
+ "style": {},
+ }
+
+
+def migrate_v2_design_to_v3(design: dict[str, Any]) -> dict[str, Any]:
+ if is_v3_design(design):
+ return deepcopy(design)
+ if not is_v2_design(design):
+ raise ValueError("Only template design v2 can be migrated to v3")
+
+ family_id = str(design.get("family_id") or "")
+ family = get_family(family_id)
+ if not family:
+ raise ValueError(f"Unknown template family: {family_id}")
+ if family.layout not in ("invoice_detail", "invoice_receipt"):
+ raise ValueError(f"Studio v3 does not support layout: {family.layout}")
+
+ sections = design.get("sections") or {}
+ header = [_block("brand-header", "brand_header")]
+ body: list[dict[str, Any]] = []
+ footer: list[dict[str, Any]] = []
+
+ if sections.get("show_seller_info", family.layout == "invoice_detail"):
+ body.append(_block("seller-info", "party_info", {"role": "seller", "title": "فروشنده"}))
+ if sections.get("show_buyer_info", True):
+ body.append(_block("buyer-info", "party_info", {"role": "buyer", "title": "خریدار"}))
+ table_props = deepcopy(design.get("table") or {})
+ table_props["show_unit_price"] = sections.get("show_unit_price", True)
+ body.append(_block("invoice-lines", "invoice_lines", table_props))
+ body.append(_block("invoice-totals", "invoice_totals", deepcopy(design.get("totals") or {})))
+ if sections.get("show_payments", True):
+ body.append(_block("payments", "payments"))
+ if sections.get("show_footer_note", True):
+ body.append(_block("invoice-note", "note"))
+ if sections.get("show_signatures", family.layout == "invoice_detail"):
+ body.append(
+ _block(
+ "signatures",
+ "signatures",
+ {
+ "show_seller": sections.get("show_seller_signature", True),
+ "show_buyer": sections.get("show_buyer_signature", True),
+ },
+ )
+ )
+ if sections.get("show_qr", False):
+ body.append(_block("invoice-qr", "qr"))
+
+ show_print_time = sections.get("show_print_time", True)
+ show_preparer = sections.get("show_preparer", family.layout == "invoice_detail")
+ if show_print_time or show_preparer:
+ footer.append(
+ _block(
+ "footer-meta",
+ "footer_meta",
+ {"show_print_time": show_print_time, "show_preparer": show_preparer},
+ )
+ )
+
+ theme = deepcopy(design.get("theme") or {})
+ theme.setdefault("direction", "rtl")
+ return {
+ "schema_version": 3,
+ "family_id": family_id,
+ "layout": family.layout,
+ "theme": theme,
+ "branding": deepcopy(design.get("branding") or {}),
+ "custom_css": str(design.get("custom_css") or ""),
+ "regions": {"header": header, "body": body, "footer": footer},
+ }
+
+
+def validate_v3_design(
+ module_key: str,
+ subtype: str | None,
+ design: dict[str, Any],
+) -> dict[str, list[str]]:
+ errors: list[str] = []
+ warnings: list[str] = []
+ if not isinstance(design, dict) or not is_v3_design(design):
+ return {"errors": ["schema_version must be 3"], "warnings": []}
+
+ family_id = str(design.get("family_id") or "").strip()
+ family = get_family(family_id)
+ if not family:
+ return {"errors": [f"Unknown family_id: {family_id}"], "warnings": []}
+ if family.module_key != module_key or (family.subtype or None) != (subtype or None):
+ errors.append("family_id does not match template scope")
+ if family.layout not in ("invoice_detail", "invoice_receipt"):
+ errors.append("Studio v3 currently supports invoice detail and receipt layouts")
+
+ theme = design.get("theme") or {}
+ direction = str(theme.get("direction") or "rtl").strip().lower()
+ if direction not in ("rtl", "ltr"):
+ errors.append("Invalid theme.direction")
+ for key in ("primary_color", "accent_color", "text_color"):
+ value = str(theme.get(key) or "").strip()
+ if value and not _HEX_COLOR_RE.fullmatch(value):
+ errors.append(f"Invalid theme.{key}")
+
+ regions = design.get("regions")
+ if not isinstance(regions, dict):
+ return {"errors": errors + ["regions must be an object"], "warnings": warnings}
+
+ seen_ids: set[str] = set()
+ counts: dict[str, int] = {}
+ for region_name in ("header", "body", "footer"):
+ blocks = regions.get(region_name) or []
+ if not isinstance(blocks, list):
+ errors.append(f"regions.{region_name} must be a list")
+ continue
+ for index, block in enumerate(blocks):
+ if not isinstance(block, dict):
+ errors.append(f"Invalid block in {region_name} at index {index}")
+ continue
+ block_id = str(block.get("id") or "").strip()
+ block_type = str(block.get("type") or "").strip()
+ definition = _BLOCKS.get(block_type)
+ if not block_id or not _ID_RE.fullmatch(block_id):
+ errors.append(f"Invalid block id in {region_name} at index {index}")
+ elif block_id in seen_ids:
+ errors.append(f"Duplicate block id: {block_id}")
+ seen_ids.add(block_id)
+ if not definition:
+ errors.append(f"Unknown block type: {block_type}")
+ continue
+ if region_name not in definition["allowed_regions"]:
+ errors.append(f"Block '{block_type}' is not allowed in region '{region_name}'")
+ counts[block_type] = counts.get(block_type, 0) + 1
+
+ props = block.get("props") or {}
+ if not isinstance(props, dict):
+ errors.append(f"Block '{block_id}' props must be an object")
+ continue
+ style = block.get("style") or {}
+ if not isinstance(style, dict):
+ errors.append(f"Block '{block_id}' style must be an object")
+ continue
+ text_align = str(style.get("text_align") or "").strip().lower()
+ if text_align and text_align not in ("right", "center", "left"):
+ errors.append(f"Invalid text alignment in block '{block_id}'")
+ if block_type == "invoice_lines":
+ items_var = str(props.get("items_var") or "lines")
+ if not _KEY_RE.fullmatch(items_var):
+ errors.append(f"Invalid invoice items variable: {items_var}")
+ columns = props.get("columns") or []
+ visible_columns = [c for c in columns if isinstance(c, dict) and c.get("visible", True) is not False]
+ if not visible_columns:
+ errors.append("Invoice lines must have at least one visible column")
+ for column in visible_columns:
+ key = str(column.get("key") or "")
+ if not _KEY_RE.fullmatch(key):
+ errors.append(f"Invalid invoice column key: {key}")
+ if block_type == "party_info" and str(props.get("role") or "") not in ("seller", "buyer"):
+ errors.append(f"Invalid party role in block '{block_id}'")
+ if block_type == "invoice_totals":
+ for row_index, row in enumerate(props.get("rows") or [], start=1):
+ if not isinstance(row, dict) or row.get("visible", True) is False:
+ continue
+ expr = str(row.get("expr") or "").strip()
+ if not expr:
+ errors.append(f"Totals row {row_index} is missing expr")
+ continue
+ try:
+ SandboxedEnvironment(loader=BaseLoader(), autoescape=True).from_string(f"{{{{ {expr} }}}}")
+ except TemplateSyntaxError as ex:
+ errors.append(f"Invalid totals expression in row {row_index}: {ex.message}")
+ if block_type == "custom_text" and len(str(props.get("text") or "")) > 2000:
+ errors.append(f"Custom text is too long in block '{block_id}'")
+
+ for block_type, definition in _BLOCKS.items():
+ count = counts.get(block_type, 0)
+ max_instances = definition.get("max_instances")
+ if max_instances is not None and count > int(max_instances):
+ errors.append(f"Block '{block_type}' exceeds its maximum instances")
+ if definition.get("required") and count == 0:
+ errors.append(f"Required block is missing: {block_type}")
+
+ try:
+ from app.services.template_design_v3_compiler import compile_v3_design_to_jinja_html
+
+ compile_v3_design_to_jinja_html(design)
+ except Exception as ex:
+ errors.append(f"Compile error: {ex}")
+ return {"errors": errors, "warnings": warnings}
diff --git a/hesabixAPI/app/services/template_design_v2_compiler.py b/hesabixAPI/app/services/template_design_v2_compiler.py
index 4caa9883..5c65d614 100644
--- a/hesabixAPI/app/services/template_design_v2_compiler.py
+++ b/hesabixAPI/app/services/template_design_v2_compiler.py
@@ -69,7 +69,11 @@ def _total_display_flag(row: Dict[str, Any]) -> str | None:
def _wrap_if_flag(flag: str | None, inner: str) -> str:
if not flag:
return inner
- return f"{{% if {flag} %}}{inner}{{% endif %}}"
+ # A Studio preview can be rendered with a sample/legacy context that does not
+ # yet contain the business print-display flags. The design itself marks the
+ # column/row as visible, so an absent runtime flag must not make the whole
+ # template fail under StrictUndefined.
+ return f"{{% if {flag} | default(true) %}}{inner}{{% endif %}}"
def _cell_expr(col: Dict[str, Any]) -> str:
@@ -113,6 +117,10 @@ def _total_expr(row: Dict[str, Any]) -> str:
def _theme_css(design: Dict[str, Any], family_id: str) -> str:
theme = design.get("theme") or {}
+ direction = str(theme.get("direction") or "rtl").strip().lower()
+ if direction not in ("rtl", "ltr"):
+ direction = "rtl"
+ default_align = "right" if direction == "rtl" else "left"
primary = _color(theme.get("primary_color"), "#1e3a5f")
accent = _color(theme.get("accent_color"), "#366092")
text = _color(theme.get("text_color"), "#212529")
@@ -128,6 +136,10 @@ def _theme_css(design: Dict[str, Any], family_id: str) -> str:
--rt-base: {base_font}px;
--rt-table: {table_font}px;
}}
+html, body {{
+ direction: {direction};
+ text-align: {default_align};
+}}
.rt-layout {{
font-size: var(--rt-base);
color: var(--rt-text);
@@ -872,14 +884,18 @@ def _compile_invoice_receipt(design: Dict[str, Any]) -> Tuple[str, str, str, str
if key == "product_name":
inner = (
"
"
- "{% if row.product_code %}{{ row.product_code }} — {% endif %}{{ row.product_name | default('-') }}"
+ "{% if row.product_code is defined and row.product_code %}{{ row.product_code }} — {% endif %}"
+ "{{ row.product_name | default('-') }}"
"
"
- "{% if row.description %}{{ row.description }}
{% endif %}"
+ "{% if row.description is defined and row.description %}"
+ "{{ row.description }}
{% endif %}"
)
if sections.get("show_unit_price", True):
inner += (
- "{% if row.unit_price %}{{ row.unit_price | money }}"
- "{% if row.unit_display %} / {{ row.unit_display }}{% endif %}
{% endif %}"
+ "{% if row.unit_price is defined and row.unit_price %}"
+ "{{ row.unit_price | money }}"
+ "{% if row.unit_display is defined and row.unit_display %}"
+ " / {{ row.unit_display }}{% endif %}
{% endif %}"
)
return inner
if key in ("quantity", "quantity_display"):
diff --git a/hesabixAPI/app/services/template_design_v3_compiler.py b/hesabixAPI/app/services/template_design_v3_compiler.py
new file mode 100644
index 00000000..68cdde84
--- /dev/null
+++ b/hesabixAPI/app/services/template_design_v3_compiler.py
@@ -0,0 +1,302 @@
+from __future__ import annotations
+
+from copy import deepcopy
+from typing import Any
+
+from app.services import template_design_v2_compiler as v2
+from app.services.report_template_gallery import get_family
+from app.services.report_template_v3_service import is_v3_design
+
+
+def _blocks(design: dict[str, Any], region: str) -> list[dict[str, Any]]:
+ regions = design.get("regions") or {}
+ return [
+ block
+ for block in (regions.get(region) or [])
+ if isinstance(block, dict) and block.get("visible", True) is not False
+ ]
+
+
+def _block_by_type(design: dict[str, Any], block_type: str) -> dict[str, Any] | None:
+ for region in ("header", "body", "footer"):
+ for block in _blocks(design, region):
+ if str(block.get("type") or "") == block_type:
+ return block
+ return None
+
+
+def _v2_projection(design: dict[str, Any]) -> dict[str, Any]:
+ lines = _block_by_type(design, "invoice_lines") or {}
+ totals = _block_by_type(design, "invoice_totals") or {}
+ return {
+ "schema_version": 2,
+ "family_id": design.get("family_id"),
+ "layout": design.get("layout"),
+ "theme": deepcopy(design.get("theme") or {}),
+ "branding": deepcopy(design.get("branding") or {}),
+ "custom_css": str(design.get("custom_css") or ""),
+ "sections": {},
+ "table": deepcopy(lines.get("props") or {}),
+ "totals": deepcopy(totals.get("props") or {}),
+ }
+
+
+def _header_block(design: dict[str, Any], *, receipt: bool) -> str:
+ family_id = str(design.get("family_id") or "")
+ logo_html = v2._logo_html(design, style="max-height:28px;max-width:72px;" if receipt else "")
+ business_name = v2._business_name_expr(design)
+ if receipt:
+ return f"""
+
+ {logo_html}
+ {f'
{business_name}
' if business_name else ''}
+
{{{{ title_text | default('فاکتور') }}}}
+
{{{{ invoice.code | default('-') }}}} — {v2._jinja_first_of("invoice.issue_date", "invoice_date_jalali")}
+
+
+""".strip()
+ if family_id == "invoice_modern":
+ return f"""
+
+
+
+
{{{{ title_text | default('فاکتور') }}}}
+
{{{{ invoice.code | default('-') }}}} — {v2._jinja_first_of("invoice.issue_date", "invoice_date_jalali")}
+
+ {logo_html}
+
+
+""".strip()
+ name_html = f"{business_name}
" if business_name else ""
+ return f"""
+
+""".strip()
+
+
+def _party_block(props: dict[str, Any], *, receipt: bool) -> str:
+ role = str(props.get("role") or "buyer")
+ title = v2._esc(props.get("title") or ("فروشنده" if role == "seller" else "خریدار"))
+ expr = v2._jinja_first_of("seller.name", "business_name") if role == "seller" else "{{ buyer.name | default('-') }}"
+ if receipt:
+ return f'{title}: {expr}
'
+ return f''
+
+
+def _detail_lines(props: dict[str, Any]) -> str:
+ items_var = str(props.get("items_var") or "lines")
+ columns = v2._visible_columns(list(props.get("columns") or []))
+ if not columns:
+ return ""
+ striped = "striped" if props.get("striped", True) else ""
+ headers = "".join(
+ v2._wrap_if_flag(
+ v2._column_display_flag(column),
+ f"{v2._esc(column.get('title') or column.get('key') or '')} | ",
+ )
+ for column in columns
+ )
+ cells = "".join(
+ v2._wrap_if_flag(v2._column_display_flag(column), f"{v2._cell_expr(column)} | ")
+ for column in columns
+ )
+ return f"""
+
+
+ {headers}
+ {{% for row in {items_var} %}}{cells}
{{% endfor %}}
+
+
+""".strip()
+
+
+def _receipt_cell(column: dict[str, Any], *, show_unit_price: bool) -> str:
+ key = str(column.get("key") or "").strip()
+ if key == "product_name":
+ result = (
+ ""
+ "{% if row.product_code is defined and row.product_code %}{{ row.product_code }} — {% endif %}"
+ "{{ row.product_name | default('-') }}
"
+ "{% if row.description is defined and row.description %}{{ row.description }}
{% endif %}"
+ )
+ if show_unit_price:
+ result += (
+ "{% if row.unit_price is defined and row.unit_price %}{{ row.unit_price | money }}"
+ "{% if row.unit_display is defined and row.unit_display %} / {{ row.unit_display }}{% endif %}
{% endif %}"
+ )
+ return result
+ if key in ("quantity", "quantity_display"):
+ return "{{ row.quantity_display | default(row.quantity, true) }}"
+ return v2._cell_expr(column)
+
+
+def _receipt_lines(props: dict[str, Any]) -> str:
+ items_var = str(props.get("items_var") or "lines")
+ columns = v2._visible_columns(list(props.get("columns") or []))
+ if not columns:
+ return ""
+ headers = "".join(
+ v2._wrap_if_flag(
+ v2._column_display_flag(column),
+ f"{v2._esc(column.get('title') or column.get('key') or '')} | ",
+ )
+ for column in columns
+ )
+ cells = "".join(
+ v2._wrap_if_flag(
+ v2._column_display_flag(column),
+ f"{_receipt_cell(column, show_unit_price=props.get('show_unit_price', True) is not False)} | ",
+ )
+ for column in columns
+ )
+ return f"""
+
+ {headers}
+ {{% for row in {items_var} %}}{cells}
{{% endfor %}}
+
+""".strip()
+
+
+def _totals_block(props: dict[str, Any], *, receipt: bool) -> str:
+ rows = [
+ row
+ for row in (props.get("rows") or [])
+ if isinstance(row, dict) and row.get("visible", True) is not False
+ ]
+ if not rows:
+ return ""
+ rows_html: list[str] = []
+ for row in rows:
+ emphasis = " class='emphasis'" if row.get("emphasis") else ""
+ title = v2._esc(row.get("title") or "")
+ value = v2._total_expr(row)
+ value_style = " style='text-align:end;font-weight:700;'" if receipt else ""
+ row_html = f"| {title} | {value} |
"
+ rows_html.append(v2._wrap_if_flag(v2._total_display_flag(row), row_html))
+ table = f""
+ return f"
{table}" if receipt else f"{table}
"
+
+
+def _payments_block(*, receipt: bool) -> str:
+ if receipt:
+ return """
+{% if payments is defined and payments %}
+{% for p in payments %}{{ p.method_name | default('-') }} — {{ p.amount | money }}
{% endfor %}{% endif %}
+""".strip()
+ return """
+{% if payments is defined and payments %}پرداختها
+
{% for p in payments %}- {{ p.method_name | default('-') }} — {{ p.amount | money }}
{% endfor %}
{% endif %}
+""".strip()
+
+
+def _compile_block_content(design: dict[str, Any], block: dict[str, Any], *, receipt: bool) -> str:
+ block_type = str(block.get("type") or "")
+ props = block.get("props") or {}
+ if block_type == "brand_header":
+ return _header_block(design, receipt=receipt)
+ if block_type == "party_info":
+ return _party_block(props, receipt=receipt)
+ if block_type == "invoice_lines":
+ return _receipt_lines(props) if receipt else _detail_lines(props)
+ if block_type == "invoice_totals":
+ return _totals_block(props, receipt=receipt)
+ if block_type == "payments":
+ return _payments_block(receipt=receipt)
+ if block_type == "note":
+ css_class = "rt-receipt-meta" if receipt else "rt-footer-note"
+ prefix = '
' if receipt else ""
+ return f"{{% if invoice_footer_note is defined and invoice_footer_note %}}{prefix}{{{{ invoice_footer_note }}}}
{{% endif %}}"
+ if block_type == "signatures":
+ parts: list[str] = []
+ if props.get("show_seller", True):
+ parts.append('')
+ if props.get("show_buyer", True):
+ parts.append('')
+ return f'{"".join(parts)}
' if parts else ""
+ if block_type == "qr":
+ size = 64 if receipt else 120
+ return f"""
+{{% if show_invoice_verify_qr is defined and show_invoice_verify_qr and invoice_verify_qr_data_uri is defined and invoice_verify_qr_data_uri %}}
+{{% endif %}}
+""".strip()
+ if block_type == "footer_meta":
+ bits: list[str] = []
+ if props.get("show_print_time", True):
+ bits.append("{{ generated_at | default('') }}")
+ if props.get("show_preparer", True):
+ bits.append("{{ issuer_name | default('') }}")
+ return f'' if bits else ""
+ if block_type == "custom_text":
+ return f'{v2._esc(props.get("text") or "")}
'
+ if block_type == "divider":
+ style = "dashed" if str(props.get("style") or "") == "dashed" else "solid"
+ return f'
'
+ if block_type == "spacer":
+ try:
+ height = max(4, min(80, int(props.get("height") or 12)))
+ except Exception:
+ height = 12
+ return f''
+ return ""
+
+
+def _compile_block(design: dict[str, Any], block: dict[str, Any], *, receipt: bool) -> str:
+ content = _compile_block_content(design, block, receipt=receipt)
+ if not content:
+ return ""
+ style = block.get("style") or {}
+ align = str(style.get("text_align") or "").strip().lower()
+ if not align and str(block.get("type") or "") == "custom_text":
+ align = str((block.get("props") or {}).get("align") or "").strip().lower()
+ if align in ("right", "center", "left"):
+ return f'{content}
'
+ return content
+
+
+def compile_v3_design_to_jinja_html(design: dict[str, Any]) -> tuple[str, str, str, str]:
+ if not is_v3_design(design):
+ raise ValueError("Not a v3 design schema")
+ family_id = str(design.get("family_id") or "")
+ family = get_family(family_id)
+ if not family:
+ raise ValueError(f"Unknown template family: {family_id}")
+ if family.layout not in ("invoice_detail", "invoice_receipt"):
+ raise ValueError(f"Studio v3 does not support layout: {family.layout}")
+ receipt = family.layout == "invoice_receipt"
+ theme = design.get("theme") or {}
+ direction = str(theme.get("direction") or "rtl").strip().lower()
+ if direction not in ("rtl", "ltr"):
+ direction = "rtl"
+
+ projection = _v2_projection(design)
+ if receipt:
+ _, css, _, _ = v2._compile_invoice_receipt(projection)
+ else:
+ css = v2._theme_css(design, family_id)
+ css += """
+.rt-studio-footer-meta { font-size: 10px; color: #64748b; text-align: center; margin-top: 8px; }
+.rt-custom-text { white-space: pre-wrap; margin: 6px 0; }
+.rt-block-align-right, .rt-block-align-right * { text-align: right !important; }
+.rt-block-align-center, .rt-block-align-center * { text-align: center !important; }
+.rt-block-align-left, .rt-block-align-left * { text-align: left !important; }
+"""
+ header_html = "".join(_compile_block(design, block, receipt=receipt) for block in _blocks(design, "header"))
+ body = "".join(_compile_block(design, block, receipt=receipt) for block in _blocks(design, "body"))
+ footer_html = "".join(_compile_block(design, block, receipt=receipt) for block in _blocks(design, "footer"))
+ body_html = f'{body}
'
+ html_doc = f'{body_html}'
+ return html_doc, css.strip(), header_html, footer_html
+
+
+def compile_template_design_to_jinja_html(design: dict[str, Any]) -> tuple[str, str, str, str]:
+ if is_v3_design(design):
+ return compile_v3_design_to_jinja_html(design)
+ return v2.compile_v2_design_to_jinja_html(design)
diff --git a/hesabixAPI/tests/test_template_design_v2_compiler.py b/hesabixAPI/tests/test_template_design_v2_compiler.py
index e63774fc..1c9bcef1 100644
--- a/hesabixAPI/tests/test_template_design_v2_compiler.py
+++ b/hesabixAPI/tests/test_template_design_v2_compiler.py
@@ -1,12 +1,17 @@
from __future__ import annotations
-import pytest
-
-from app.services.report_template_v2_service import migrate_builder_design_to_v2, validate_v2_design
-from app.services.report_template_gallery import default_design_for_family, list_gallery_items
-from app.services.template_design_v2_compiler import compile_v2_design_to_jinja_html
+from jinja2 import BaseLoader, StrictUndefined
from jinja2.sandbox import SandboxedEnvironment
-from jinja2 import BaseLoader
+
+from app.services.report_template_gallery import default_design_for_family, list_gallery_items
+from app.services.report_template_v2_service import migrate_builder_design_to_v2, validate_v2_design
+from app.services.report_template_v3_service import (
+ migrate_v2_design_to_v3,
+ studio_block_catalog,
+ validate_v3_design,
+)
+from app.services.template_design_v2_compiler import compile_v2_design_to_jinja_html
+from app.services.template_design_v3_compiler import compile_v3_design_to_jinja_html
def _sample_invoice_context() -> dict:
@@ -67,7 +72,7 @@ def test_compile_and_render_invoice_classic():
html, css, header, footer = compile_v2_design_to_jinja_html(design)
assert "{css}{header}{html}{footer}"
@@ -76,6 +81,30 @@ def test_compile_and_render_invoice_classic():
assert "A" in rendered
+def test_compile_and_render_invoice_classic_without_optional_display_flags():
+ design = default_design_for_family("invoice_classic")
+ assert design is not None
+ html, css, header, footer = compile_v2_design_to_jinja_html(design)
+ context = _sample_invoice_context()
+ for key in (
+ "show_line_discount_column",
+ "show_line_tax_column",
+ "show_line_amount_before_discount_column",
+ "show_line_amount_before_tax_column",
+ "show_summary_discount",
+ "show_summary_tax",
+ "show_summary_amount_without_tax",
+ ):
+ context.pop(key)
+ env = SandboxedEnvironment(loader=BaseLoader(), autoescape=True, undefined=StrictUndefined)
+ env.filters["money"] = lambda value, *args, **kwargs: str(value if value is not None else "")
+ env.filters["date"] = lambda value, *args, **kwargs: str(value if value is not None else "")
+ full = f"{header}{html}{footer}"
+ rendered = env.from_string(full).render(**context)
+ assert "INV-1" in rendered
+ assert "تخفیف" in rendered
+
+
def test_compile_and_render_invoice_receipt():
design = default_design_for_family("invoice_receipt_simple")
assert design is not None
@@ -84,7 +113,7 @@ def test_compile_and_render_invoice_receipt():
html, css, header, footer = compile_v2_design_to_jinja_html(design)
assert "rt-receipt-items" in html
assert "lines" in html
- env = SandboxedEnvironment(loader=BaseLoader(), autoescape=True)
+ env = SandboxedEnvironment(loader=BaseLoader(), autoescape=True, undefined=StrictUndefined)
env.filters["money"] = lambda value, *args, **kwargs: str(value if value is not None else "")
env.filters["date"] = lambda value, *args, **kwargs: str(value if value is not None else "")
full = f"{header}{html}{footer}"
@@ -131,3 +160,95 @@ def test_compile_postal_label():
html, css, header, footer = compile_v2_design_to_jinja_html(design)
assert "sender" in html
assert "receiver" in html
+
+
+def test_migrate_invoice_design_to_v3_and_render_strict():
+ design_v2 = default_design_for_family("invoice_classic")
+ assert design_v2 is not None
+ design = migrate_v2_design_to_v3(design_v2)
+ assert design["schema_version"] == 3
+ assert design["theme"]["direction"] == "rtl"
+ assert [block["type"] for block in design["regions"]["body"]][:3] == [
+ "party_info",
+ "party_info",
+ "invoice_lines",
+ ]
+ validation = validate_v3_design("invoices", "detail", design)
+ assert validation["errors"] == []
+ html, css, header, footer = compile_v3_design_to_jinja_html(design)
+ env = SandboxedEnvironment(loader=BaseLoader(), autoescape=True, undefined=StrictUndefined)
+ env.filters["money"] = lambda value, *args, **kwargs: str(value if value is not None else "")
+ env.filters["date"] = lambda value, *args, **kwargs: str(value if value is not None else "")
+ rendered = env.from_string(f"{header}{html}{footer}").render(**_sample_invoice_context())
+ assert "INV-1" in rendered
+ assert "A" in rendered
+
+
+def test_v3_compiler_preserves_dragged_block_order():
+ design_v2 = default_design_for_family("invoice_classic")
+ assert design_v2 is not None
+ design = migrate_v2_design_to_v3(design_v2)
+ body = design["regions"]["body"]
+ body.insert(0, {"id": "custom-first", "type": "custom_text", "visible": True, "props": {"text": "ابتدای بدنه"}, "style": {}})
+ html, _, _, _ = compile_v3_design_to_jinja_html(design)
+ assert html.index("ابتدای بدنه") < html.index("rt-party")
+
+
+def test_v3_compiler_applies_ltr_direction_and_block_text_alignment():
+ design_v2 = default_design_for_family("invoice_classic")
+ assert design_v2 is not None
+ design = migrate_v2_design_to_v3(design_v2)
+ design["theme"]["direction"] = "ltr"
+ design["regions"]["body"].insert(
+ 0,
+ {
+ "id": "centered-text",
+ "type": "custom_text",
+ "visible": True,
+ "props": {"text": "Centered"},
+ "style": {"text_align": "center"},
+ },
+ )
+ validation = validate_v3_design("invoices", "detail", design)
+ assert validation["errors"] == []
+ html, css, _, _ = compile_v3_design_to_jinja_html(design)
+ assert '' in html
+ assert "direction: ltr;" in css
+ assert 'class="rt-block rt-block-align-center"' in html
+
+
+def test_v3_validation_rejects_invalid_direction_and_alignment():
+ design_v2 = default_design_for_family("invoice_classic")
+ assert design_v2 is not None
+ design = migrate_v2_design_to_v3(design_v2)
+ design["theme"]["direction"] = "diagonal"
+ design["regions"]["body"][0]["style"] = {"text_align": "wide"}
+ validation = validate_v3_design("invoices", "detail", design)
+ assert "Invalid theme.direction" in validation["errors"]
+ assert any("Invalid text alignment" in error for error in validation["errors"])
+
+
+def test_v3_catalog_and_required_invoice_lines_validation():
+ catalog = studio_block_catalog("invoices", "detail")
+ assert any(item["type"] == "invoice_lines" and item.get("required") for item in catalog)
+ design_v2 = default_design_for_family("invoice_classic")
+ assert design_v2 is not None
+ design = migrate_v2_design_to_v3(design_v2)
+ design["regions"]["body"] = [block for block in design["regions"]["body"] if block["type"] != "invoice_lines"]
+ validation = validate_v3_design("invoices", "detail", design)
+ assert any("invoice_lines" in error for error in validation["errors"])
+
+
+def test_migrate_and_render_invoice_receipt_v3():
+ design_v2 = default_design_for_family("invoice_receipt_simple")
+ assert design_v2 is not None
+ design = migrate_v2_design_to_v3(design_v2)
+ validation = validate_v3_design("invoices", "receipt", design)
+ assert validation["errors"] == []
+ html, css, header, footer = compile_v3_design_to_jinja_html(design)
+ env = SandboxedEnvironment(loader=BaseLoader(), autoescape=True, undefined=StrictUndefined)
+ env.filters["money"] = lambda value, *args, **kwargs: str(value if value is not None else "")
+ env.filters["date"] = lambda value, *args, **kwargs: str(value if value is not None else "")
+ rendered = env.from_string(f"{header}{html}{footer}").render(**_sample_invoice_context())
+ assert "INV-1" in rendered
+ assert "rt-receipt-items" in rendered
diff --git a/hesabixUI/hesabix_ui/lib/pages/business/report_template_html_editor_page.dart b/hesabixUI/hesabix_ui/lib/pages/business/report_template_html_editor_page.dart
index a19045e5..caa037e9 100644
--- a/hesabixUI/hesabix_ui/lib/pages/business/report_template_html_editor_page.dart
+++ b/hesabixUI/hesabix_ui/lib/pages/business/report_template_html_editor_page.dart
@@ -382,17 +382,23 @@ class _ReportTemplateHtmlEditorPageState extends State(
context: context,
- builder: (ctx) => AlertDialog(
- title: Text(t.reportTemplatePreview),
- content: SizedBox(
- width: 720,
- height: 520,
- child: ReportTemplateEmbeddedPdf(bytes: Uint8List.fromList(pdfBytes)),
- ),
- actions: [
- TextButton(onPressed: () => Navigator.pop(ctx), child: Text(t.close)),
- ],
- ),
+ builder: (ctx) {
+ final viewport = MediaQuery.sizeOf(ctx);
+ final availableWidth = viewport.width > 64 ? viewport.width - 64 : viewport.width;
+ final availableHeight = viewport.height > 180 ? viewport.height - 180 : viewport.height;
+ return AlertDialog(
+ insetPadding: const EdgeInsets.all(16),
+ title: Text(t.reportTemplatePreview),
+ content: SizedBox(
+ width: availableWidth > 720 ? 720 : availableWidth,
+ height: availableHeight > 520 ? 520 : availableHeight,
+ child: ReportTemplateEmbeddedPdf(bytes: Uint8List.fromList(pdfBytes)),
+ ),
+ actions: [
+ TextButton(onPressed: () => Navigator.pop(ctx), child: Text(t.close)),
+ ],
+ );
+ },
);
} catch (e) {
if (mounted) {
diff --git a/hesabixUI/hesabix_ui/lib/pages/business/report_template_studio_page.dart b/hesabixUI/hesabix_ui/lib/pages/business/report_template_studio_page.dart
index 61872646..1917dd3c 100644
--- a/hesabixUI/hesabix_ui/lib/pages/business/report_template_studio_page.dart
+++ b/hesabixUI/hesabix_ui/lib/pages/business/report_template_studio_page.dart
@@ -17,11 +17,14 @@ import '../../widgets/permission/permission_widgets.dart';
import '../../widgets/report_template/studio/report_template_studio_customize_panel.dart';
import '../../widgets/report_template/studio/report_template_studio_gallery.dart';
import '../../widgets/report_template/studio/report_template_studio_preview_panel.dart';
+import '../../widgets/report_template/studio/report_template_studio_v3_builder.dart';
import '../../core/hesabix_back.dart';
import 'report_template_html_editor_page.dart';
enum _StudioStep { gallery, customize }
+enum _StudioToolbarAction { changeTemplate, advancedHtml, pageSettings }
+
class ReportTemplateStudioPage extends StatefulWidget {
final int businessId;
final AuthStore authStore;
@@ -43,7 +46,8 @@ class ReportTemplateStudioPage extends StatefulWidget {
bool get isNew => template == null && templateId == null;
@override
- State createState() => _ReportTemplateStudioPageState();
+ State createState() =>
+ _ReportTemplateStudioPageState();
}
class _ReportTemplateStudioPageState extends State {
@@ -69,14 +73,18 @@ class _ReportTemplateStudioPageState extends State {
List