finance-reconcile

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Finance Audit

财务审计

Overview

概述

Comprehensive financial audit tool that validates balance sheets and income statements. Performs four core audits: balance sheet equilibrium, income statement verification, account change tracking, and cross-statement relationship validation.
一款验证资产负债表和利润表的综合性财务审计工具,可执行四项核心审计:资产负债表平衡验证、利润表项目核对、科目变动追踪以及报表间勾稽关系验证。

Quick Start

快速开始

Basic Balance Sheet Audit

基础资产负债表审计

Verify balance sheet with account changes:
bash
scripts/reconcile.py \
    --balance-sheet balance_sheet.xlsx \
    --account-changes account_changes.xlsx \
    --output audit_report.xlsx
结合科目变动验证资产负债表:
bash
scripts/reconcile.py \
    --balance-sheet balance_sheet.xlsx \
    --account-changes account_changes.xlsx \
    --output audit_report.xlsx

Complete Financial Audit (Balance Sheet + Income Statement)

完整财务审计(资产负债表+利润表)

Full audit including profit statement:
bash
scripts/reconcile.py \
    --balance-sheet balance_sheet.xlsx \
    --account-changes account_changes.xlsx \
    --income-statement income_statement.xlsx \
    --income-details income_details.xlsx \
    --transactions transactions.xlsx \
    --output complete_audit.xlsx \
    --period "2024年1月"
包含利润表的完整审计:
bash
scripts/reconcile.py \
    --balance-sheet balance_sheet.xlsx \
    --account-changes account_changes.xlsx \
    --income-statement income_statement.xlsx \
    --income-details income_details.xlsx \
    --transactions transactions.xlsx \
    --output complete_audit.xlsx \
    --period "2024年1月"

Using Custom Column Names

使用自定义列名

Use JSON config file for custom column names:
bash
scripts/reconcile.py \
    --balance-sheet bs.xlsx \
    --account-changes ac.xlsx \
    --config my_config.json
使用JSON配置文件自定义列名:
bash
scripts/reconcile.py \
    --balance-sheet bs.xlsx \
    --account-changes ac.xlsx \
    --config my_config.json

Command Parameters

命令参数

ParameterShortRequiredDescription
--balance-sheet
-b
YesBalance sheet file path
--account-changes
-a
YesAccount change details file path
--income-statement
-i
NoIncome statement file path
--income-details
-d
NoIncome statement details file path
--transactions
-t
NoTransaction details file path
--output
-o
NoOutput Excel audit report path
--period
-p
NoAudit period (default: 本期)
--tolerance
-NoTolerance for acceptable difference (default: 0.01)
--config
-c
NoJSON config file for column names
--bs-sheet
-NoBalance sheet sheet name or index
--ac-sheet
-NoAccount changes sheet name or index
--is-sheet
-NoIncome statement sheet name or index
--id-sheet
-NoIncome details sheet name or index
--trans-sheet
-NoTransaction details sheet name or index
ParameterShortRequiredDescription
--balance-sheet
-b
Yes资产负债表文件路径
--account-changes
-a
Yes科目变动明细文件路径
--income-statement
-i
No利润表文件路径
--income-details
-d
No利润明细表文件路径
--transactions
-t
No交易明细表文件路径
--output
-o
No输出Excel审计报告路径
--period
-p
No审计期间(默认:本期)
--tolerance
-No可接受差异的容差(默认:0.01)
--config
-c
No用于自定义列名的JSON配置文件
--bs-sheet
-No资产负债表工作表名称或索引
--ac-sheet
-No科目变动表工作表名称或索引
--is-sheet
-No利润表工作表名称或索引
--id-sheet
-No利润明细表工作表名称或索引
--trans-sheet
-No交易明细表工作表名称或索引

Required File Formats

所需文件格式

1. Balance Sheet (资产负债表) - Required

1. 资产负债表 - 必填

ColumnDescription
科目Account name
期初余额Opening balance
期末余额Closing balance
类型Account type (资产/负债/所有者权益)
金额Amount for totals
ColumnDescription
科目科目名称
期初余额期初余额
期末余额期末余额
类型科目类型(资产/负债/所有者权益)
金额合计金额

2. Account Changes (科目变动明细表) - Required

2. 科目变动明细表 - 必填

ColumnDescription
科目Account name
借方Debit amount
贷方Credit amount
ColumnDescription
科目科目名称
借方借方金额
贷方贷方金额

3. Income Statement (利润表) - Optional

3. 利润表 - 可选

ColumnDescription
项目Income statement item
金额Amount
ColumnDescription
项目利润表项目
金额金额

4. Income Details (利润明细表) - Optional

4. 利润明细表 - 可选

ColumnDescription
项目Item name (must match income statement)
金额Detail amount
ColumnDescription
项目项目名称(需与利润表一致)
金额明细金额

5. Transactions (交易明细表) - Optional

