From ec4b99f53ecbb3c21e41dd5344e2b9fd7a3fd25e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nut=2E=E0=B9=84=E0=B8=9B=E0=B9=80=E0=B8=A3=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=A2?= Date: Wed, 5 Aug 2026 11:26:41 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20emit=20live=20Excel=20formulas=20for=20?= =?UTF-8?q?=E0=B8=A3.15=20revenue-estimate=20semester=20rows?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace static computed values for F/H/J/L/N/P/R with FormulaA1 cell formulas (=B-D, =(F*10)/100, etc.) so the exported report is auditable and recalculates in Excel, matching a reference ร15.xlsx. P/R now use the per-row contribution/framework percent passed from rmutr-api instead of a fixed 40%. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01KhYYmBPw4LhYXoDnTNz2xV --- Controllers/Budget.Controller.cs | 17 ++++++++++------- Models/budget/revenue_estimates.cs | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Controllers/Budget.Controller.cs b/Controllers/Budget.Controller.cs index c203b9d..715d61c 100644 --- a/Controllers/Budget.Controller.cs +++ b/Controllers/Budget.Controller.cs @@ -2290,24 +2290,27 @@ namespace rmutr_report.Controllers if (detail.topic_type == 3) { + var contributionPercent = detail.contribution_percent ?? 40; + var frameworkPercent = detail.framework_percent ?? 40; + ws.Cell(row, 1).Value = detail.topic; ws.Cell(row, 2).Value = detail.revenue_estimates; ws.Cell(row, 3).Value = "บาท"; ws.Cell(row, 4).Value = detail.less_revenue_estimates; ws.Cell(row, 5).Value = "บาท"; - ws.Cell(row, 6).Value = detail.balance_revenue_estimates; + ws.Cell(row, 6).FormulaA1 = $"=B{row}-D{row}"; ws.Cell(row, 7).Value = "บาท"; - ws.Cell(row, 8).Value = detail.less_accumulated_income; + ws.Cell(row, 8).FormulaA1 = $"=(F{row}*10)/100"; ws.Cell(row, 9).Value = "บาท"; - ws.Cell(row, 10).Value = detail.balance_before_allocating_according; + ws.Cell(row, 10).FormulaA1 = $"=F{row}-H{row}"; ws.Cell(row, 11).Value = "บาท"; - ws.Cell(row, 12).Value = detail.contribution_utility_bills; + ws.Cell(row, 12).FormulaA1 = $"=(J{row}*5)/100"; ws.Cell(row, 13).Value = "บาท"; - ws.Cell(row, 14).Value = detail.contribution_central_budget; + ws.Cell(row, 14).FormulaA1 = $"=(J{row}*15)/100"; ws.Cell(row, 15).Value = "บาท"; - ws.Cell(row, 16).Value = detail.contribution_central_expenditure; + ws.Cell(row, 16).FormulaA1 = $"=(J{row}*{contributionPercent})/100"; ws.Cell(row, 17).Value = "บาท"; - ws.Cell(row, 18).Value = detail.expenditure_limit; + ws.Cell(row, 18).FormulaA1 = $"=(J{row}*{frameworkPercent})/100"; ws.Cell(row, 19).Value = "บาท"; ws.Range(ws.Cell(row, 1), ws.Cell(row, 19)).Style.Font.FontName = diff --git a/Models/budget/revenue_estimates.cs b/Models/budget/revenue_estimates.cs index 97729a9..992fe04 100644 --- a/Models/budget/revenue_estimates.cs +++ b/Models/budget/revenue_estimates.cs @@ -46,6 +46,8 @@ namespace rmutr_report.Models public decimal? contribution_central_budget { get; set; } public decimal? contribution_central_expenditure { get; set; } public decimal? expenditure_limit { get; set; } + public decimal? contribution_percent { get; set; } + public decimal? framework_percent { get; set; } public int? topic_type { get; set; }