61 lines
1.9 KiB
Python
61 lines
1.9 KiB
Python
|
|
#!/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()
|