Depreciation report: 0% depreciation category is missing from the report
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 54/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- graphql, typescript
Hướng nghiên cứu
Start by reproducing the issue in the depreciation report, then inspect packages/server/src/modules/reports/helpers/depreciation-report.helper.ts, especially calculateDepreciation, and the resolver at reports/resolvers/depreciation-report.resolver.ts. Trace the client table under components/screens/reports/depreciation-report/ if the category is still absent after fixing the calculations. Add the requested helper and resolver tests; done means a 0% category reports cost and net value correctly with no NaN or Infinity, while non-zero results remain unchanged.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug
A depreciation category with a 0% rate works on the charge side (entering it on a charge, generating the ledger), but it does not show up in the depreciation report. Make the report present it.
Likely cause
The report maths in packages/server/src/modules/reports/helpers/depreciation-report.helper.ts (calculateDepreciation) divides by the rate and doesn't handle a rate of 0:
- With no explicit end date,
yearsToFullDepreciation = 1 / normalizedRateisInfinity, so the computedfullDepreciationYearanddepreciationEndDateare garbage (Math.ceil(Infinity), then date maths on it). - The return value computes
depreciationRate * (yearlyDepreciationAmount / annualDepreciationAmount), which is0 * (0 / 0)=NaNwhen the annual amount is 0.
NaN amounts can't be serialized as GraphQL Float, and the bad dates can throw. So the depreciationReport resolver (reports/resolvers/depreciation-report.resolver.ts) probably fails for that record or category, and the category is missing from the result. I haven't run the report with a 0% category, so please confirm by reproducing first.
The ledger side apparently doesn't hit this, which is why generation works.
Expected behavior
- A 0% category appears in the depreciation report with its assets: original cost / report-year additions, 0 yearly depreciation, 0 accumulated depreciation, and net value equal to cost (the asset never depreciates).
- The statutory rate shows
0%, and the claimed rate shows0(or-), neverNaN. - The report totals and
calculateDepreciationAmount(used for the tax report) stay correct, and 0% records contribute 0.
Suggested fix
- In
calculateDepreciation, handle a rate of 0 up front. ReturnyearlyDepreciationAmount: 0,yearlyDepreciationRate: 0andpastDepreciationAmount: 0(or0 / activation checksas appropriate) before any division. Never compute1 / normalizedRateor thex / annualDepreciationAmountratio when the rate or annual amount is 0. - Guard the ratio in the returned
yearlyDepreciationRateagainstannualDepreciationAmount === 0. - Check the client table (
components/screens/reports/depreciation-report/) for assumptions that hide empty or zero-rate rows. ItsclaimedDepreciationRate ? ... : ...truthiness check is OK for 0 but worth a look. - Make sure rows aren't dropped silently: the resolver logs and returns when a category or charge is missing, so consider surfacing that.
Acceptance criteria
- A 0% category with records appears in the depreciation report for the relevant year, with correct cost and net value.
- No
NaN/Infinityin any returned field. - Unit tests for
calculateDepreciationwith rate 0 (activated this year, in a past year, with and without an end date), and a resolver-level test with a 0% category. - Non-zero categories are unchanged.
Generated by Claude Code
- Ngôn ngữ chính
- TypeScript
- Star
- 30
- Fork
- 10
- Merge trung bình
- 2 ngày 12 giờ
- Pull request đã merge (30 ngày)
- 276
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Urigo/accounter-fullstack
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
Urigo/accounter-fullstack#5302 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
1214 annual-audit-workflow
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Urigo/accounter-fullstack#5257 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
1214 annual-audit-workflow
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Urigo/accounter-fullstack#5256 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
annual-audit-workflow
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 87/100
Urigo/accounter-fullstack#5252 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Urigo/accounter-fullstack#4919 ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của Urigo/accounter-fullstack
Issue tương tự
-
area: integrations documentation priority: P2 size: XS
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
eddiejaoude/StackDash#798 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bot:ai-assisted component:midnight-js status:untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
midnightntwrk/midnight-js#1790 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:vscode bug has repro platform:macos platform:vscode regression
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
anthropics/claude-code#113502 ·
-
Add: Rajdhani TV HDĐang mởcheck:passed streams:add
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày