-
Notifications
You must be signed in to change notification settings - Fork 27
feat: add income tax calculation guide with navigation integration #439
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Create new guide page explaining IR calculation on fixed income investments (CDB, LCI/LCA, savings) - Add 4 practical examples with real numbers showing IR, IOF, and net yield comparisons - Include official sources: Receita Federal, Planalto, Banco Central, CVM - Fix IOF percentage function to safely handle edge cases (days < 1)
📝 WalkthroughWalkthroughThe PR adds a new Portuguese Income Tax Calculation Guide page, inserts a navigation link to it, updates the savings page to reference the guide, and tightens input validation and defensive lookup logic for IOF in the finance utility. Changes
Sequence Diagram(s)(omitted — changes are UI/content additions and a small utility validation tweak; no multi-component control flow needing visualization) Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
✏️ Tip: You can disable this entire section by setting Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🤖 Fix all issues with AI agents
In `@app/pages/como-calcular-imposto-de-renda.vue`:
- Around line 78-81: The comparative note in the paragraph that begins with
"<em>Observe:</em>" must be updated to reflect the corrected IOF calculation and
the resulting (correct) lower net gain; locate that paragraph in
como-calcular-imposto-de-renda.vue (the block containing "<em>Observe:</em> O
resgate antecipado (dia 15)...") and replace the phrasing "O resgate antecipado
(dia 15) resultou em um ganho líquido de apenas R$ 34,87 contra R$ 465,00 no
exemplo anterior." with the corrected net-gain value and comparative text that
matches the fixed IOF calculation so the note accurately states the new lower
net gain.
- Around line 70-77: The IOF percentage used in the example on the
como-calcular-imposto-de-renda.vue page is wrong: use the IOF value from the IOF
table in finance.ts (day 15 → index 14 → 50%), update the narrative and computed
numbers accordingly (IOF: 50% × R$75 = R$37.50; rendimento após IOF: R$75 −
R$37.50 = R$37.50; IR (22.5%): 22.5% × R$37.50 = R$8.44 (rounded); rendimento
líquido: R$37.50 − R$8.44 = R$29.06; saldo final: R$10,000 + R$29.06 =
R$10,029.06), and ensure rounding style matches other examples; reference the
IOF array in finance.ts and the list block in the
como-calcular-imposto-de-renda.vue component to make the edits.
📜 Review details
Configuration used: defaults
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
app/components/NavigationBar.vueapp/pages/como-calcular-imposto-de-renda.vueapp/pages/como-calcular-juros-da-poupanca.vueapp/src/finance.ts
🧰 Additional context used
📓 Path-based instructions (6)
{app/src/**/*.ts,app/components/**/*.{ts,tsx,vue}}
📄 CodeRabbit inference engine (AGENTS.md)
{app/src/**/*.ts,app/components/**/*.{ts,tsx,vue}}: IR (Income Tax) calculation depends on investment days: ≤180 days = 22.5%, 181-360 = 20%, 361-720 = 17.5%, >720 = 15%
Always check for null values in investment index properties (e.g., investment.di, investment.poupanca, investment.selic) before calculations
Files:
app/src/finance.tsapp/components/NavigationBar.vue
{app/src/**/*.ts,app/components/**/*.{ts,tsx,vue},test/unit/src/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
{app/src/**/*.ts,app/components/**/*.{ts,tsx,vue},test/unit/src/**/*.ts}: IOF (Insurance Operations Tax) lookup table applies only if redemption < 30 days, using table in finance.ts:22-25 (96% down to 0% across 30 days)
All currency calculations use.toFixed(2)beforeNumber.parseFloat()to prevent floating-point errors in tax/interest math
Final IOF calculation formula: finalReturn = amount + interest - IOF - (interest - IOF) × IR%
Files:
app/src/finance.tsapp/components/NavigationBar.vue
{app/src/**/*.ts,app/components/**/*.vue,test/unit/src/**/*.ts}
📄 CodeRabbit inference engine (AGENTS.md)
Period conversion must use exact multipliers: Days = 1, Months = 365/12 (not 30), Years = 365 (not 360) — matches BCB official practices
Files:
app/src/finance.tsapp/components/NavigationBar.vue
**/*.{ts,tsx,vue}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx,vue}: TypeScript strict mode is enabled in tsconfig.json — prefer explicit types overany
Use ~/ alias for imports pointing to the app/ directory throughout the codebase
Files:
app/src/finance.tsapp/pages/como-calcular-imposto-de-renda.vueapp/pages/como-calcular-juros-da-poupanca.vueapp/components/NavigationBar.vue
{app/src/**/*.ts,app/store/**/*.ts,app/components/**/*.{ts,tsx,vue}}
📄 CodeRabbit inference engine (AGENTS.md)
Do NOT hardcode BCB index values in code; always fetch via
update-indexes.mjswhich updates indicadores.json with BCB API data
Files:
app/src/finance.tsapp/components/NavigationBar.vue
app/components/**/*.vue
📄 CodeRabbit inference engine (AGENTS.md)
Computed properties in Vue components should auto-recalculate when Pinia store state updates
Files:
app/components/NavigationBar.vue
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/**/*.ts,app/components/**/*.{ts,tsx,vue}} : IR (Income Tax) calculation depends on investment days: ≤180 days = 22.5%, 181-360 = 20%, 361-720 = 17.5%, >720 = 15%
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to test/unit/src/finance.spec.ts : Tax tables (IR brackets, IOF lookup) are critical and must have comprehensive tests covering day boundaries (days 1, 30, 31) and edge cases
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/lcx.ts,test/unit/src/**/*.ts} : LCI/LCA investments are tax-exempt (no IR/IOF) in lcx.ts module
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/**/*.ts,app/components/**/*.{ts,tsx,vue},test/unit/src/**/*.ts} : IOF (Insurance Operations Tax) lookup table applies only if redemption < 30 days, using table in finance.ts:22-25 (96% down to 0% across 30 days)
Applied to files:
app/src/finance.tsapp/pages/como-calcular-imposto-de-renda.vue
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/**/*.ts,app/components/**/*.{ts,tsx,vue},test/unit/src/**/*.ts} : Final IOF calculation formula: finalReturn = amount + interest - IOF - (interest - IOF) × IR%
Applied to files:
app/src/finance.tsapp/pages/como-calcular-imposto-de-renda.vue
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to test/unit/src/finance.spec.ts : Tax tables (IR brackets, IOF lookup) are critical and must have comprehensive tests covering day boundaries (days 1, 30, 31) and edge cases
Applied to files:
app/src/finance.ts
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/**/*.ts,app/components/**/*.{ts,tsx,vue}} : IR (Income Tax) calculation depends on investment days: ≤180 days = 22.5%, 181-360 = 20%, 361-720 = 17.5%, >720 = 15%
Applied to files:
app/src/finance.tsapp/pages/como-calcular-imposto-de-renda.vue
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/**/*.ts,app/components/**/*.{ts,tsx,vue}} : Always check for null values in investment index properties (e.g., investment.di, investment.poupanca, investment.selic) before calculations
Applied to files:
app/src/finance.tsapp/pages/como-calcular-imposto-de-renda.vue
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to test/unit/src/**/*.ts : Test compound interest calculations using real BCB index values (e.g., 1.0003105377556554) rather than round numbers
Applied to files:
app/src/finance.ts
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/**/{cdb,lcx,poupanca}.ts,test/unit/src/**/*.ts} : Each investment module (cdb.ts, lcx.ts, poupanca.ts) must export `get<Type>Result()` function returning object with { interestAmount, taxAmount, taxPercentage, iofAmount }
Applied to files:
app/src/finance.tsapp/pages/como-calcular-imposto-de-renda.vue
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/**/*.ts,app/components/**/*.{ts,tsx,vue},test/unit/src/**/*.ts} : All currency calculations use `.toFixed(2)` before `Number.parseFloat()` to prevent floating-point errors in tax/interest math
Applied to files:
app/src/finance.ts
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/**/*.ts,app/components/**/*.vue,test/unit/src/**/*.ts} : Period conversion must use exact multipliers: Days = 1, Months = 365/12 (not 30), Years = 365 (not 360) — matches BCB official practices
Applied to files:
app/src/finance.ts
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to app/store/investment.ts : Pinia store uses Portuguese enum names (PeriodTypes.Dias, meses, anos) internally
Applied to files:
app/src/finance.ts
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Main calculation orchestration happens in InvestmentSimulation.vue (lines 46-58); all investment type calculations should flow through this component
Applied to files:
app/pages/como-calcular-imposto-de-renda.vue
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/lcx.ts,test/unit/src/**/*.ts} : LCI/LCA investments are tax-exempt (no IR/IOF) in lcx.ts module
Applied to files:
app/pages/como-calcular-imposto-de-renda.vue
📚 Learning: 2026-01-15T19:58:57.917Z
Learnt from: CR
Repo: rendafixa/rendafixa.github.io PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-15T19:58:57.917Z
Learning: Applies to {app/src/poupanca.ts,test/unit/src/**/*.ts} : Savings accounts use simple monthly rates, not compound interest calculations like CDB/RDB
Applied to files:
app/pages/como-calcular-imposto-de-renda.vueapp/pages/como-calcular-juros-da-poupanca.vue
🔇 Additional comments (5)
app/components/NavigationBar.vue (1)
105-122: LGTM!The new navigation link follows the established pattern with consistent styling, proper accessibility via
aria-label, and the inline SVG icon matches the existing navigation items' structure.app/pages/como-calcular-juros-da-poupanca.vue (1)
52-58: LGTM!The new "Impostos na Poupança" section correctly explains that savings accounts are tax-exempt and provides a helpful cross-link to the IR guide. The placement and styling are appropriate.
app/pages/como-calcular-imposto-de-renda.vue (2)
1-51: Well-structured educational content.The page follows good practices:
- Proper heading hierarchy (h2 → h3 → h4)
- Semantic HTML structure
- External links with
rel="noopener noreferrer"for security- IR brackets documented correctly match the
getIndexIR()implementation infinance.ts
201-206: LGTM!SEO metadata is properly configured using Nuxt's
useSeoMetacomposable with an appropriate title and description for the page content.app/src/finance.ts (1)
27-33: Good defensive improvement for bounds checking.The validation change correctly handles edge cases where
daysToRedeemcould be 0, negative, or greater than 30. The nullish coalescing fallback (?? 0) adds an extra layer of safety. The index calculation (day 1-30 mapping to array indices 0-29) is correct, and callers always pass integer values viaMath.floor()in the duration calculation.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
|



Summary
This PR adds a comprehensive educational guide for calculating income tax on fixed-income investments in Brazil, with full integration into the application's navigation and related content.
Changes
New Page:
app/pages/como-calcular-imposto-de-renda.vue(210 lines)Bug Fix:
app/src/finance.tsgetIOFPercentage()functionif (daysToRedeem >= 1 && daysToRedeem <= 30)const pct = iofTable[index] ?? 0Navigation:
app/components/NavigationBar.vueCross-linking:
app/pages/como-calcular-juros-da-poupanca.vueTesting
Technical Details
Related Issues
Resolves educational guide for users to understand tax implications of fixed-income investments.
Summary by CodeRabbit
New Features
Documentation
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.