from typing import Any, Dict from core.document_processor.templates.base_template import DocumentTemplate class InvoiceTemplate(DocumentTemplate): """发票模板""" @property def template_name(self) -> str: return "invoice" @property def description(self) -> str: return "增值税发票识别模板" def output_schema(self) -> Dict[str, Any]: return { "invoice_code": "发票代码", "invoice_number": "发票号码", "issue_date": "开票日期", "seller_name": "销售方名称", "seller_tax_id": "销售方税号", "buyer_name": "购买方名称", "buyer_tax_id": "购买方税号", "amount_without_tax": "不含税金额", "tax_amount": "税额", "total_amount": "价税合计", "items": [ { "name": "货物或服务名称", "specification": "规格型号", "unit": "单位", "quantity": "数量", "unit_price": "单价", "amount": "金额", } ], } def extraction_rules(self) -> str: return """ """ def validate_result(self, result: Dict) -> bool: # 验证必填字段 required_fields = ["invoice_number", "total_amount", "issue_date"] return all(field in result for field in required_fields)