7.4 KiB
7.4 KiB
Late Fee Start Date and Daily Recalculation Evidence (2026-06-30)
Scope
- Backend feature: late-fee start-date calculation for four configured modes, billing-time persistence, and daily recalculation for unpaid charges.
- Backend branch:
feat/late-fee-recalc, merged locally intodevelop - Backend merge commit:
4f1a99b7e Merge branch 'feat/late-fee-recalc' into develop - Docs branch:
feat/rev004-dict-alignment-docs
Backend Commits
8c2714af2 feat: add late fee begin date calculator1724f0c3c feat: resolve late fee parameter config282c327e7 feat: add late fee daily calculator320e50d73 feat: add late fee recalculation mapper helpersfd5154f83 feat: save late fee begin date during billingf7207fe61 feat: add daily late fee recalculation jobaf05601f1 fix: harden late fee recalculation batch3722c54fa fix: paginate late fee recalculation batchesd551dba84 fix: handle late fee reversal and batch transactionsbcc635e81 fix: guard late fee recalculation updates
Implemented Files
sw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeSettingCodes.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeConfig.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeConfigResolver.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeBeginDateCalculator.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeBeginDateApplyService.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeDailyCalculator.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeRecalculationBatchService.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/latefee/LateFeeRecalculationService.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/job/charge/LateFeeRecalculationJob.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/config/ClockConfig.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/dal/mysql/charge/ChargeMapper.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/dal/mysql/paymentrecorddetail/PaymentRecordDetailMapper.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/dal/mysql/latefeereducedetail/LateFeeReduceDetailMapper.javasw-business/sw-business-server/src/main/java/cn/com/emsoft/sw/business/service/charge/ChargeServiceImpl.javascript/xxl-job-init.sqlsql/rev004/REV004_late_fee_daily_recalculation_index.sql- Unit tests under
sw-business/sw-business-server/src/test/java/cn/com/emsoft/sw/business/service/charge/latefee/ sw-business/sw-business-server/src/test/java/cn/com/emsoft/sw/business/service/charge/ChargeLateFeeBeginDateWiringTest.javasw-business/sw-business-server/src/test/java/cn/com/emsoft/sw/business/service/accountingadjust/pricediff/PriceDiffWriteBackServiceTest.java
Review Fixes
- Paid late-fee deduction excludes original
APPLIEDlate-fee details that have aREVERSEDdetail referencing them throughrelatedDetailId. - The daily recalculation batch now selects unpaid charges with non-null
lateFeeBeginDate, avoiding repeated starvation behind historical rows that cannot be recalculated. script/xxl-job-init.sqlregisters handlerlateFeeDailyRecalculationfor business-server with cron0 30 3 * * ?.LateFeeRecalculationServiceTestincludes a defensive scenario where a reversed late-fee detail is returned by the mapper and ignored by aggregation.- The daily recalculation job now uses keyset pagination (
id > lastId) until no eligible rows remain, so rows after the first page are recalculated in the same run instead of waiting forever behind unchanged earlier rows. LateFeeBeginDateApplyServicecentralizeslateFeeBeginDatepersistence and is reused by normal billing, manual charge creation, counter add-reading formalization, and special billing formalization beforechargeMapper.insert.- Focused tests now cover the shared begin-date apply service, keyset pagination across batches, and direct insert path wiring for counter add-reading and special billing.
- Price-diff write-back now applies missing
lateFeeBeginDatebefore inserting the replacement unpaid charge. - Daily recalculation now keeps the outer pagination loop non-transactional and executes each page through
LateFeeRecalculationBatchService.recalculateBatch(...)with its own transaction boundary. - Daily recalculation now updates
lateFeethrough a conditional mapper update that still requirespayState=UNPAIDand non-nulllateFeeBeginDate, so a charge paid after selection is not overwritten or counted. LateFeeDailyCalculatorignores non-positive penalty coefficients defensively.REV004_late_fee_daily_recalculation_index.sqladdsidx_biz_charge_late_fee_recalcon(tenant_id, pay_state, id)for the tenant-scoped unpaid keyset scan.
Verification
Focused Late-Fee Tests
Command:
mvn -pl sw-business/sw-business-server -am -Dtest=LateFeeBeginDateCalculatorTest,LateFeeBeginDateApplyServiceTest,LateFeeConfigResolverTest,LateFeeDailyCalculatorTest,LateFeeRecalculationServiceTest,ChargeLateFeeBeginDateWiringTest,CounterAddReadingApplicationServiceImplTest,SpecialBillingServiceImplTest,PriceDiffWriteBackServiceTest -Dsurefire.failIfNoSpecifiedTests=false test
Result: PASS
LateFeeBeginDateApplyServiceTest: 2 tests, 0 failures, 0 errors, 0 skippedLateFeeRecalculationServiceTest: 8 tests, 0 failures, 0 errors, 0 skippedLateFeeConfigResolverTest: 3 tests, 0 failures, 0 errors, 0 skippedLateFeeBeginDateCalculatorTest: 7 tests, 0 failures, 0 errors, 0 skippedLateFeeDailyCalculatorTest: 9 tests, 0 failures, 0 errors, 0 skippedChargeLateFeeBeginDateWiringTest: 5 tests, 0 failures, 0 errors, 0 skippedPriceDiffWriteBackServiceTest: 1 test, 0 failures, 0 errors, 0 skippedCounterAddReadingApplicationServiceImplTest: 24 tests, 0 failures, 0 errors, 0 skippedSpecialBillingServiceImplTest: 4 tests, 0 failures, 0 errors, 0 skipped- Total: 63 tests, 0 failures, 0 errors, 0 skipped
Existing Accounting Regression Tests
Command:
mvn -pl sw-business/sw-business-server -am -Dtest=LateFeeDateModeCalculatorTest,PaymentRecordServiceImplTest,AccountingAdjustActionServiceImplTest,ChargeServiceBillingValidationTest -Dsurefire.failIfNoSpecifiedTests=false test
Result: PASS
ChargeServiceBillingValidationTest: 8 tests, 0 failures, 0 errors, 0 skippedLateFeeDateModeCalculatorTest: 4 tests, 0 failures, 0 errors, 0 skippedAccountingAdjustActionServiceImplTest: 19 tests, 0 failures, 0 errors, 0 skippedPaymentRecordServiceImplTest: 18 tests, 0 failures, 0 errors, 0 skipped- Total: 49 tests, 0 failures, 0 errors, 0 skipped
Compile
Command:
mvn -pl sw-business/sw-business-server -am -DskipTests compile
Result: PASS
Known Warnings
- Maven reports existing effective-model warnings for duplicate or missing plugin declarations in unrelated modules.
- Mockito reports the existing dynamic-agent warning during unit tests.
- These warnings did not fail the executed verification commands.