{
  "task": "FIN-STAT-PERF",
  "redmine": 39,
  "recordedAt": "2026-11-02T10:21:01+08:00",
  "comparison": "git show f1aadbd original FinancialStatistics class and original round_money/gross margin helpers, unchanged shared services; exact old/new HTTP JSON fields/types/month order including annual_total",
  "baseline": {
    "task": "FIN-STAT-PERF",
    "issue": 39,
    "baselineCommit": "f1aadbdf12ccdaab79fac748baa03ff06d99c380",
    "branch": "bugfix/finance-statistics-performance",
    "candidateFiles": {
      "api/finance/views.py": "a60309943816d442a47cb40b2fdc68394824df1d29016e9be2320cb005ba3d33",
      "api/finance/statistics.py": "9ca03ae35295aa0353d2561e9da58dae0736f18d1c49741c13d12c2dea66d14a",
      "api/finance/test_statistics_performance.py": "20fd8f9dff8781a6a0e5b44877c46cfa3687ff9b4e6e32b5d21099d9ca3e578e"
    },
    "baselineViewsSHA256": "f3e9027ffb1785eb6e5e0ae0b7a2f15b131b10981d78bb268be7d38fc8ee494e",
    "baselineExtractedSHA256": "43938a31035507448ba72061a04db5ecbbbd21415bd21b559c026e20ae024af0",
    "extraction": "AST source segments of exact original FinancialStatistics class plus original round_money/calculate_gross_margin_rate; no developer oracle",
    "unchangedDependencies": {
      "api/finance/services.py": {
        "baselineSHA256": "398506e847c44e88dd8f1270d014a8d5020c30663c356766379b0337ceb29081",
        "currentSHA256": "398506e847c44e88dd8f1270d014a8d5020c30663c356766379b0337ceb29081",
        "unchanged": true
      },
      "api/projects/models.py": {
        "baselineSHA256": "2e7e44f15ae166b325363b2e7fea9aca0b6f30efd81298440f4617f9c43de78f",
        "currentSHA256": "2e7e44f15ae166b325363b2e7fea9aca0b6f30efd81298440f4617f9c43de78f",
        "unchanged": true
      },
      "config/auth/permissions.py": {
        "baselineSHA256": "594ce88bf75ca9cbbd3a5a8da142541c05c07012712e40b8ea73fc99c160590f",
        "currentSHA256": "594ce88bf75ca9cbbd3a5a8da142541c05c07012712e40b8ea73fc99c160590f",
        "unchanged": true
      },
      "api/finance/urls.py": {
        "baselineSHA256": "9e1f1c6ad80c6808cd709cd5aa9b4d420a8a1d182183234ad348c82c96dc89af",
        "currentSHA256": "9e1f1c6ad80c6808cd709cd5aa9b4d420a8a1d182183234ad348c82c96dc89af",
        "unchanged": true
      }
    }
  },
  "cases": [
    {
      "id": "FINQA-01-BOUNDARY",
      "status": "Pass",
      "at": "2026-11-02T10:17:21.466961",
      "actual": {
        "months": 12,
        "allResponseFieldsIncludingAnnualTotalEqual": true,
        "cases": "history/future/deleted/missing rates; four expense categories; company_payment zero/empty/null; deleted/null-deleted/unknown costs; explicit hour priority"
      },
      "impact": "IMP-01 / REG-01",
      "name": "12月多币种/历史汇率与字段优先级",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "POST年2022至基线及当前真实HTTP；历史、当月、未来、软删汇率与默认回退，company_payment显式0/空/缺失、软删及null删除费用、四分类和小时优先均应保持完整响应一致",
      "evidence": "pair-boundary-12-months.json"
    },
    {
      "id": "FINQA-02-FILTERS",
      "status": "Pass",
      "at": "2026-11-02T10:17:21.639616",
      "actual": {
        "companyVariants": 3,
        "yearStatusAndPayableOnly": "same full baseline API; valid zero-income expert payable rows, nonfinished/zero/negative regular income filtered"
      },
      "impact": "IMP-01 / REG-02",
      "name": "客户、年份、状态和专家应付范围",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "对年2023分别请求公司A/B及字符串0筛选；完成、未完成、跨年、普通零/负收入、合法专家应付零收入按原完整接口比较",
      "evidence": "pair-filters-1.json; pair-filters-2.json; pair-filters-0.json"
    },
    {
      "id": "FINQA-03-ROUNDING",
      "status": "Pass",
      "at": "2026-11-02T10:17:21.699165",
      "actual": {
        "allResponseFieldsIncludingAnnualTotalEqual": true,
        "paymentInfoPrecision": [
          "0.005",
          "0.015",
          "-0.005",
          "-1.005"
        ],
        "monthlyThenAnnual": true
      },
      "impact": "IMP-01 / REG-01",
      "name": "小数临界、负费用、月年汇总",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "使用JSON公司支付0.005/0.015/-0.005/-1.005及多类费用；年2031完整API应与旧类逐字段相等，annual_total沿原月度四舍五入汇总",
      "evidence": "pair-rounding.json"
    },
    {
      "id": "FINQA-04-RANDOM",
      "status": "Pass",
      "at": "2026-11-02T10:17:22.259261",
      "actual": {
        "seed": 20261102,
        "randomTasks": 300,
        "queryVariants": 6,
        "allResponseFieldsEqual": true,
        "includesLeapAndYearBoundaries": true
      },
      "impact": "IMP-01 / REG-01/02",
      "name": "固定种子300任务随机差分",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "seed20261102生成300任务/费用混合状态、币种和公司；对2026全量/公司A/B及2025/2027/2024共6组比较；含闰日和年界，差异应0",
      "evidence": "random-input.json; pair-random-*.json"
    },
    {
      "id": "FINQA-05-ZERO-INCOME",
      "status": "Pass",
      "at": "2026-11-02T10:17:22.312881",
      "actual": {
        "negativeExpense": "real credit/negative company payment included identically",
        "annualGrossMargin": 0
      },
      "impact": "IMP-01 / REG-01/02",
      "name": "零收入及负费用的毛利边界",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "年2032仅合法专家应付任务、company_payment=-7.005；完整响应应与旧类相等，收入0时毛利率保持0",
      "evidence": "pair-zero-income-negative-cost.json"
    },
    {
      "id": "FINQA-06-EMPTY",
      "status": "Pass",
      "at": "2026-11-02T10:17:22.364654",
      "actual": {
        "twelveMonthsAllFieldsZero": true,
        "annualTotalEqual": true
      },
      "impact": "IMP-01 / REG-02",
      "name": "空年度响应",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "年2199无任务；七组月数组均12个零，annual_total全部原字段/类型/金额相等",
      "evidence": "pair-empty-year.json"
    },
    {
      "id": "FINQA-07-RATE-EDIT",
      "status": "Pass",
      "at": "2026-11-02T10:17:22.455383",
      "actual": {
        "nextRequestSeesFixtureRateEdit": true,
        "matchesRealBaseline": true,
        "noCacheResetUsed": true
      },
      "impact": "IMP-01 / REG-01",
      "name": "请求内复用不变成跨请求缓存",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "仅更新本次合成USD2022-01汇率后再请求；结果须发生对应变化且立即与旧真实接口一致，不手动清缓存",
      "evidence": "pair-rate-edit-next-request.json"
    },
    {
      "id": "FINQA-08-QUERY-BOUND",
      "status": "Pass",
      "at": "2026-11-02T10:17:22.640851",
      "actual": {
        "metrics": {
          "query-small-old": {
            "case": "query-small-old",
            "path": "/qa-baseline/v1/finances/statistics",
            "dataSQLCount": 18,
            "allSQLCount": 21,
            "elapsedSeconds": 0.014752833000000187,
            "onlyFinancialSelect": true
          },
          "query-small-new": {
            "case": "query-small-new",
            "path": "/v1/finances/statistics",
            "dataSQLCount": 3,
            "allSQLCount": 6,
            "elapsedSeconds": 0.006790207999999964,
            "onlyFinancialSelect": true
          },
          "query-large-old": {
            "case": "query-large-old",
            "path": "/qa-baseline/v1/finances/statistics",
            "dataSQLCount": 170,
            "allSQLCount": 173,
            "elapsedSeconds": 0.05354383400000007,
            "onlyFinancialSelect": true
          },
          "query-large-new": {
            "case": "query-large-new",
            "path": "/v1/finances/statistics",
            "dataSQLCount": 3,
            "allSQLCount": 6,
            "elapsedSeconds": 0.00827650000000002,
            "onlyFinancialSelect": true
          }
        },
        "notProductionBenchmark": true
      },
      "impact": "IMP-02 / REG-03",
      "name": "实际HTTP统计数据SQL增长",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "比较小公司1条任务及随机大池中符合目标年/公司的任务子集；实际HTTP中财务数据SELECT保持至多3条，金额仍与旧类一致",
      "evidence": "sql-observations.json; pair-query-small.json; pair-query-large.json"
    },
    {
      "id": "FINQA-09-PERMISSIONS",
      "status": "Pass",
      "at": "2026-11-02T10:17:22.792302",
      "actual": {
        "financeAllowed": true,
        "paDenied": 403,
        "anonymousDenied": 401,
        "salesOriginalAllowancePreserved": true,
        "normalJWTAuthBothViews": true
      },
      "impact": "IMP-03 / REG-04/05",
      "name": "真实URL、正常登录与权限",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "独立本地合成finance/pa/sales账号经正常密码登录，不force_authenticate；两端都执行真实JWT认证；finance成功、PA403、匿名401，保留旧Sales允许规则",
      "evidence": "http-observations.json; pair-permission-pa.json; pair-permission-anonymous.json; pair-permission-sales.json"
    },
    {
      "id": "FINQA-10-READ-ONLY",
      "status": "Pass",
      "at": "2026-11-02T10:17:22.792605",
      "actual": {
        "oldNewHTTPPairs": 19,
        "financialFullRowsUnchangedEachPair": true,
        "normalAuthAuditOnlyOutsideFinancialTables": true,
        "externalAttempts": 0
      },
      "impact": "IMP-03 / REG-04",
      "name": "统计接口财务副作用与隔离",
      "layer": "real localhost WSGI HTTP + fresh isolated SQLite ORM; exact baseline view",
      "precondition": "same synthetic QA-only database, same normal JWT auth, original view extracted from baseline commit, no developer oracle",
      "stepsExpected": "每组旧/新HTTP前后对公司/项目/Task/Cost/汇率完整行比较；统计不得写财务，外连0，业务文件sha始终匹配",
      "evidence": "pair-*.json; cleanup.json; candidate-and-baseline.json"
    }
  ],
  "counts": {
    "Pass": 10,
    "Fail": 0,
    "Blocked": 0,
    "Skipped": 0
  },
  "HTTPPairs": 19,
  "successfulResponsePairs": 17,
  "permissionDenialPairs": 2,
  "developer13ReusedNotRun": true,
  "fixtureCounts": {
    "Companies": 3,
    "Projects": 3,
    "ProjectTasks": 333,
    "ProjectTaskCosts": 1126,
    "CurrencyExchangeRate": 9
  },
  "cleanup": {
    "onlyQAOwnedSQLiteRemoved": true,
    "localServerStopped": true,
    "workerStopped": true,
    "sharedServicesTouched": false,
    "candidateUnchanged": true,
    "externalAttempts": [],
    "noRealCredentialsUsed": true,
    "QAArtifactsRetained": true
  },
  "unmeasured": [
    "unchanged Web actual browser/page interaction",
    "PostgreSQL query plan, production-sized memory/concurrency",
    "shared/test/production environment or real business data",
    "production performance improvement"
  ],
  "businessSourceChangedByQA": false,
  "deploymentAuthorized": false
}
