收入合计: {incomeLimitAtPeriod:N0}
"); - // 新增:显示不记额收入明细 description.Append("无不记额收入
"); - else + if (noLimitIncomeItems.Count > 0) { description.Append("""不记额支出合计: {noLimitExpenseAtPeriod:N0}
"); description.Append("计划收入 = 预算 {incomeLimitAtPeriod:N0} + 不记额 {noLimitIncomeAtPeriod:N0} = {totalIncome:N0}
"); description.Append($"计划支出 = 预算 {expenseLimitAtPeriod:N0} + 不记额 {noLimitExpenseAtPeriod:N0} = {totalExpense:N0}
"); - description.Append($"最终目标:{totalIncome - totalExpense:N0}
"); + + decimal historicalSurplus = 0; + if (periodType == BudgetPeriodType.Year) + { + var archives = await budgetArchiveRepository.GetArchivesByYearAsync(date.Year); + if (archives.Count > 0) + { + var expenseSurplus = archives.Sum(a => a.ExpenseSurplus); + var incomeSurplus = archives.Sum(a => a.IncomeSurplus); + historicalSurplus = expenseSurplus + incomeSurplus; + + description.Append("| 月份 | +支出结余 | +收入结余 | +合计 | +
|---|---|---|---|
| {archive.Month}月 | +{archive.ExpenseSurplus:N0} | +{archive.IncomeSurplus:N0} | +{monthlyTotal:N0} | +
| 汇总 | +{expenseSurplus:N0} | +{incomeSurplus:N0} | +{historicalSurplus:N0} | +
动态目标 = 计划盈余 {totalIncome - totalExpense:N0} + 历史盈亏 {historicalSurplus:N0} = {finalGoal:N0}
"); + } + else + { + description.Append($"最终目标:{totalIncome - totalExpense:N0}
"); + } + + var finalLimit = periodType == BudgetPeriodType.Year ? (totalIncome - totalExpense + historicalSurplus) : (totalIncome - totalExpense); var virtualBudget = await BuildVirtualSavingsBudgetRecordAsync( periodType == BudgetPeriodType.Year ? -1 : -2, date, - totalIncome - totalExpense); // 修改:使用总金额 + finalLimit); // 计算实际发生的 收入 - 支出 var current = await CalculateCurrentAmountAsync(new BudgetRecord diff --git a/Web/src/api/budget.js b/Web/src/api/budget.js index 4720485..8876fd9 100644 --- a/Web/src/api/budget.js +++ b/Web/src/api/budget.js @@ -95,3 +95,17 @@ export function updateArchiveSummary(data) { data }) } + +/** + * 获取指定周期的存款预算信息 + * @param {number} year 年份 + * @param {number} month 月份 + * @param {number} type 周期类型 (1:Month, 2:Year) + */ +export function getSavingsBudget(year, month, type) { + return request({ + url: '/Budget/GetSavingsBudget', + method: 'get', + params: { year, month, type } + }) +} diff --git a/Web/src/components/Budget/BudgetCard.vue b/Web/src/components/Budget/BudgetCard.vue index b763f47..ac59911 100644 --- a/Web/src/components/Budget/BudgetCard.vue +++ b/Web/src/components/Budget/BudgetCard.vue @@ -133,6 +133,10 @@ + + diff --git a/Web/src/views/BudgetView.vue b/Web/src/views/BudgetView.vue index 648acf7..3fefa76 100644 --- a/Web/src/views/BudgetView.vue +++ b/Web/src/views/BudgetView.vue @@ -170,6 +170,33 @@ + + + +