fix: 澄清未知成本前利润语义
This commit is contained in:
@@ -120,7 +120,7 @@ function renderProfit(response: Record<string, unknown>): RenderedCliResult {
|
||||
const summary = record(report.summary);
|
||||
const completeness = record(report.completeness);
|
||||
const confirmedCosts = record(summary.confirmedCostsCny);
|
||||
const confirmedProfit = record(summary.confirmedProfitCny);
|
||||
const profitBeforeUnknownCosts = record(summary.profitBeforeUnknownCostsCny);
|
||||
const unknownBasis = record(summary.unknownCostBasisApiUsd);
|
||||
const formulas = record(summary.profitFormula);
|
||||
const disclosure = record(response.disclosure);
|
||||
@@ -132,10 +132,10 @@ function renderProfit(response: Record<string, unknown>): RenderedCliResult {
|
||||
"SUMMARY",
|
||||
];
|
||||
lines.push(table(
|
||||
["SCOPE", "STATUS", "REVENUE_CNY", "PROFIT_POOL_COST_CNY", "SELF_USE_COST_CNY", "CONFIRMED_PROFIT_CNY", "UNKNOWN_API_USD"],
|
||||
["SCOPE", "STATUS", "REVENUE_CNY", "PROFIT_POOL_COST_CNY", "SELF_USE_COST_CNY", "PROFIT_BEFORE_UNKNOWN_COSTS_CNY", "UNKNOWN_API_USD"],
|
||||
[
|
||||
["不扣自用", text(record(summary.withoutSelfUse).status), cny(summary.revenueCny), cny(confirmedCosts.profitPool), "-", cny(confirmedProfit.withoutSelfUse), apiUsd(unknownBasis.profitPool)],
|
||||
["扣除自用", text(record(summary.withSelfUse).status), cny(summary.revenueCny), cny(confirmedCosts.profitPool), cny(confirmedCosts.selfUse), cny(confirmedProfit.withSelfUse), apiUsd(unknownBasis.total)],
|
||||
["不扣自用", text(record(summary.withoutSelfUse).status), cny(summary.revenueCny), cny(confirmedCosts.profitPool), "-", cny(profitBeforeUnknownCosts.withoutSelfUse), apiUsd(unknownBasis.profitPool)],
|
||||
["扣除自用", text(record(summary.withSelfUse).status), cny(summary.revenueCny), cny(confirmedCosts.profitPool), cny(confirmedCosts.selfUse), cny(profitBeforeUnknownCosts.withSelfUse), apiUsd(unknownBasis.total)],
|
||||
],
|
||||
));
|
||||
lines.push("", "FORMULA");
|
||||
|
||||
@@ -180,8 +180,8 @@ def run_profit_report():
|
||||
self_cost = sum((profit_decimal(row["upstreamCostCny"]) for row in self_accounts if row["upstreamCostCny"] is not None), profit_decimal(0))
|
||||
unknown_profit_api_usd = sum((profit_decimal(row["apiAmountUsd"]) for row in missing_profit), profit_decimal(0))
|
||||
unknown_self_api_usd = sum((profit_decimal(row["apiAmountUsd"]) for row in missing_self), profit_decimal(0))
|
||||
confirmed_without_self = revenue - profit_cost
|
||||
confirmed_with_self = confirmed_without_self - self_cost
|
||||
profit_before_unknown_without_self = revenue - profit_cost
|
||||
profit_before_unknown_with_self = profit_before_unknown_without_self - self_cost
|
||||
without_complete = not missing_profit and not unclassified
|
||||
with_complete = without_complete and not missing_self
|
||||
account_rows.sort(key=lambda row: (row["class"], row["groupName"], str(row["accountId"]), str(row["accountName"])))
|
||||
@@ -201,9 +201,9 @@ def run_profit_report():
|
||||
"selfUse": profit_decimal_text(self_cost),
|
||||
"total": profit_decimal_text(profit_cost + self_cost),
|
||||
},
|
||||
"confirmedProfitCny": {
|
||||
"withoutSelfUse": profit_decimal_text(confirmed_without_self),
|
||||
"withSelfUse": profit_decimal_text(confirmed_with_self),
|
||||
"profitBeforeUnknownCostsCny": {
|
||||
"withoutSelfUse": profit_decimal_text(profit_before_unknown_without_self),
|
||||
"withSelfUse": profit_decimal_text(profit_before_unknown_with_self),
|
||||
},
|
||||
"unknownCostBasisApiUsd": {
|
||||
"profitPool": profit_decimal_text(unknown_profit_api_usd),
|
||||
@@ -211,11 +211,11 @@ def run_profit_report():
|
||||
"total": profit_decimal_text(unknown_profit_api_usd + unknown_self_api_usd),
|
||||
},
|
||||
"profitFormula": {
|
||||
"withoutSelfUse": "confirmedProfitCny.withoutSelfUse - sum(missing profit account apiAmountUsd * unknown costRateCnyPerApiUsd)",
|
||||
"withSelfUse": "confirmedProfitCny.withSelfUse - sum(all missing account apiAmountUsd * unknown costRateCnyPerApiUsd)",
|
||||
"withoutSelfUse": "profitBeforeUnknownCostsCny.withoutSelfUse - sum(missing profit account apiAmountUsd * unknown costRateCnyPerApiUsd)",
|
||||
"withSelfUse": "profitBeforeUnknownCostsCny.withSelfUse - sum(all missing account apiAmountUsd * unknown costRateCnyPerApiUsd)",
|
||||
},
|
||||
"withoutSelfUse": {"status": "complete" if without_complete else "partial", "profitCny": profit_decimal_text(confirmed_without_self) if without_complete else None},
|
||||
"withSelfUse": {"status": "complete" if with_complete else "partial", "profitCny": profit_decimal_text(confirmed_with_self) if with_complete else None},
|
||||
"withoutSelfUse": {"status": "complete" if without_complete else "partial", "profitCny": profit_decimal_text(profit_before_unknown_without_self) if without_complete else None},
|
||||
"withSelfUse": {"status": "complete" if with_complete else "partial", "profitCny": profit_decimal_text(profit_before_unknown_with_self) if with_complete else None},
|
||||
},
|
||||
"completeness": {
|
||||
"missingCostAccounts": [{"class": row["class"], "groupName": row["groupName"], "accountId": row["accountId"], "accountName": row["accountName"], "apiAmountUsd": row["apiAmountUsd"]} for row in missing_profit + missing_self],
|
||||
|
||||
Reference in New Issue
Block a user