Files
njts-accounting-core/test_api_fix.py
2026-03-03 00:01:43 +09:00

58 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Test if the trial-balance API fix is applied"""
import requests
import json
url = 'http://127.0.0.1:18080/trial-balance'
params = {
'fiscal_year': 2025,
'date_from': '2025-06-01',
'date_to': '2025-12-31'
}
print("🔍 Testing API...")
print(f"URL: {url}")
print(f"Params: {params}")
print()
try:
response = requests.get(url, params=params)
response.raise_for_status()
data = response.json()
# Find the target row
target = [row for row in data if row.get('account_name') == '繰越利益剰余金合計']
if target:
row = target[0]
print("✓ Found: 繰越利益剰余金合計")
print(f" debit: {row.get('debit')}")
print(f" credit: {row.get('credit')}")
print()
print("Expected (after fix):")
print(" debit: 0")
print(" credit: 7967855")
print()
debit_correct = row.get('debit') == '0'
credit_correct = row.get('credit') == '7967855'
if debit_correct and credit_correct:
print("✓✓✓ SUCCESS! API is now returning CORRECT values.")
print("The fix has been successfully applied!")
else:
print("❌ Values still incorrect")
if not debit_correct:
print(f" - debit is {row.get('debit')}, expected 0")
if not credit_correct:
print(f" - credit is {row.get('credit')}, expected 7967855")
else:
print("❌ Cannot find 繰越利益剰余金合計 row")
print("Last 5rows:")
for row in data[-5:]:
print(f" {row.get('account_name')}: debit={row.get('debit')}, credit={row.get('credit')}")
except Exception as e:
print(f"❌ Error: {e}")
print("\nMake sure the backend is running on http://127.0.0.1:18080")