diff --git a/__tests__/dohoda.test.ts b/__tests__/dohoda.test.ts new file mode 100644 index 00000000..6e70054e --- /dev/null +++ b/__tests__/dohoda.test.ts @@ -0,0 +1,54 @@ +import { validate } from '../src/pages/dohoda' +import { testValidation } from './utils/testValidation' + +describe('dohoda', () => { + describe('#validate', () => { + testValidation(validate, [ + { + input: { dohoda: undefined }, + expected: ['dohoda'], + }, + { input: { dohoda: false }, expected: [] }, + { + input: { dohoda: true }, + expected: [ + 'uhrnPrijmovZoVsetkychDohod', + 'uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', + 'uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', + 'uhrnPreddavkovNaDanDohody', + 'udajeODanovomBonuseNaDietaDohody', + ], + }, + { + input: { + dohoda: true, + r029_poberal_dochodok: true, + uhrnPrijmovZoVsetkychDohod: 'a', + uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '-1', + uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '-1', + udajeODanovomBonuseNaDietaDohody: 'a', + uhrnPreddavkovNaDanDohody: '-1', + }, + expected: [ + 'uhrnPrijmovZoVsetkychDohod', + 'uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', + 'uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', + 'uhrnPreddavkovNaDanDohody', + 'udajeODanovomBonuseNaDietaDohody', + ], + }, + { + input: { + dohoda: true, + r029_poberal_dochodok: true, + uhrnPrijmovZoVsetkychDohod: '10', + uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '20', + uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '20', + udajeODanovomBonuseNaDietaDohody: '30', + uhrnPreddavkovNaDanDohody: '40', + }, + expected: [], + }, + ]) + }) +}) diff --git a/__tests__/routes.test.ts b/__tests__/routes.test.ts index 2898ab84..3b6997d1 100644 --- a/__tests__/routes.test.ts +++ b/__tests__/routes.test.ts @@ -15,6 +15,7 @@ describe('routes', () => { homeRoute, '/prijmy-a-vydavky', '/zamestnanie', + '/dohoda', '/partner', '/deti', '/dochodok', @@ -33,6 +34,7 @@ describe('routes', () => { homeRoute, '/prijmy-a-vydavky', '/zamestnanie', + '/dohoda', '/partner', '/deti', '/dochodok', @@ -55,6 +57,7 @@ describe('routes', () => { homeRoute, '/prijmy-a-vydavky', '/zamestnanie', + '/dohoda', '/partner', '/deti', '/dochodok', @@ -78,6 +81,7 @@ describe('routes', () => { homeRoute, '/prijmy-a-vydavky', '/zamestnanie', + '/dohoda', '/partner', '/deti', '/dochodok', @@ -170,7 +174,7 @@ describe('routes', () => { it('should not redirect from route when form is filled out', () => { validateRoute( - { route: '/partner', replace } as any, + { route: '/dohoda', replace } as any, {} as TaxForm, { employed: false } as TaxFormUserInput, {} as PostponeUserInput, diff --git a/__tests__/testCases/case202201Input.ts b/__tests__/testCases/case202201Input.ts index 9c838a82..65abef2e 100644 --- a/__tests__/testCases/case202201Input.ts +++ b/__tests__/testCases/case202201Input.ts @@ -26,6 +26,14 @@ export const case202201Input: E2eTestUserInput = { udajeODanovomBonuseNaDieta: '1084.26', employed: true, + /** SECTION Dohoda */ + uhrnPrijmovZoVsetkychDohod: '4420', + uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '850.60', + uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '230', + uhrnPreddavkovNaDanDohody: '0', + udajeODanovomBonuseNaDietaDohody: '0', + dohoda: true, + /** SECTION Pension */ platil_prispevky_na_dochodok: false, zaplatene_prispevky_na_dochodok: '0', diff --git a/__tests__/testCases/case202202aInput.ts b/__tests__/testCases/case202202aInput.ts index 47d4aba9..6de65f22 100644 --- a/__tests__/testCases/case202202aInput.ts +++ b/__tests__/testCases/case202202aInput.ts @@ -26,6 +26,14 @@ export const case202202aInput: E2eTestUserInput = { udajeODanovomBonuseNaDieta: '0', employed: false, + /** SECTION Dohoda */ + uhrnPrijmovZoVsetkychDohod: '5500', + uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '1200', + uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '330', + uhrnPreddavkovNaDanDohody: '120', + udajeODanovomBonuseNaDietaDohody: '100', + dohoda: true, + /** SECTION Pension */ platil_prispevky_na_dochodok: false, zaplatene_prispevky_na_dochodok: '0', @@ -62,6 +70,6 @@ export const case202202aInput: E2eTestUserInput = { expectNgoDonationValue: true, - percent2: '173,62', + percent2: '193,88', percent3: '320,78', } diff --git a/__tests__/testCases/case202202bInput.ts b/__tests__/testCases/case202202bInput.ts index 1ebbbcc1..8c924e83 100644 --- a/__tests__/testCases/case202202bInput.ts +++ b/__tests__/testCases/case202202bInput.ts @@ -26,6 +26,14 @@ export const case202202bInput: E2eTestUserInput = { udajeODanovomBonuseNaDieta: '0', employed: false, + /** SECTION Dohoda */ + uhrnPrijmovZoVsetkychDohod: '5500', + uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '1200', + uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '330', + uhrnPreddavkovNaDanDohody: '120', + udajeODanovomBonuseNaDietaDohody: '100', + dohoda: true, + /** SECTION Pension */ platil_prispevky_na_dochodok: false, zaplatene_prispevky_na_dochodok: '0', @@ -63,6 +71,6 @@ export const case202202bInput: E2eTestUserInput = { expectNgoDonationValue: true, /** SECTION Two Percent */ - percent2: '178,62', + percent2: '194,53', percent3: '321,72', } diff --git a/__tests__/testCases/case202202cInput.ts b/__tests__/testCases/case202202cInput.ts index 685ece9a..cc7c621c 100644 --- a/__tests__/testCases/case202202cInput.ts +++ b/__tests__/testCases/case202202cInput.ts @@ -26,6 +26,14 @@ export const case202202cInput: E2eTestUserInput = { udajeODanovomBonuseNaDieta: '0', employed: false, + /** SECTION Dohoda */ + uhrnPrijmovZoVsetkychDohod: '0', + uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '0', + uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '0', + uhrnPreddavkovNaDanDohody: '0', + udajeODanovomBonuseNaDietaDohody: '0', + dohoda: false, + /** SECTION Pension */ platil_prispevky_na_dochodok: false, zaplatene_prispevky_na_dochodok: '0', diff --git a/__tests__/testCases/case202301Input.ts b/__tests__/testCases/case202301Input.ts index 6833a037..66ac696e 100644 --- a/__tests__/testCases/case202301Input.ts +++ b/__tests__/testCases/case202301Input.ts @@ -25,6 +25,7 @@ export const case202301Input: E2eTestUserInput = { uhrnPreddavkovNaDan: '0', udajeODanovomBonuseNaDieta: '0', employed: false, + dohoda: false, /** SECTION Pension */ platil_prispevky_na_dochodok: false, diff --git a/__tests__/testCases/case202302Input.ts b/__tests__/testCases/case202302Input.ts index e4a0fc66..097d0ac4 100644 --- a/__tests__/testCases/case202302Input.ts +++ b/__tests__/testCases/case202302Input.ts @@ -25,6 +25,7 @@ export const case202302Input: E2eTestUserInput = { uhrnPreddavkovNaDan: '446.76', udajeODanovomBonuseNaDieta: '0', employed: true, + dohoda: false, /** SECTION Pension */ platil_prispevky_na_dochodok: false, diff --git a/__tests__/testCases/case202303Input.ts b/__tests__/testCases/case202303Input.ts index e2eb54dd..cd6cb2b5 100644 --- a/__tests__/testCases/case202303Input.ts +++ b/__tests__/testCases/case202303Input.ts @@ -25,6 +25,7 @@ export const case202303Input: E2eTestUserInput = { uhrnPreddavkovNaDan: '1434', udajeODanovomBonuseNaDieta: '0', employed: true, + dohoda: false, /** SECTION Pension */ platil_prispevky_na_dochodok: false, diff --git a/__tests__/testCases/prenajom202303Input.ts b/__tests__/testCases/prenajom202303Input.ts index 756848a0..a4c644fc 100644 --- a/__tests__/testCases/prenajom202303Input.ts +++ b/__tests__/testCases/prenajom202303Input.ts @@ -10,4 +10,5 @@ export const prenajom202303Input: E2eTestUserInput = { vydavkyZPrenajmu: '4325', prenajomPrijemZPrilezitostnejCinnosti: true, vyskaOslobodenia: '350', + dohoda: false, } diff --git a/__tests__/testCases/prenajom202304Input.ts b/__tests__/testCases/prenajom202304Input.ts index 330722b8..a5001cdc 100644 --- a/__tests__/testCases/prenajom202304Input.ts +++ b/__tests__/testCases/prenajom202304Input.ts @@ -9,4 +9,5 @@ export const prenajom202304Input: E2eTestUserInput = { prenajomPrijemZPrilezitostnejCinnosti: false, expectNgoDonationValue: true, percent2: '7,57', + dohoda: false, } diff --git a/cypress/e2e/executeCase.ts b/cypress/e2e/executeCase.ts index d7fce103..e6ac0255 100644 --- a/cypress/e2e/executeCase.ts +++ b/cypress/e2e/executeCase.ts @@ -99,6 +99,22 @@ const executeTestCase = (testCase: string) => { next() + /** SECTION Dohoda */ + assertUrl('/dohoda') + + if (input.dohoda) { + getInput('dohoda', '-yes').click() + typeToInput('uhrnPrijmovZoVsetkychDohod', input) + typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input) + typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input) + typeToInput('uhrnPreddavkovNaDanDohody', input) + typeToInput('udajeODanovomBonuseNaDietaDohody', input) + } else { + getInput('dohoda', '-no').click() + } + + next() + /** SECTION Partner */ assertUrl('/partner') diff --git a/cypress/e2e/pagePercent.spec.ts b/cypress/e2e/pagePercent.spec.ts index 3c21f97e..71b46ad1 100644 --- a/cypress/e2e/pagePercent.spec.ts +++ b/cypress/e2e/pagePercent.spec.ts @@ -69,6 +69,22 @@ describe('twoPercent page', () => { next() + /** SECTION Dohoda */ + assertUrl('/dohoda') + + if (input.dohoda) { + getInput('dohoda', '-yes').click() + typeToInput('uhrnPrijmovZoVsetkychDohod', input) + typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input) + typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input) + typeToInput('uhrnPreddavkovNaDanDohody', input) + typeToInput('udajeODanovomBonuseNaDietaDohody', input) + } else { + getInput('dohoda', '-no').click() + } + + next() + /** SECTION Partner */ if (input.r032_uplatnujem_na_partnera) { getInput('r032_uplatnujem_na_partnera', '-yes').click() @@ -253,6 +269,22 @@ describe('twoPercent page', () => { next() + /** SECTION Dohoda */ + assertUrl('/dohoda') + + if (input.dohoda) { + getInput('dohoda', '-yes').click() + typeToInput('uhrnPrijmovZoVsetkychDohod', input) + typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input) + typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input) + typeToInput('uhrnPreddavkovNaDanDohody', input) + typeToInput('udajeODanovomBonuseNaDietaDohody', input) + } else { + getInput('dohoda', '-no').click() + } + + next() + /** SECTION Partner */ if (input.r032_uplatnujem_na_partnera) { getInput('r032_uplatnujem_na_partnera', '-yes').click() @@ -428,6 +460,22 @@ describe('twoPercent page', () => { next() + /** SECTION Dohoda */ + assertUrl('/dohoda') + + if (input.dohoda) { + getInput('dohoda', '-yes').click() + typeToInput('uhrnPrijmovZoVsetkychDohod', input) + typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input) + typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input) + typeToInput('uhrnPreddavkovNaDanDohody', input) + typeToInput('udajeODanovomBonuseNaDietaDohody', input) + } else { + getInput('dohoda', '-no').click() + } + + next() + /** SECTION Partner */ if (input.r032_uplatnujem_na_partnera) { getInput('r032_uplatnujem_na_partnera', '-yes').click() @@ -540,6 +588,22 @@ describe('twoPercent page', () => { next() + /** SECTION Dohoda */ + assertUrl('/dohoda') + + if (input.dohoda) { + getInput('dohoda', '-yes').click() + typeToInput('uhrnPrijmovZoVsetkychDohod', input) + typeToInput('uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody', input) + typeToInput('uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody', input) + typeToInput('uhrnPreddavkovNaDanDohody', input) + typeToInput('udajeODanovomBonuseNaDietaDohody', input) + } else { + getInput('dohoda', '-no').click() + } + + next() + /** SECTION Partner */ if (input.r032_uplatnujem_na_partnera) { getInput('r032_uplatnujem_na_partnera', '-yes').click() diff --git a/cypress/e2e/pages.spec.ts b/cypress/e2e/pages.spec.ts index 61047934..b0a24c7e 100644 --- a/cypress/e2e/pages.spec.ts +++ b/cypress/e2e/pages.spec.ts @@ -64,6 +64,9 @@ const navigateEligibleToChildrenPage = () => { assertUrl('/zamestnanie') skipPage() + assertUrl('/dohoda') + skipPage() + assertUrl('/partner') skipPage() } @@ -153,7 +156,7 @@ describe('Employment page', () => { // Should submit and next page should be parter next() - assertUrl('/partner') + assertUrl('/dohoda') }) it('should erase previous answers when answer is changed to "no"', () => { cy.visit('/zamestnanie') @@ -174,7 +177,7 @@ describe('Employment page', () => { next() // go back - assertUrl('/partner') + assertUrl('/dohoda') cy.get('[data-test=back]').click() assertUrl('/zamestnanie') @@ -224,7 +227,7 @@ describe('Employment page', () => { next() // go back - assertUrl('/partner') + assertUrl('/dohoda') cy.get('[data-test=back]').click() assertUrl('/zamestnanie') @@ -249,7 +252,7 @@ describe('Partner page', () => { // Back button should work and be the correct page cy.get('[data-test=back]').click() - assertUrl('/zamestnanie') + assertUrl('/dohoda') // Go back to our page cy.visit('/partner') @@ -471,6 +474,9 @@ describe('Children page', () => { }) next() + assertUrl('/dohoda') + skipPage() + assertUrl('/partner') skipPage() @@ -851,6 +857,9 @@ describe('IBAN page', () => { assertUrl('/partner') skipPage() + assertUrl('/partner') + skipPage() + assertUrl('/deti') getInput('hasChildren', '-yes').click() @@ -946,6 +955,7 @@ describe('Summary page', () => { ;[ '/prijmy-a-vydavky', '/zamestnanie', + '/dohoda', '/partner', '/deti', '/deti', diff --git a/cypress/e2e/random.spec.ts b/cypress/e2e/random.spec.ts index f004d9f3..c6580c70 100644 --- a/cypress/e2e/random.spec.ts +++ b/cypress/e2e/random.spec.ts @@ -1,6 +1,9 @@ import Decimal from 'decimal.js' import { TaxFormUserInput } from '../../src/types/TaxFormUserInput' -import { EmployedUserInput } from '../../src/types/PageUserInputs' +import { + EmployedUserInput, + DohodaUserInput, +} from '../../src/types/PageUserInputs' import { PARTNER_MAX_ODPOCET, TAX_YEAR } from '../../src/lib/calculation' import { formSuccessful } from './executeCase' import { generateBirthId } from '../../src/lib/rodneCisloGenerator' @@ -17,6 +20,7 @@ const randomFromRangeString = (min: number, max: number) => { const randomInput = (): TaxFormUserInput => { const employed = Math.random() > 0.5 + const dohoda = Math.random() > 0.5 const hasChildren = Math.random() > 0.2 const partner = Math.random() > 0.7 const rent = Math.random() > 0.3 @@ -32,6 +36,7 @@ const randomInput = (): TaxFormUserInput => { priloha3_r13_zdravotne: prijmy.times(zdravPercent).toFixed(2), zaplatenePreddavky: randomFromRangeString(0, 100000), employed, + dohoda, hasChildren, children: [], r005_meno: 'Fake', @@ -53,7 +58,7 @@ const randomInput = (): TaxFormUserInput => { 0, 100000, ), - udajeODanovomBonuseNaDieta: randomFromRangeString(0, 100000), + udajeODanovomBonuseNaDieta: randomFromRangeString(0, 1000), uhrnPreddavkovNaDan: randomFromRangeString(0, 100000), } @@ -61,6 +66,24 @@ const randomInput = (): TaxFormUserInput => { input = { ...input, ...zamestnanie } } + const dohody: DohodaUserInput = { + uhrnPrijmovZoVsetkychDohod: randomFromRangeString(0, 100000), + uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: randomFromRangeString( + 0, + 100000, + ), + uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: randomFromRangeString( + 0, + 100000, + ), + udajeODanovomBonuseNaDietaDohody: randomFromRangeString(0, 1000), + uhrnPreddavkovNaDanDohody: randomFromRangeString(0, 100000), + } + + if (dohoda) { + input = { ...input, ...dohody } + } + if (hasChildren) { const childrenCount = randomFromRange(1, 7).round().toNumber() const partnerChildBonus = Math.random() > 0.3 diff --git a/src/lib/calculation.ts b/src/lib/calculation.ts index f50cc0c7..f7348365 100644 --- a/src/lib/calculation.ts +++ b/src/lib/calculation.ts @@ -292,26 +292,45 @@ export function calculate(input: TaxFormUserInput): TaxForm { return this.t1r11s2 }, - /** SECTION Employment */ + /** SECTION Employment a Dohody */ r036: round( new Decimal( parseInputNumber(input?.uhrnPrijmovOdVsetkychZamestnavatelov ?? '0'), + ).plus( + new Decimal(parseInputNumber(input?.uhrnPrijmovZoVsetkychDohod ?? '0')), ), ), + r036a: round( + new Decimal(parseInputNumber(input?.uhrnPrijmovZoVsetkychDohod ?? '0')), + ), r037: round( new Decimal( parseInputNumber( input?.uhrnPovinnehoPoistnehoNaSocialnePoistenie ?? '0', ), - ).plus( - new Decimal( - parseInputNumber( - input?.uhrnPovinnehoPoistnehoNaZdravotnePoistenie ?? '0', + ) + .plus( + new Decimal( + parseInputNumber( + input?.uhrnPovinnehoPoistnehoNaZdravotnePoistenie ?? '0', + ), + ), + ) + .plus( + new Decimal( + parseInputNumber( + input?.uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody ?? '0', + ), + ), + ) + .plus( + new Decimal( + parseInputNumber( + input?.uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody ?? '0', + ), ), ), - ), ), - get vydavkyPoistPar6ods11_ods1a2() { return round(this.priloha3_r11_socialne.plus(this.priloha3_r13_zdravotne)) }, @@ -648,7 +667,13 @@ export function calculate(input: TaxFormUserInput): TaxForm { }, get r119() { return round( - new Decimal(parseInputNumber(input?.udajeODanovomBonuseNaDieta ?? '0')), + new Decimal( + parseInputNumber(input?.udajeODanovomBonuseNaDieta ?? '0'), + ).plus( + new Decimal( + parseInputNumber(input?.udajeODanovomBonuseNaDietaDohody ?? '0'), + ), + ), ) }, get r120() { @@ -715,7 +740,9 @@ export function calculate(input: TaxFormUserInput): TaxForm { r130: new Decimal(0), get r131() { return round( - new Decimal(parseInputNumber(input?.uhrnPreddavkovNaDan ?? '0')), + new Decimal(parseInputNumber(input?.uhrnPreddavkovNaDan ?? '0')).plus( + parseInputNumber(input?.uhrnPreddavkovNaDanDohody ?? '0'), + ), ) }, get r132() { @@ -813,6 +840,7 @@ export function calculate(input: TaxFormUserInput): TaxForm { }, children: input?.hasChildren ?? false, employed: input?.employed ?? false, + dohoda: input?.dohoda ?? false, get XIIoddiel_uplatnujem2percenta() { return this.canDonateTwoPercentOfTax diff --git a/src/lib/initialValues.ts b/src/lib/initialValues.ts index 85278409..6fc9137c 100644 --- a/src/lib/initialValues.ts +++ b/src/lib/initialValues.ts @@ -3,6 +3,7 @@ import { PartnerUserInput, IncomeAndExpenseUserInput, EmployedUserInput, + DohodaUserInput, ChildrenUserInput, PensionUserInput, UrokyUserInput, @@ -54,6 +55,15 @@ export const employmentUserInputInitialValues: EmployedUserInput = { uhrnPreddavkovNaDan: '', } +export const dohodaUserInputInitialValues: DohodaUserInput = { + dohoda: undefined, + uhrnPrijmovZoVsetkychDohod: '', + uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody: '', + uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody: '', + udajeODanovomBonuseNaDietaDohody: '', + uhrnPreddavkovNaDanDohody: '', +} + export const rentUserInputInitialValues: RentUserInput = { rent: undefined, vyskaPrijmovZPrenajmu: '', diff --git a/src/lib/routes.ts b/src/lib/routes.ts index 5f4c1318..bedbedfd 100644 --- a/src/lib/routes.ts +++ b/src/lib/routes.ts @@ -14,6 +14,7 @@ export type Route = | HomeRoute | '/prijmy-a-vydavky' | '/zamestnanie' + | '/dohoda' | '/partner' | '/deti' | '/dochodok' @@ -39,6 +40,7 @@ export const getOrderedRoutes = (taxForm: TaxForm): ReadonlyArray => { homeRoute, '/prijmy-a-vydavky', '/zamestnanie', + '/dohoda', '/partner', '/deti', '/dochodok', @@ -130,7 +132,8 @@ export const validateRoute = ( } else { const requirements = { '/zamestnanie': 't1r10_prijmy', - '/partner': 'employed', + '/dohoda': 'employed', + '/partner': 'dohoda', '/deti': 'r032_uplatnujem_na_partnera', '/dochodok': 'hasChildren', '/prenajom': 'platil_prispevky_na_dochodok', diff --git a/src/lib/xml/xmlConverter.ts b/src/lib/xml/xmlConverter.ts index 0d9f9aa8..e97add64 100644 --- a/src/lib/xml/xmlConverter.ts +++ b/src/lib/xml/xmlConverter.ts @@ -138,13 +138,17 @@ export function convertToJson(taxForm: TaxForm): OutputJson { /** SECTION Employed */ - if (taxForm.employed) { + if (taxForm.employed || taxForm.dohoda) { form.dokument.telo.r36 = decimalToString(taxForm.r036) form.dokument.telo.r37 = decimalToString(taxForm.r037) form.dokument.telo.r38 = decimalToString(taxForm.r038) form.dokument.telo.socZdravPoistenie.pr8 = decimalToString(taxForm.r039) } + if (taxForm.dohoda) { + form.dokument.telo.r36a = decimalToString(taxForm.r036a) + } + form.dokument.telo.r39 = decimalToString(taxForm.r039) form.dokument.telo.r40 = decimalToString(taxForm.r040) form.dokument.telo.r41 = decimalToString(taxForm.r041) @@ -208,7 +212,7 @@ export function convertToJson(taxForm: TaxForm): OutputJson { } } - form.dokument.telo.r153 = taxForm.employed ? '5' : '4' + form.dokument.telo.r153 = taxForm.employed || taxForm.dohoda ? '5' : '4' const maDanovyBonus = taxForm.mozeZiadatVyplatitDanovyBonus && taxForm.ziadamVyplatitDanovyBonus diff --git a/src/pages/dohoda.tsx b/src/pages/dohoda.tsx new file mode 100644 index 00000000..82d4349e --- /dev/null +++ b/src/pages/dohoda.tsx @@ -0,0 +1,153 @@ +import React from 'react' +import { Form } from 'formik' +import { BooleanRadio, FormWrapper, Input } from '../components/FormComponents' +import { DohodaUserInput, FormErrors } from '../types/PageUserInputs' +import { numberInputRegexp } from '../lib/utils' +import { ErrorSummary } from '../components/ErrorSummary' +import { Page } from '../components/Page' +import { dohodaUserInputInitialValues } from '../lib/initialValues' +import { BackLink } from '../components/BackLink' +import { TAX_YEAR } from '../lib/calculation' + +const Dohoda: Page = ({ + setTaxFormUserInput, + taxFormUserInput, + router, + previousRoute, + nextRoute, +}) => { + return ( + <> + + + initialValues={taxFormUserInput} + validate={validate} + onSubmit={(values) => { + const userInput = values.dohoda + ? values + : { + ...dohodaUserInputInitialValues, + dohoda: false, + } + setTaxFormUserInput(userInput) + router.push(nextRoute) + }} + > + {({ values, errors }) => ( +
+ errors={errors} /> + + {values.dohoda && ( + <> +

+ Nasledujúce hodnoty nájdete na tlačive "Potvrdenie o + zdaniteľných príjmoch fyzickej osoby". Ak ste mali viac dohôd, + tak tieto sumy spočítajte a uveďte výsledné. +

+ + + + + + + )} + + + )} + + + ) +} + +export const validate = (values: DohodaUserInput) => { + const errors: Partial> = {} + + if (typeof values.dohoda === 'undefined') { + errors.dohoda = 'Vyznačte odpoveď' + } + + if (values.dohoda) { + if (!values.uhrnPrijmovZoVsetkychDohod) { + errors.uhrnPrijmovZoVsetkychDohod = + 'Zadajte úhrn príjmov zo všetkých dohôd' + } else if (!values.uhrnPrijmovZoVsetkychDohod.match(numberInputRegexp)) { + errors.uhrnPrijmovZoVsetkychDohod = + 'Zadajte sumu príjmov vo formáte 123,45' + } + + if (!values.uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody) { + errors.uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody = + 'Zadajte úhrn sociálneho poistného' + } else if ( + !values.uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody.match( + numberInputRegexp, + ) + ) { + errors.uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody = + 'Zadajte sumu sociálneho poistného vo formáte 123,45' + } + + if (!values.uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody) { + errors.uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody = + 'Zadajte úhrn zdravotného poistného' + } else if ( + !values.uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody.match( + numberInputRegexp, + ) + ) { + errors.uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody = + 'Zadajte sumu zdravotného poistného vo formáte 123,45' + } + + if (!values.uhrnPreddavkovNaDanDohody) { + errors.uhrnPreddavkovNaDanDohody = 'Zadajte úhrn preddavkov na daň' + } else if (!values.uhrnPreddavkovNaDanDohody.match(numberInputRegexp)) { + errors.uhrnPreddavkovNaDanDohody = + 'Zadajte sumu povinného poistného vo formáte 123,45' + } + + if (!values.udajeODanovomBonuseNaDietaDohody) { + errors.udajeODanovomBonuseNaDietaDohody = + 'Zadajte údaje o daňovom bonuse na dieťa' + } else if ( + !values.udajeODanovomBonuseNaDietaDohody.match(numberInputRegexp) + ) { + errors.udajeODanovomBonuseNaDietaDohody = + 'Zadajte sumu povinného poistného vo formáte 123,45' + } + } + + return errors +} + +export default Dohoda diff --git a/src/pages/index.tsx b/src/pages/index.tsx index bb249f05..8f4c8975 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -129,7 +129,6 @@ const TaxFormSection = ({ nextRoute, isDebug, isLive }) => {
  • Daňové straty
  • SZČO starobní dôchodcovia
  • -
  • Práca na dohodu
  • Záväzky a pohľadávky (tabuľka 1b)
  • diff --git a/src/pages/suhrn.tsx b/src/pages/suhrn.tsx index c9cd097a..6194a0e1 100644 --- a/src/pages/suhrn.tsx +++ b/src/pages/suhrn.tsx @@ -178,6 +178,52 @@ const Suhrn: Page = ({ ] } /> + = ({ label="Úhrn vyplatených zdaniteľných príjmov" hint={`Tento údaj nájdete v riadku 01.`} /> - {/* TODO: Pridat input - - */} +export type DohodaUserInput = Pick< + TaxFormUserInput, + | 'dohoda' + | 'uhrnPrijmovZoVsetkychDohod' + | 'uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody' + | 'uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody' + | 'udajeODanovomBonuseNaDietaDohody' + | 'uhrnPreddavkovNaDanDohody' +> + export type RentUserInput = Pick< TaxFormUserInput, | 'rent' diff --git a/src/types/TaxForm.ts b/src/types/TaxForm.ts index cb6d6046..6b5d60ee 100644 --- a/src/types/TaxForm.ts +++ b/src/types/TaxForm.ts @@ -111,6 +111,9 @@ export interface TaxForm { priloha3_r09_socialne: Decimal priloha3_r10_zdravotne: Decimal + /** SECTION Dohoda */ + r036a: Decimal + /** SECTION Prenajom */ rent?: boolean prenajom_oslobodenie: Decimal @@ -249,6 +252,7 @@ export interface TaxForm { /** Helper properties from input, that are not part of taxForm */ children: boolean employed: boolean + dohoda: boolean XIIoddiel_uplatnujem2percenta: boolean danovyBonusNaDieta: { danovyBonus: Decimal diff --git a/src/types/TaxFormUserInput.ts b/src/types/TaxFormUserInput.ts index 82ed6fcf..c03f2b44 100644 --- a/src/types/TaxFormUserInput.ts +++ b/src/types/TaxFormUserInput.ts @@ -92,6 +92,14 @@ export interface TaxFormUserInput { uhrnPreddavkovNaDan?: string udajeODanovomBonuseNaDieta?: string + /** SECTION Dohoda */ + dohoda?: boolean + uhrnPrijmovZoVsetkychDohod?: string + uhrnPovinnehoPoistnehoNaSocialnePoistenieDohody?: string + uhrnPovinnehoPoistnehoNaZdravotnePoistenieDohody?: string + uhrnPreddavkovNaDanDohody?: string + udajeODanovomBonuseNaDietaDohody?: string + /** SECTION Prenajom */ rent?: boolean vyskaPrijmovZPrenajmu?: string