搜索

PythonReactSEOPDF
GitHub Skill

validate-journals

Validate hledger journal files using check/format scripts. Includes validation procedures and pre-commit verification.

polyipseity☆ 0 仓库 Stars0 仓库 Forks

安装与使用

请根据来源仓库和你的 AI 工具说明安装此技能。先阅读技能文件和依赖要求,再添加到工作流。

查看来源 ↗使用指南

技能说明

Validate Journals Skill

Validate journals to catch errors and ensure consistency before committing.

When to Use

  • Before committing changes
  • After editing journal files
  • When adding new transactions or accounts
  • When troubleshooting validation errors

Quick Start

python -m format       # Auto-format journals
python -m check        # Validate all journals

# Fix any errors shown, then commit
git commit -S -m "your message"

What Check Validates

The python -m check script runs hledger --strict mode checking:

  • accounts - All accounts defined in preludes
  • assertions - Balance assertions match
  • autobalanced - Postings balanced
  • balanced - Double-entry bookkeeping (transactions balance)
  • commodities - Commodity usage matches definitions
  • ordereddates - Date ordering correct
  • parseable - Valid hledger syntax
  • payees - Payee definitions exist
  • tags - Tag usage matches definitions

Common Errors & Fixes

Error Fix
Account not defined Add to preludes/self.journal
Balance mismatch Fix transaction or prior balances
Transaction not balanced Add missing postings
Payee not defined Add to preludes/self.journal
Tag not defined Add to preludes/self.journal
Date out of order Correct date or reorder

Format Validation

The formatter normalizes:

  • Amounts to 2 decimal places: 50.00 HKD
  • Large numbers with spaces: 16 966.42 HKD
  • Comment properties alphabetically: activity:, eating:, time:, timezone:
  • Preserves UUIDs: assets:banks:<bank-uuid>

Pre-Commit Workflow

1. python -m format       # Normalize formatting
2. python -m check        # Validate
3. git status && git diff # Review changes
4. git commit             # Commit when clean

Checking Specific Months

# Check single month instead of all
hledger -f ledger/2025/2025-01/self.journal --strict bal

# Verify specific account
hledger -f ledger/index.journal accounts | grep "your-search"
hledger -f ledger/index.journal register "assets:cash"

Best Practices

  • Validate frequently (not just before commit)
  • Format before validation
  • Fix errors immediately
  • Keep preludes clean
  • Always run python -m check before committing

Related Documentation

使用示例

查看来源仓库中的使用示例与配置说明。

查看来源 ↗

来源历史

收录时间
2026-01-20
索引更新时间
2026-01-26
Branch
main

收录与同步日期属于本站记录。源码修改历史请查看来源仓库。

GitHub ↗

chat Comments (0)

chat_bubble_outline

No comments yet. Be the first to share your thoughts!