5. 交易明细表 - 可选

ColumnDescription
科目Affected account
借方Debit amount
贷方Credit amount
日期 (optional)Transaction date
凭证号 (optional)Voucher number
See
references/file_formats.md
for detailed format specifications and custom column configuration.
ColumnDescription
科目受影响科目
借方借方金额
贷方贷方金额
日期 (optional)交易日期
凭证号 (optional)凭证号
详细格式规范和自定义列配置请查看
references/file_formats.md

Audit Objectives

审计目标

The script performs four core audit objectives:
本脚本实现四项核心审计目标:

1. Balance Sheet Equilibrium Verification

1. 资产负债表平衡验证

Formula: 资产总计 = 负债总计 + 所有者权益总计
Verifies that the balance sheet is balanced overall.
公式:资产总计 = 负债总计 + 所有者权益总计
验证资产负债表整体是否平衡。

2. Income Statement Verification

2. 利润表验证

Logic: Income statement items = Corresponding detail summary
Validates each income statement item (revenue, expenses, etc.) against detail records.
逻辑:利润表项目金额 = 对应明细汇总金额
核对利润表中每个项目(收入、费用等)与明细记录是否一致。

3. Account Change Tracking

3. 科目变动追踪

Logic: Opening Balance + Changes = Closing Balance
For each account:
  • Asset accounts: Closing = Opening + Debit - Credit
  • Liability/Equity accounts: Closing = Opening + Credit - Debit
逻辑:期初余额 + 变动金额 = 期末余额
针对每个科目:
  • 资产类科目:期末余额 = 期初余额 + 借方发生额 - 贷方发生额
  • 负债/所有者权益类科目:期末余额 = 期初余额 + 贷方发生额 - 借方发生额

4. Cross-Statement Relationship Validation

4. 报表间勾稽关系验证

Logic: Retained earnings change ≈ Net profit
Validates relationships between balance sheet and income statement.
See
references/verification_rules.md
for detailed audit logic and troubleshooting.
逻辑:未分配利润变动额 ≈ 净利润
验证资产负债表与利润表之间的勾稽关系。
详细审计逻辑和故障排查请查看
references/verification_rules.md

Audit Outputs

审计输出

Console Report

控制台报告

================================================================================
                              财务审计报告 - 本期
================================================================================

一、审计概述
--------------------------------------------------------------------------------
审计结果: 通过 ✓

二、资产负债表审计
--------------------------------------------------------------------------------
资产总计: ¥1,000,000.00
负债总计: ¥600,000.00
所有者权益总计: ¥400,000.00
资产负债平衡: 是 ✓

三、利润表审计
--------------------------------------------------------------------------------
利润项目匹配: 5/5

四、报表勾稽关系
--------------------------------------------------------------------------------
净利润: ¥100,000.00
未分配利润变动: ¥100,000.00
勾稽关系验证: 通过 ✓

五、不平衡项目清单
--------------------------------------------------------------------------------
  无不平衡项目
================================================================================
                              财务审计报告 - 本期
================================================================================

一、审计概述
--------------------------------------------------------------------------------
审计结果: 通过 ✓

二、资产负债表审计
--------------------------------------------------------------------------------
资产总计: ¥1,000,000.00
负债总计: ¥600,000.00
所有者权益总计: ¥400,000.00
资产负债平衡: 是 ✓

三、利润表审计
--------------------------------------------------------------------------------
利润项目匹配: 5/5

四、报表勾稽关系
--------------------------------------------------------------------------------
净利润: ¥100,000.00
未分配利润变动: ¥100,000.00
勾稽关系验证: 通过 ✓

五、不平衡项目清单
--------------------------------------------------------------------------------
  无不平衡项目

Excel Audit Report

Excel审计报告

When
--output
is specified, generates an Excel file with these sheets:
SheetContent
审计报告Full audit report text
科目变动分析Account analysis with opening/closing balances
交易影响追踪Transaction impact tracking
利润表核对Income statement verification results
不平衡项List of unbalanced items
指定
--output
参数时,将生成包含以下工作表的Excel文件:
SheetContent
审计报告完整审计报告文本
科目变动分析包含期初/期末余额的科目分析
交易影响追踪交易影响追踪
利润表核对利润表核对结果
不平衡项不平衡项目清单

Account Change Analysis Table

科目变动分析表

科目科目类型期初余额借方变动贷方变动净变动期末余额是否平衡差异
货币资金资产100000200000200001200000
科目科目类型期初余额借方变动贷方变动净变动期末余额是否平衡差异
货币资金资产100000200000200001200000

Using the Script as a Module

将脚本作为模块使用

python
from scripts.reconcile import (
    audit_financial_statements,
    generate_audit_report,
    export_audit_report
)

