#!/usr/bin/env python3
"""
测试 PDF 解析功能
"""

from financial_report_parser import FinancialReportParser

def test_pdf_parsing():
    parser = FinancialReportParser()
    
    # 测试文件读取和类型
    with open("financial_report_parser/605228_20250719_SSRU.pdf", "rb") as f:
        pdf_content = f.read()
        
        # 调用解析方法
        result = parser.parse_pdf(pdf_content)
        
        # 格式化输出结果
        # print("📊 财务报表解析结果:")
        # print("=" * 50)
        
        # if 'balance_sheet' in result:
        #     print("\n💰 资产负债表:")
        #     balance_sheet = result['balance_sheet']
        #     print(f"   货币资金: {balance_sheet.get('monetary_funds', 0):,.2f}")
        #     print(f"   应收账款: {balance_sheet.get('accounts_receivable', 0):,.2f}")
        #     print(f"   存货: {balance_sheet.get('inventory', 0):,.2f}")
        #     print(f"   流动资产合计: {balance_sheet.get('total_current_assets', 0):,.2f}")
        #     print(f"   固定资产: {balance_sheet.get('fixed_assets', 0):,.2f}")
        #     print(f"   非流动资产合计: {balance_sheet.get('total_non_current_assets', 0):,.2f}")
        #     print(f"   资产总计: {balance_sheet.get('total_assets', 0):,.2f}")
        #     print(f"   应付账款: {balance_sheet.get('accounts_payable', 0):,.2f}")
        #     print(f"   流动负债合计: {balance_sheet.get('total_current_liabilities', 0):,.2f}")
        #     print(f"   负债合计: {balance_sheet.get('total_liabilities', 0):,.2f}")
        #     print(f"   实收资本: {balance_sheet.get('paid_in_capital', 0):,.2f}")
        #     print(f"   未分配利润: {balance_sheet.get('undistributed_profits', 0):,.2f}")
        
        # if 'profit_statement' in result:
        #     print("\n📈 利润表:")
        #     profit_statement = result['profit_statement']
        #     print(f"   营业收入: {profit_statement.get('operating_revenue', 0):,.2f}")
        #     print(f"   营业成本: {profit_statement.get('operating_cost', 0):,.2f}")
        #     print(f"   营业利润: {profit_statement.get('operating_profit', 0):,.2f}")
        #     print(f"   利润总额: {profit_statement.get('total_profit', 0):,.2f}")
        #     print(f"   净利润: {profit_statement.get('net_profit_final', 0):,.2f}")
        #     print(f"   基本每股收益: {profit_statement.get('basic_eps', 0):.2f}")
        
        # if 'cash_flow_statement' in result:
        #     print("\n💸 现金流量表:")
        #     cash_flow = result['cash_flow_statement']
        #     print(f"   经营活动现金流量净额: {cash_flow.get('net_cash_flows_from_operating_activities', 0):,.2f}")
        #     print(f"   投资活动现金流量净额: {cash_flow.get('net_cash_flows_from_investing_activities', 0):,.2f}")
        #     print(f"   筹资活动现金流量净额: {cash_flow.get('net_cash_flows_from_financing_activities', 0):,.2f}")
        
        # 显示数据质量信息
        # if 'validation' in result:
        #     validation = result['validation']
        #     print(f"\n✅ 数据质量评分: {validation.get('data_quality_score', 0)}/100")
        #     if validation.get('warnings'):
        #         print(f"⚠️  警告: {validation['warnings']}")
        
        # print("\n" + "=" * 50)

if __name__ == "__main__":
    test_pdf_parsing()









