Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/update-indexes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Checking for changes
id: check_changes
run: |
if git diff --exit-code assets/indicadores.json; then
if git diff --exit-code app/assets/indicadores.json; then
echo "has_changes=false" >> $GITHUB_ENV
else
echo "has_changes=true" >> $GITHUB_ENV
Expand All @@ -37,7 +37,7 @@ jobs:
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add assets/indicadores.json
git add app/assets/indicadores.json
git commit -m "Updated indicadores.json on $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
git push
env:
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export default defineNuxtConfig({
transpile: ['vuetify'],
},

future: {
compatibilityVersion: 4,
},

modules: [
'@pinia/nuxt',
'nuxt-schema-org',
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
"@nuxt/test-utils": "^3.19.2",
"@vitejs/plugin-vue": "^6.0.1",
"jsdom": "^26.1.0",
"nuxt": "^3.19.2",
"nuxt": "^4.1.2",
"vite-plugin-vuetify": "^2.1.2",
"vitest": "^3.2.4",
"vuetify": "^3.10.4"
},
"dependencies": {
"@mdi/font": "^7.4.47",
"@pinia/nuxt": "^0.10.1",
"@pinia/nuxt": "^0.11.2",
"axios": "^1.12.2",
"nuxt-schema-org": "^5.0.9"
"nuxt-schema-org": "^5.0.9",
"pinia": "^3.0.3"
},
"pnpm": {
"onlyBuiltDependencies": [
Expand Down
83 changes: 29 additions & 54 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

85 changes: 85 additions & 0 deletions test/app/src/cdb.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import { describe, it, expect } from 'vitest'
import { getCDBResult } from '../../../app/src/cdb'
import { getIndexIR, getIOFAmount, getIOFPercentage } from '../../../app/src/finance'

// Helper to compute expected values independently (mirrors financial math)
function expectedCDB(amount: number, di: number, yearlyIndex: number, days: number) {
const yearlyRate = yearlyIndex / 100 // convert to decimal
const dailyFactor = Math.pow((yearlyRate * di) / 100 + 1, 1 / 365)
const rawInterest = amount * Math.pow(dailyFactor, days) - amount
const interestAmount = parseFloat(rawInterest.toFixed(2))
const taxPercentage = getIndexIR(days)
const iofAmount = getIOFAmount(days, interestAmount)
const taxAmount = (interestAmount - iofAmount) * (taxPercentage / 100)
return { interestAmount, taxAmount, taxPercentage, iofAmount }
}

describe('getCDBResult - tax percentage tiers', () => {
const tierCases = [
{ days: 30, expected: 22.5 },
{ days: 181, expected: 20 },
{ days: 400, expected: 17.5 },
{ days: 900, expected: 15 }
]

for (const { days, expected } of tierCases) {
it(`returns taxPercentage ${expected} for ${days} days`, () => {
const result = getCDBResult(1000, 100, 13.15, days)
expect(result.taxPercentage).toBe(expected)
})
}
})

describe('getCDBResult - IOF impact (early redemption)', () => {
it('applies IOF correctly for redemption within 10 days', () => {
const amount = 1000
const di = 110 // 110% of CDI
const yearlyIndex = 13.15
const days = 10

const result = getCDBResult(amount, di, yearlyIndex, days)
const expected = expectedCDB(amount, di, yearlyIndex, days)

expect(getIOFPercentage(days)).toBeGreaterThan(0) // sanity check IOF applies
expect(result.interestAmount).toBe(expected.interestAmount)
expect(result.taxPercentage).toBe(expected.taxPercentage)
expect(result.iofAmount).toBeCloseTo(expected.iofAmount, 6)
expect(result.taxAmount).toBeCloseTo(expected.taxAmount, 6)
})
})

describe('getCDBResult - no IOF after 35 days', () => {
it('does not apply IOF and calculates taxes correctly', () => {
const amount = 1000
const di = 100
const yearlyIndex = 13.15
const days = 200

const result = getCDBResult(amount, di, yearlyIndex, days)
const expected = expectedCDB(amount, di, yearlyIndex, days)

expect(getIOFPercentage(days)).toBe(0)
expect(result.iofAmount).toBe(0)
expect(result.interestAmount).toBe(expected.interestAmount)
expect(result.taxPercentage).toBe(expected.taxPercentage)
expect(result.taxAmount).toBeCloseTo(expected.taxAmount, 6)
})
})

describe('getCDBResult - long term lowest tax bracket', () => {
it('applies 15% tax after more than 720 days', () => {
const amount = 1000
const di = 95
const yearlyIndex = 13.15
const days = 800

const result = getCDBResult(amount, di, yearlyIndex, days)
const expected = expectedCDB(amount, di, yearlyIndex, days)

expect(result.taxPercentage).toBe(15)
expect(result.iofAmount).toBe(0)
expect(result.interestAmount).toBe(expected.interestAmount)
expect(result.taxAmount).toBeCloseTo(expected.taxAmount, 6)
})
})

2 changes: 1 addition & 1 deletion test/src/finance.spec.ts → test/app/src/finance.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { compoundInterest, getIndexIR, getIOFAmount, getIOFPercentage } from '../../src/finance'
import { compoundInterest, getIndexIR, getIOFAmount, getIOFPercentage } from '../../../app/src/finance'

describe('getIndexIR function', () => {
const testCases = [
Expand Down
Loading