ERP/test_fix_total_amount.py
2026-02-03 13:27:32 +08:00

61 lines
1.9 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.

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
测试修复含税金额功能
"""
import requests
import json
def test_fix_total_amount():
"""测试修复含税金额API"""
# API地址
url = "http://localhost:5000/api/reconciliations/fix-total-amount"
# 模拟登录需要先获取session
login_url = "http://localhost:5000/api/login"
try:
# 创建会话
session = requests.Session()
# 登录
login_data = {
"username": "admin",
"password": "admin"
}
print("正在登录...")
login_response = session.post(login_url, json=login_data)
if login_response.status_code == 200:
print("登录成功!")
# 调用修复含税金额API
print("\n正在调用修复含税金额API...")
response = session.post(url)
if response.status_code == 200:
result = response.json()
print(f"\n修复结果:")
print(f"- 状态: {'成功' if result.get('ok') else '失败'}")
print(f"- 修复记录数: {result.get('fixed_count', 0)}")
print(f"- 消息: {result.get('message', '')}")
else:
print(f"API调用失败状态码: {response.status_code}")
print(f"错误信息: {response.text}")
else:
print(f"登录失败,状态码: {login_response.status_code}")
print(f"错误信息: {login_response.text}")
except requests.exceptions.ConnectionError:
print("\n错误:无法连接到服务器")
print("请确保生产管理系统正在运行systemctl start prod-mgmt")
except Exception as e:
print(f"\n发生错误: {str(e)}")
if __name__ == '__main__':
print("=== 测试修复含税金额功能 ===\n")
test_fix_total_amount()