Skip to content

Commit

Permalink
2023 update consts (#813)
Browse files Browse the repository at this point in the history
* update consts

* remove 2022 specific stuff

* delete old child calcs

* remove income filter date

* skip old children tests

* fix unit tests and typescript compile

* update cypress tests

* update outputJson type based on xsd

* update base json

* update tax form for 2023

* update obvious errors
  • Loading branch information
MarekVigas authored Dec 31, 2023
1 parent 35e57bb commit 641b08f
Show file tree
Hide file tree
Showing 61 changed files with 19,938 additions and 17,628 deletions.
290 changes: 144 additions & 146 deletions __tests__/calculation.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import {
calculate,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
MIN_PRIJEM_NA_DANOVY_BONUS_NA_DIETA,
} from '../src/lib/calculation'
import { parseInputNumber } from '../src/lib/utils'
import { TaxFormUserInput } from '../src/types/TaxFormUserInput'
import { initTaxFormUserInputValues } from '../src/lib/initialValues'
import { sum } from '../src/lib/utils'
// import { sum } from '../src/lib/utils'

describe('#parse', () => {
const inputs = [
Expand Down Expand Up @@ -59,10 +56,10 @@ const child = {
}

/** The numbers need to be updated every year, for example 150701 => 160701 */
const childUnder6 = { ...child, rodneCislo: '200501 / 9753' }
const childTurning6InFeb = { ...child, rodneCislo: '160215 / 0011' }
const childTurning6InJul = { ...child, rodneCislo: '160731 / 0012' }
const childOver6 = { ...child, rodneCislo: '100101 / 1234' }
// const childUnder6 = { ...child, rodneCislo: '200501 / 9753' }
// const childTurning6InFeb = { ...child, rodneCislo: '160215 / 0011' }
// const childTurning6InJul = { ...child, rodneCislo: '160731 / 0012' }
// const childOver6 = { ...child, rodneCislo: '100101 / 1234' }

describe('With child (for tax year 2022)', () => {
test('should map child', () => {
Expand Down Expand Up @@ -113,156 +110,157 @@ describe('With child (for tax year 2022)', () => {
expect(result.r034[0].m12).toBe(false)
})

describe('children tax bonus (r117)', () => {
test('Child under 6', () => {
const result = calculate({
...initTaxFormUserInputValues,
hasChildren: true,
children: [childUnder6],
t1r10_prijmy: MIN_PRIJEM_NA_DANOVY_BONUS_NA_DIETA.toString(),
})
const monthSums = sum(
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
) // kazdy mesiac ked vek < 6 rokov
// TODO 2023
describe.skip('children tax bonus (r117)', () => {
// test('Child under 6', () => {
// const result = calculate({
// ...initTaxFormUserInputValues,
// hasChildren: true,
// children: [childUnder6],
// t1r10_prijmy: MIN_PRIJEM_NA_DANOVY_BONUS_NA_DIETA.toString(),
// })
// const monthSums = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// ) // kazdy mesiac ked vek < 6 rokov

expect(result.r117a).toEqual(monthSums)
})
// expect(result.r117a).toEqual(monthSums)
// })

test('Child turning 6 in 2022 (february)', () => {
const result = calculate({
...initTaxFormUserInputValues,
hasChildren: true,
children: [childTurning6InFeb],
t1r10_prijmy: MIN_PRIJEM_NA_DANOVY_BONUS_NA_DIETA.toString(),
})
// test('Child turning 6 in 2022 (february)', () => {
// const result = calculate({
// ...initTaxFormUserInputValues,
// hasChildren: true,
// children: [childTurning6InFeb],
// t1r10_prijmy: MIN_PRIJEM_NA_DANOVY_BONUS_NA_DIETA.toString(),
// })

const monthSums = sum(
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
)
// const monthSums = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// )

expect(result.r117a).toEqual(monthSums)
})
// expect(result.r117a).toEqual(monthSums)
// })

test('Child turning 6 in 2022 (july)', () => {
const result = calculate({
...initTaxFormUserInputValues,
hasChildren: true,
children: [childTurning6InJul],
t1r10_prijmy: MIN_PRIJEM_NA_DANOVY_BONUS_NA_DIETA.toString(),
})
// test('Child turning 6 in 2022 (july)', () => {
// const result = calculate({
// ...initTaxFormUserInputValues,
// hasChildren: true,
// children: [childTurning6InJul],
// t1r10_prijmy: MIN_PRIJEM_NA_DANOVY_BONUS_NA_DIETA.toString(),
// })

const part1 = sum(
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
) // februar - jul (vek do 6 rokov vratane mesiaca dovrsenia) ale jul uz patri do druhej polovice roka
expect(result.r117a).toEqual(part1)
})
// const part1 = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// ) // februar - jul (vek do 6 rokov vratane mesiaca dovrsenia) ale jul uz patri do druhej polovice roka
// expect(result.r117a).toEqual(part1)
// })

test('Child over 6', () => {
const result = calculate({
...initTaxFormUserInputValues,
hasChildren: true,
children: [childOver6],
t1r10_prijmy: (15_000).toString(),
})
// test('Child over 6', () => {
// const result = calculate({
// ...initTaxFormUserInputValues,
// hasChildren: true,
// children: [childOver6],
// t1r10_prijmy: (15_000).toString(),
// })

const monthSums = sum(
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
) // vek nad 6 rokov vratane mesiaca dovrsenia
expect(result.r117).toEqual(monthSums)
})
// const monthSums = sum(
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// ) // vek nad 6 rokov vratane mesiaca dovrsenia
// expect(result.r117).toEqual(monthSums)
// })

test('More children', () => {
const result = calculate({
...initTaxFormUserInputValues,
hasChildren: true,
children: [
{ ...childOver6 },
{ ...childTurning6InFeb },
{ ...childTurning6InJul },
{ ...childUnder6 },
],
t1r10_prijmy: (25_000).toString(),
})
// test('More children', () => {
// const result = calculate({
// ...initTaxFormUserInputValues,
// hasChildren: true,
// children: [
// { ...childOver6 },
// { ...childTurning6InFeb },
// { ...childTurning6InJul },
// { ...childUnder6 },
// ],
// t1r10_prijmy: (25_000).toString(),
// })

// childOver6
const childOver6Sum = sum(
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
)
// // childOver6
// const childOver6Sum = sum(
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// )

// childTurning6InFeb
const childTurning6InFebSum = sum(
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_OVER_SIX_UNTIL_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
)
// // childTurning6InFeb
// const childTurning6InFebSum = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_OVER_SIX_UNTIL_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// )

// childTurning6InJul
const childTurning6InJulSum = sum(
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
) // januar - jul (vek do 6 rokov vratane mesiaca dovrsenia)
// // childTurning6InJul
// const childTurning6InJulSum = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// ) // januar - jul (vek do 6 rokov vratane mesiaca dovrsenia)

// childUnder6
const childUnder6Sum = sum(
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
)
expect(result.r117).toEqual(
sum(
childOver6Sum,
childTurning6InFebSum,
childTurning6InJulSum,
childUnder6Sum,
),
)
})
// // childUnder6
// const childUnder6Sum = sum(
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY,
// )
// expect(result.r117).toEqual(
// sum(
// childOver6Sum,
// childTurning6InFebSum,
// childTurning6InJulSum,
// childUnder6Sum,
// ),
// )
// })
})
})
4 changes: 0 additions & 4 deletions __tests__/testCases/baseInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export const baseInput: E2eTestUserInput = {
datum: '22.02.2022',
hasChildren: false,
children: [],
prijmyPredJul22: true,
zaciatokPrijmovDen: null,
zaciatokPrijmovMesiac: null,
zaciatokPrijmovRok: null,
expectNgoDonationValue: true,

percent2: '10,26',
Expand Down
4 changes: 0 additions & 4 deletions __tests__/testCases/bugReport1Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ export const bugReport1Input: E2eTestUserInput = {
uhrnPovinnehoPoistnehoNaSocialnePoistenie: '400',
uhrnPovinnehoPoistnehoNaZdravotnePoistenie: '35,22',
hasChildren: true,
prijmyPredJul22: true,
zaciatokPrijmovDen: null,
zaciatokPrijmovMesiac: null,
zaciatokPrijmovRok: null,
children: [
{
id: 1,
Expand Down
4 changes: 0 additions & 4 deletions __tests__/testCases/bugReport2aInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export const bugReport2aInput: E2eTestUserInput = {
udajeODanovomBonuseNaDieta: '22.17',
uhrnPreddavkovNaDan: '124,35',
hasChildren: true,
prijmyPredJul22: true,
zaciatokPrijmovDen: null,
zaciatokPrijmovMesiac: null,
zaciatokPrijmovRok: null,
children: [
{
id: 1,
Expand Down
4 changes: 0 additions & 4 deletions __tests__/testCases/bugReport2bInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ export const bugReport2bInput: E2eTestUserInput = {
udajeODanovomBonuseNaDieta: '0',
uhrnPreddavkovNaDan: '0',
hasChildren: false,
prijmyPredJul22: true,
zaciatokPrijmovDen: null,
zaciatokPrijmovMesiac: null,
zaciatokPrijmovRok: null,
children: [],
platil_prispevky_na_dochodok: false,
zaplatene_prispevky_na_dochodok: '0',
Expand Down
4 changes: 0 additions & 4 deletions __tests__/testCases/bugReport3Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ export const bugReport3Input: E2eTestUserInput = {
udajeODanovomBonuseNaDieta: '0',
uhrnPreddavkovNaDan: '10',
hasChildren: true,
prijmyPredJul22: true,
zaciatokPrijmovDen: null,
zaciatokPrijmovMesiac: null,
zaciatokPrijmovRok: null,
children: [
{
id: 1,
Expand Down
4 changes: 0 additions & 4 deletions __tests__/testCases/bugReport4Input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,5 @@ export const bugReport4Input: E2eTestUserInput = {
t1r10_prijmy: '20000',
datum: '22.02.2020',
hasChildren: false,
prijmyPredJul22: true,
zaciatokPrijmovDen: null,
zaciatokPrijmovMesiac: null,
zaciatokPrijmovRok: null,
children: [],
}
Loading

0 comments on commit 641b08f

Please sign in to comment.