Files
njts-accounting-core/test_api_balance.py
2026-02-20 15:47:27 +09:00

56 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import requests
import json
BASE_URL = "http://localhost:18080"
print("=" * 80)
print("【修正後のAPI試算表テスト】")
print("=" * 80)
print()
try:
# Get trial balance
response = requests.get(f"{BASE_URL}/trial-balance")
response.raise_for_status()
data = response.json()
# Find account 701
accounts = data.get('accounts', [])
account_701 = None
for acc in accounts:
if acc.get('account_code') == '701':
account_701 = acc
break
if account_701:
print(f"701 売上高Sales Revenue:")
print(f" 借方Debit: {account_701.get('debit', 'N/A')}")
print(f" 貸方Credit: {account_701.get('credit', 'N/A')}")
print(f" 期末残高Closing Balance: {account_701.get('closing_balance', 'N/A')}")
print()
else:
print("Account 701 not found!")
print()
# Show totals
totals = data.get('totals', {})
print("試算表合計Trial Balance Totals:")
print(f" 借方合計: {totals.get('debit', 'N/A')}")
print(f" 貸方合計: {totals.get('credit', 'N/A')}")
print()
# Check if debit = credit (this is the test)
debit_total = float(totals.get('debit', 0) or 0)
credit_total = float(totals.get('credit', 0) or 0)
if debit_total == credit_total:
print("✓ 試算表が正しくバランスしています(借方=貸方)")
else:
print(f"✗ 試算表がバランスしていません(借方={debit_total}, 貸方={credit_total}")
except Exception as e:
print(f"エラー: {e}")
import traceback
traceback.print_exc()