result, accounts = audit_financial_statements(
    balance_sheet_file='balance_sheet.xlsx',
    account_changes_file='account_changes.xlsx',
    income_statement_file='income_statement.xlsx',
    income_details_file='income_details.xlsx',
    transactions_file='transactions.xlsx',
    tolerance=0.01,
    period='2024年1月'
)
python
from scripts.reconcile import (
    audit_financial_statements,
    generate_audit_report,
    export_audit_report
)

result, accounts = audit_financial_statements(
    balance_sheet_file='balance_sheet.xlsx',
    account_changes_file='account_changes.xlsx',
    income_statement_file='income_statement.xlsx',
    income_details_file='income_details.xlsx',
    transactions_file='transactions.xlsx',
    tolerance=0.01,
    period='2024年1月'
)

Print console report

Print console report

print(generate_audit_report(result, period='2024年1月'))
print(generate_audit_report(result, period='2024年1月'))

Export Excel report

Export Excel report

export_audit_report(result, 'audit_report.xlsx', accounts, period='2024年1月')
export_audit_report(result, 'audit_report.xlsx', accounts, period='2024年1月')

Check audit result

Check audit result

if result.is_passed: print("Audit passed!") else: print(f"Found {len(result.unbalanced_items)} unbalanced items")
undefined
if result.is_passed: print("Audit passed!") else: print(f"Found {len(result.unbalanced_items)} unbalanced items")
undefined

Tolerance Setting

容差设置

Default tolerance is ±0.01 yuan. Adjust with
--tolerance
:
bash
scripts/reconcile.py \
    --balance-sheet bs.xlsx \
    --account-changes ac.xlsx \
    --tolerance 1.0
Consider these factors when setting tolerance:
  • Exchange rate fluctuations (for foreign currency)
  • System precision differences
  • Rounding errors
默认容差为±0.01元,可通过
--tolerance
参数调整:
bash
scripts/reconcile.py \
    --balance-sheet bs.xlsx \
    --account-changes ac.xlsx \
    --tolerance 1.0
设置容差时需考虑以下因素:
  • 汇率波动(外币业务)
  • 系统精度差异
  • 四舍五入误差

Troubleshooting

故障排查

Balance Sheet Not Balanced

资产负债表不平衡

Possible causes:
  • Incorrect balance entries
  • Incorrect totals calculation
  • Opening/closing mismatch
Solutions:
  1. Check balance sheet total rows
  2. Verify account balances
  3. Check account type classification
可能原因
  • 余额录入错误
  • 合计计算错误
  • 期初/期末余额不匹配
解决方法
  1. 检查资产负债表合计行
  2. 验证科目余额
  3. 检查科目类型分类

Account Changes Unbalanced

科目变动不平衡

Possible causes:
  • Missing change records
  • Incorrect debit/credit direction
  • Account name mismatch
Solutions:
  1. Ensure account names match exactly
  2. Verify debit/credit records
  3. Check for missing change records
可能原因
  • 缺失变动记录
  • 借贷方向错误
  • 科目名称不匹配
解决方法
  1. 确保科目名称完全一致
  2. 验证借贷记录
  3. 检查是否有缺失的变动记录

Income Statement Not Matching

利润表核对不一致

Possible causes:
  • Missing detail items
  • Inconsistent item names
  • Incorrect summary calculation
Solutions:
  1. Ensure detail table includes all items
  2. Check item name consistency
  3. Verify summary calculations
可能原因
  • 缺失明细项目
  • 项目名称不一致
  • 汇总计算错误
解决方法
  1. 确保明细表包含所有项目
  2. 检查项目名称一致性
  3. 验证汇总计算

Cross-Statement Relationship Failed

报表勾稽关系验证失败

Possible causes:
  • Profit distribution (dividends, retained earnings)
  • Mismatched accounting periods
  • Incorrect net profit calculation
Solutions:
  1. Consider profit distribution events
  2. Verify income statement net profit
  3. Confirm period consistency
可能原因
  • 利润分配(分红、留存收益)
  • 会计期间不匹配
  • 净利润计算错误
解决方法
  1. 考虑利润分配事项
  2. 验证利润表净利润
  3. 确认期间一致性

Resources

资源

scripts/reconcile.py

scripts/reconcile.py

Core audit script supporting:
  • Balance sheet equilibrium verification
  • Income statement validation
  • Account change tracking
  • Cross-statement relationship validation
  • Transaction impact tracing
  • Comprehensive audit report generation
核心审计脚本,支持:
  • 资产负债表平衡验证
  • 利润表验证
  • 科目变动追踪
  • 报表间勾稽关系验证
  • 交易影响追溯
  • 生成综合性审计报告

references/file_formats.md

references/file_formats.md

Detailed file format specifications, column name mapping, and configuration options.
详细的文件格式规范、列名映射和配置选项。

references/verification_rules.md

references/verification_rules.md

Comprehensive audit rules, validation logic, output examples, and troubleshooting guide.
全面的审计规则、验证逻辑、输出示例和故障排查指南。