Files
sweet-hut-agent/domain/bill.py
2026-07-13 22:06:05 +08:00

41 lines
1.0 KiB
Python

import requests
from config.domain import MetricConfig
BILL_BASE_URL = "https://cxx0822.s.3q.hair/home-api/"
USERNAME = "Cxx0822"
PASSWORD = "19940822Cxx"
_BILL_RAW_CACHE = None
_BILL_FILTERED_CACHE = None
def get_bill_token():
resp = requests.post(
f"{BILL_BASE_URL}session",
params={"name": USERNAME, "password": PASSWORD},
timeout=10,
)
resp.raise_for_status()
return resp.json()["saToken"]["tokenValue"]
BILL_FIELD_NAME_MAP = {
"date": "账单日期",
"bookName": "账本名称",
"type": "账单类型",
"category": "账单类别",
"location": "账单地点",
"payAccount": "支付账户",
"amount": "金额",
"content": "账单内容",
"remark": "备注",
}
BILL_DETAIL_FIELDS = ["date", "bookName", "type", "customer", "category",
"location", "payAccount", "amount", "content", "remark"]
BILL_SEARCH_FIELDS = ["location", "content", "remark"]
BILL_METRICS = [MetricConfig("amount", "金额", agg="sum", format="money")]