v1.7.8 — 首页改为3表格卡片(合同/确收/毛利) + 合同时间维指标
This commit is contained in:
@@ -352,8 +352,19 @@ def bootstrap():
|
||||
cost_q2 = sum_finance(months_q2, "cost_expense")
|
||||
revenue_month = sum_finance([current_month], "revenue")
|
||||
cost_month = sum_finance([current_month], "cost_expense")
|
||||
# Contract aggregates
|
||||
# Contract aggregates — time-based
|
||||
signed_amount = sum(x["expected_contract_amount"] or 0 for x in operations if x["project_status"] == "已签约")
|
||||
from datetime import date
|
||||
today = date.today()
|
||||
def contract_in_period(op, start, end):
|
||||
if op["project_status"] != "已签约": return False
|
||||
try:
|
||||
d = date.fromisoformat(op["created_at"][:10])
|
||||
return start <= d <= end
|
||||
except: return False
|
||||
signed_annual = sum(x["expected_contract_amount"] or 0 for x in operations if contract_in_period(x, date(2026,1,1), date(2026,12,31)))
|
||||
signed_q2 = sum(x["expected_contract_amount"] or 0 for x in operations if contract_in_period(x, date(2026,4,1), date(2026,6,30)))
|
||||
signed_month = sum(x["expected_contract_amount"] or 0 for x in operations if contract_in_period(x, date(2026,6,1), date(2026,6,30)))
|
||||
pipeline_amount = sum(x["expected_contract_amount"] or 0 for x in operations if x["project_status"] not in ["已签约","已丢单","已归档","已完成"])
|
||||
signed_not_executed = sum(x["expected_contract_amount"] or 0 for x in operations if x["project_type"] == "execution" and x["execution_progress"] < 100)
|
||||
summary = {
|
||||
@@ -368,6 +379,9 @@ def bootstrap():
|
||||
"upcoming_products": len([x for x in products if x["status"] in ["规划中", "设计中", "开发中", "测试中"]]),
|
||||
# Extended finance metrics
|
||||
"signed_amount": signed_amount,
|
||||
"signed_annual": signed_annual,
|
||||
"signed_q2": signed_q2,
|
||||
"signed_month": signed_month,
|
||||
"pipeline_amount": pipeline_amount,
|
||||
"revenue_annual": revenue_annual,
|
||||
"revenue_q2": revenue_q2,
|
||||
|
||||
Reference in New Issue
Block a user