報告:selectDto.taxTableCode.equals(TAX_CODE_HEI) 條件判斷調查
Copyright Notice: This article is an original work licensed under the CC 4.0 BY-NC-ND license.
If you wish to repost this article, please include the original source link and this copyright notice.
Source link: https://v2know.com/article/1271
1. 調查目的
確認在程式中使用 selectDto.taxTableCode.equals(TAX_CODE_HEI) 是否能作為有效條件判斷,並釐清 taxTableCode 的取值來源及其在服務邏輯中的實際作用。
2. 調查結果
2.1 taxTableCode 取值來源
-
taxTableCode來源於MonthAccountCalcSelectResearchData.sql,直接查詢 M_RESEARCHER 表的tax_table_code欄位。 -
查詢結果會封裝至
MonthAccountCalcResearchRecordDto.taxTableCode,供後續邏輯使用。
2.2 DTO 定義
-
MonthAccountCalcResearchRecordDto包含taxTableCode屬性。 -
該屬性若無查詢結果則預設為空字串,但正常情況下會被 SQL 查詢結果覆蓋。
2.3 服務邏輯
-
在
calcTaxWithholding...系列方法中,邏輯會依據taxTableCode進行分支判斷。 -
甲 (1) 與乙 (2):直接透過
selectDto.taxTableCode分支。 -
丙 (3):並非僅靠
taxTableCode判斷,而是透過oneoffResearchKbn與countOfResearch的組合條件實現。 -
換言之,程式碼並不會單純用
taxTableCode == TAX_CODE_HEI ("3")作為丙類判斷條件。
3. 結論
-
selectDto.taxTableCode可正確取得資料庫中的值-
若資料庫記錄為
3,則 DTO 會反映為"3"。
-
-
單純判斷不足
-
僅使用
selectDto.taxTableCode.equals(TAX_CODE_HEI)作為條件雖然可行,但不足以完整覆蓋業務需求。 -
丙類邏輯必須同時結合
oneoffResearchKbn與countOfResearch,否則可能導致誤判。
-
-
建議
-
在程式中應 同時檢查
taxTableCode、oneoffResearchKbn與countOfResearch,以符合正確的業務分支規則。 -
僅以
taxTableCode.equals(TAX_CODE_HEI)作判斷僅適合作為初步篩選條件,不應視為完整判斷依據。
-
✅ 結論:
selectDto.taxTableCode.equals(TAX_CODE_HEI) 能取得正確值,但若要正確處理丙類判斷,必須搭配 oneoffResearchKbn 與 countOfResearch。
This article was last edited at