Commit 7cca10fcc9499b82c71b1955b89b720bfe8d3748
1 parent
752852ae
[FIX] FMS:报表校验逐月查损益改直调账簿余额,断 getClosingOverview↔checkBalanceSheet 无限递归(A40)- #1215
#1215
Showing
3 changed files
with
8 additions
and
13 deletions
yudao-module-fms/src/main/java/cn/iocoder/yudao/module/fms/service/closing/FmsClosingPeriodService.java
| ... | ... | @@ -61,9 +61,6 @@ public interface FmsClosingPeriodService { |
| 61 | 61 | /** |
| 62 | 62 | * 获得指定会计期间的损益结转余额(末级损益科目本期借贷差额绝对值之和) |
| 63 | 63 | * |
| 64 | - * 供报表勾稽逐月检查损益是否结转使用:直接查账簿余额, | |
| 65 | - * 不重入 getClosingOverview(后者内部会回调报表 check,构成无限递归)。 | |
| 66 | - * | |
| 67 | 64 | * @param accountSetId 账套编号 |
| 68 | 65 | * @param month 会计期间 |
| 69 | 66 | * @param userId 用户编号 | ... | ... |
yudao-module-fms/src/main/java/cn/iocoder/yudao/module/fms/service/report/FmsBalanceSheetServiceImpl.java
| ... | ... | @@ -7,8 +7,6 @@ import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| 9 | 9 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 10 | -import cn.iocoder.yudao.module.fms.controller.admin.closing.vo.FmsClosingOverviewRespVO; | |
| 11 | -import cn.iocoder.yudao.module.fms.controller.admin.closing.vo.FmsClosingQueryReqVO; | |
| 12 | 10 | import cn.iocoder.yudao.module.fms.controller.admin.ledger.vo.subjectbalance.FmsLedgerSubjectBalanceRespVO; |
| 13 | 11 | import cn.iocoder.yudao.module.fms.controller.admin.report.vo.balance.FmsBalanceSheetCheckRespVO; |
| 14 | 12 | import cn.iocoder.yudao.module.fms.controller.admin.report.vo.balance.FmsBalanceSheetRowRespVO; |
| ... | ... | @@ -292,7 +290,7 @@ public class FmsBalanceSheetServiceImpl implements FmsBalanceSheetService { |
| 292 | 290 | } |
| 293 | 291 | |
| 294 | 292 | /** |
| 295 | - * 判断查询期间内各月的损益是否均已结转,逐月检查结账概览的损益余额 | |
| 293 | + * 判断查询期间内各月的损益是否均已结转 | |
| 296 | 294 | * |
| 297 | 295 | * @param listReqVO 查询条件 |
| 298 | 296 | * @param userId 用户编号 |
| ... | ... | @@ -302,8 +300,7 @@ public class FmsBalanceSheetServiceImpl implements FmsBalanceSheetService { |
| 302 | 300 | YearMonth endMonth = LocalDateTimeUtils.parseYearMonth(listReqVO.getEndMonth()); |
| 303 | 301 | for (YearMonth currentMonth = LocalDateTimeUtils.parseYearMonth(listReqVO.getStartMonth()); |
| 304 | 302 | !currentMonth.isAfter(endMonth); currentMonth = currentMonth.plusMonths(1)) { |
| 305 | - // 直接查当月损益余额,不再重入 getClosingOverview | |
| 306 | - //(其内部会回调本类 checkBalanceSheet → 本方法,对同月构成无界自递归,栈溢出) | |
| 303 | + // 直接查询损益余额,避免报表校验与结账概况循环调用 | |
| 307 | 304 | BigDecimal profitLossBalance = closingPeriodService.getProfitLossBalance( |
| 308 | 305 | listReqVO.getAccountSetId(), currentMonth.toString(), userId); |
| 309 | 306 | // 当月损益余额不为零时,说明存在尚未结转的损益 | ... | ... |
yudao-module-fms/src/test/java/cn/iocoder/yudao/module/fms/service/report/FmsBalanceSheetServiceImplTest.java
| ... | ... | @@ -21,7 +21,6 @@ import cn.iocoder.yudao.module.fms.dal.mysql.report.balance.FmsBalanceSheetConfi |
| 21 | 21 | import cn.iocoder.yudao.module.fms.dal.mysql.report.balance.FmsBalanceSheetReportMapper; |
| 22 | 22 | import cn.iocoder.yudao.module.fms.enums.config.FmsSubjectTypeEnum; |
| 23 | 23 | import cn.iocoder.yudao.module.fms.enums.report.FmsReportTypeEnum; |
| 24 | -import cn.iocoder.yudao.module.fms.controller.admin.closing.vo.FmsClosingOverviewRespVO; | |
| 25 | 24 | import cn.iocoder.yudao.module.fms.service.closing.FmsClosingPeriodService; |
| 26 | 25 | import cn.iocoder.yudao.module.fms.service.closing.FmsClosingSchemeService; |
| 27 | 26 | import cn.iocoder.yudao.module.fms.service.closing.FmsClosingVoucherService; |
| ... | ... | @@ -46,6 +45,7 @@ import java.util.List; |
| 46 | 45 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 47 | 46 | import static org.junit.jupiter.api.Assertions.assertFalse; |
| 48 | 47 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 48 | +import static org.junit.jupiter.api.Assertions.assertTrue; | |
| 49 | 49 | import static org.mockito.ArgumentMatchers.any; |
| 50 | 50 | import static org.mockito.ArgumentMatchers.eq; |
| 51 | 51 | import static org.mockito.Mockito.when; |
| ... | ... | @@ -206,8 +206,8 @@ public class FmsBalanceSheetServiceImplTest extends BaseDbUnitTest { |
| 206 | 206 | FmsTrialBalanceRespVO trialBalance = new FmsTrialBalanceRespVO(); |
| 207 | 207 | trialBalance.setBalanced(false); |
| 208 | 208 | when(initialBalanceService.getTrialBalance(1L, 10L)).thenReturn(trialBalance); |
| 209 | - when(closingPeriodService.getClosingOverview(any(), eq(10L))) | |
| 210 | - .thenReturn(new FmsClosingOverviewRespVO().setProfitLossBalance(new BigDecimal("20.00"))); | |
| 209 | + when(closingPeriodService.getProfitLossBalance(1L, "2026-08", 10L)) | |
| 210 | + .thenReturn(new BigDecimal("20.00")); | |
| 211 | 211 | |
| 212 | 212 | // 调用 |
| 213 | 213 | FmsBalanceSheetCheckRespVO result = balanceSheetService.checkBalanceSheet(buildQueryReqVO(), 10L); |
| ... | ... | @@ -241,14 +241,15 @@ public class FmsBalanceSheetServiceImplTest extends BaseDbUnitTest { |
| 241 | 241 | .setChildren(Collections.emptyList()))); |
| 242 | 242 | when(initialBalanceService.getTrialBalance(1L, 10L)) |
| 243 | 243 | .thenReturn(new FmsTrialBalanceRespVO().setBalanced(true)); |
| 244 | - when(closingPeriodService.getClosingOverview(any(), eq(10L))) | |
| 245 | - .thenReturn(new FmsClosingOverviewRespVO().setProfitLossBalance(BigDecimal.ZERO)); | |
| 244 | + when(closingPeriodService.getProfitLossBalance(1L, "2026-08", 10L)) | |
| 245 | + .thenReturn(BigDecimal.ZERO); | |
| 246 | 246 | |
| 247 | 247 | // 调用 |
| 248 | 248 | FmsBalanceSheetCheckRespVO result = balanceSheetService.checkBalanceSheet(buildQueryReqVO(), 10L); |
| 249 | 249 | |
| 250 | 250 | // 断言 |
| 251 | 251 | assertEquals(0, result.getUnmappedSubjects().size()); |
| 252 | + assertTrue(result.getProfitLossTransferred()); | |
| 252 | 253 | } |
| 253 | 254 | |
| 254 | 255 | // ========== 随机对象 ========== | ... | ... |