feat: emit live Excel formulas for ร.15 revenue-estimate semester rows
continuous-integration/drone/push Build is passing

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KhYYmBPw4LhYXoDnTNz2xV
This commit is contained in:
Nut.ไปเรื่อย
2026-08-05 11:26:41 +07:00
parent d9bc1f742f
commit ec4b99f53e
2 changed files with 12 additions and 7 deletions
+10 -7
View File
@@ -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 =