From 643e340fdcda306926793b19ea567e9d79ad92f5 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 12:03:16 +0100 Subject: [PATCH 01/17] unify tax return possibilities iban page --- ...igital_100223_DP FO typ B_Priklad c. 3.xml | 4 +- ...igital_110223_DP FO typ B_Priklad c. 1.xml | 4 +- ...igital_110223_DP FO typ B_Priklad c. 2.xml | 4 +- ...igital_110223_DP FO typ B_Priklad c. 4.xml | 4 +- ...igital_110223_DP FO typ B_Priklad c. 5.xml | 4 +- __tests__/fixtures/unicodeInput.xml | 4 +- __tests__/fixtures/unicodeOutput.xml | 4 +- __tests__/iban.test.ts | 142 +----------------- __tests__/routes.test.ts | 8 +- __tests__/testCases/bugReport6Input.ts | 3 +- __tests__/testCases/withBonusInput.ts | 2 +- .../testCases/withEmploymentBonusInput.ts | 3 +- __tests__/testCases/withTaxReturnInput.ts | 2 +- __tests__/xml/schema.xsd | 4 +- cypress/e2e/executeCase.ts | 42 +----- cypress/e2e/pages.spec.ts | 4 +- public/form/form.572_files/form.572.xmlfdf.js | 5 +- src/lib/calculation.ts | 14 +- src/lib/initialValues.ts | 2 +- src/lib/routes.ts | 4 +- src/lib/xml/outputBasis.ts | 4 +- src/lib/xml/xmlConverter.ts | 21 +-- src/pages/iban.tsx | 63 ++------ src/types/OutputJson.ts | 4 +- src/types/PageUserInputs.ts | 4 +- src/types/TaxForm.ts | 8 +- src/types/TaxFormUserInput.ts | 4 +- 27 files changed, 55 insertions(+), 316 deletions(-) diff --git a/__tests__/examples/2022/SK Digital_100223_DP FO typ B_Priklad c. 3.xml b/__tests__/examples/2022/SK Digital_100223_DP FO typ B_Priklad c. 3.xml index 07d5ee81..4dfc13d5 100644 --- a/__tests__/examples/2022/SK Digital_100223_DP FO typ B_Priklad c. 3.xml +++ b/__tests__/examples/2022/SK Digital_100223_DP FO typ B_Priklad c. 3.xml @@ -576,9 +576,7 @@ 4 10.02.2023 - 1 - 0 - 0 + 1 0 1 diff --git a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 1.xml b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 1.xml index 216171b8..21ed49f0 100644 --- a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 1.xml +++ b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 1.xml @@ -576,9 +576,7 @@ 5 11.02.2023 - 0 - 0 - 0 + 0 0 0 diff --git a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 2.xml b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 2.xml index c81ac334..20693e9b 100644 --- a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 2.xml +++ b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 2.xml @@ -576,9 +576,7 @@ 4 11.02.2023 - 0 - 0 - 0 + 0 0 0 diff --git a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 4.xml b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 4.xml index 0f324287..7ade8356 100644 --- a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 4.xml +++ b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 4.xml @@ -576,9 +576,7 @@ 5 11.02.2023 - 0 - 0 - 0 + 0 0 0 diff --git a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 5.xml b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 5.xml index 9e4bb58f..86b1c863 100644 --- a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 5.xml +++ b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 5.xml @@ -576,9 +576,7 @@ 4 11.02.2023 - 1 - 0 - 0 + 1 1 0 diff --git a/__tests__/fixtures/unicodeInput.xml b/__tests__/fixtures/unicodeInput.xml index b76be45a..07e84377 100644 --- a/__tests__/fixtures/unicodeInput.xml +++ b/__tests__/fixtures/unicodeInput.xml @@ -597,9 +597,7 @@ 3 22.02.2020 - 0 - 0 - 0 + 0 0 0 diff --git a/__tests__/fixtures/unicodeOutput.xml b/__tests__/fixtures/unicodeOutput.xml index 01805cd8..88e34429 100644 --- a/__tests__/fixtures/unicodeOutput.xml +++ b/__tests__/fixtures/unicodeOutput.xml @@ -597,9 +597,7 @@ 3 22.02.2020 - 0 - 0 - 0 + 0 0 0 diff --git a/__tests__/iban.test.ts b/__tests__/iban.test.ts index e69739ee..5f5f88de 100644 --- a/__tests__/iban.test.ts +++ b/__tests__/iban.test.ts @@ -4,157 +4,31 @@ import { TaxForm } from '../src/types/TaxForm' describe('iban', () => { describe('#validate', () => { - describe('mozeZiadatVyplatitDanovyBonus', () => { + describe('mozeZiadatVratitPreplatkyBonusyUroky', () => { const taxFormMock = { - mozeZiadatVyplatitDanovyBonus: true, - mozeZiadatVratitDanovyPreplatok: false, + mozeZiadatVratitPreplatkyBonusyUroky: true } as TaxForm testValidation(makeValidate(taxFormMock), [ { - input: { ziadamVyplatitDanovyBonus: undefined }, - expected: ['ziadamVyplatitDanovyBonus'], + input: { ziadamVyplatitDanovyBonusUrokPreplatok: undefined }, + expected: ['ziadamVyplatitDanovyBonusUrokPreplatok'], }, - { input: { ziadamVyplatitDanovyBonus: false }, expected: [] }, + { input: { ziadamVyplatitDanovyBonusUrokPreplatok: false }, expected: [] }, { - input: { ziadamVyplatitDanovyBonus: true }, + input: { ziadamVyplatitDanovyBonusUrokPreplatok: true }, expected: ['iban'], }, { input: { - ziadamVyplatitDanovyBonus: true, + ziadamVyplatitDanovyBonusUrokPreplatok: true, iban: 'a', }, expected: ['iban'], }, { input: { - ziadamVyplatitDanovyBonus: true, - iban: 'SK6807200002891987426353', - }, - expected: [], - }, - ]) - }) - - describe('mozeZiadatVratitDanovyPreplatok', () => { - const taxFormMock = { - mozeZiadatVyplatitDanovyBonus: false, - mozeZiadatVratitDanovyPreplatok: true, - } as TaxForm - - testValidation(makeValidate(taxFormMock), [ - { - input: { ziadamVratitDanovyPreplatok: undefined }, - expected: ['ziadamVratitDanovyPreplatok'], - }, - { input: { ziadamVratitDanovyPreplatok: false }, expected: [] }, - { - input: { ziadamVratitDanovyPreplatok: true }, - expected: ['iban'], - }, - { - input: { - ziadamVratitDanovyPreplatok: true, - iban: 'a', - }, - expected: ['iban'], - }, - { - input: { - ziadamVratitDanovyPreplatok: true, - iban: 'SK6807200002891987426353', - }, - expected: [], - }, - ]) - }) - - describe('mozeZiadatVyplatitDanovyBonus && mozeZiadatVratitDanovyPreplatok', () => { - const taxFormMock = { - mozeZiadatVyplatitDanovyBonus: true, - mozeZiadatVratitDanovyPreplatok: true, - } as TaxForm - - testValidation(makeValidate(taxFormMock), [ - { - input: { - ziadamVyplatitDanovyBonus: undefined, - ziadamVratitDanovyPreplatok: undefined, - }, - expected: [ - 'ziadamVyplatitDanovyBonus', - 'ziadamVratitDanovyPreplatok', - ], - }, - { - input: { - ziadamVyplatitDanovyBonus: undefined, - ziadamVratitDanovyPreplatok: false, - }, - expected: ['ziadamVyplatitDanovyBonus'], - }, - { - input: { - ziadamVyplatitDanovyBonus: false, - ziadamVratitDanovyPreplatok: undefined, - }, - expected: ['ziadamVratitDanovyPreplatok'], - }, - { - input: { - ziadamVyplatitDanovyBonus: false, - ziadamVratitDanovyPreplatok: false, - }, - expected: [], - }, - { - input: { - ziadamVyplatitDanovyBonus: undefined, - ziadamVratitDanovyPreplatok: true, - }, - expected: ['ziadamVyplatitDanovyBonus', 'iban'], - }, - { - input: { - ziadamVyplatitDanovyBonus: true, - ziadamVratitDanovyPreplatok: undefined, - }, - expected: ['ziadamVratitDanovyPreplatok', 'iban'], - }, - { - input: { - ziadamVyplatitDanovyBonus: true, - ziadamVratitDanovyPreplatok: false, - }, - expected: ['iban'], - }, - { - input: { - ziadamVyplatitDanovyBonus: false, - ziadamVratitDanovyPreplatok: true, - }, - expected: ['iban'], - }, - { - input: { - ziadamVyplatitDanovyBonus: true, - ziadamVratitDanovyPreplatok: true, - }, - expected: ['iban'], - }, - { - input: { - ziadamVyplatitDanovyBonus: true, - ziadamVratitDanovyPreplatok: true, - iban: 'a', - }, - expected: ['iban'], - }, - { - input: { - ziadamVyplatitDanovyBonus: true, - ziadamVratitDanovyPreplatok: true, + ziadamVyplatitDanovyBonusUrokPreplatok: true, iban: 'SK6807200002891987426353', }, expected: [], diff --git a/__tests__/routes.test.ts b/__tests__/routes.test.ts index 3b6997d1..c3a97f8b 100644 --- a/__tests__/routes.test.ts +++ b/__tests__/routes.test.ts @@ -51,7 +51,7 @@ describe('routes', () => { it('should return routes with children, with iban', () => { expect( getOrderedRoutes({ - mozeZiadatVyplatitDanovyBonus: true, + mozeZiadatVratitPreplatkyBonusyUroky: true, } as TaxForm), ).toStrictEqual([ homeRoute, @@ -75,7 +75,7 @@ describe('routes', () => { it('should return routes without children, with iban', () => { expect( getOrderedRoutes({ - mozeZiadatVyplatitDanovyBonus: true, + mozeZiadatVratitPreplatkyBonusyUroky: true, } as TaxForm), ).toStrictEqual([ homeRoute, @@ -114,7 +114,7 @@ describe('routes', () => { it('should be correct when eligible for refund', () => { const { nextRoute } = getRoutes('/suhrn', { - mozeZiadatVyplatitDanovyBonus: true, + mozeZiadatVratitPreplatkyBonusyUroky: true, } as TaxForm) expect(nextRoute()).toBe('/iban') }) @@ -137,7 +137,7 @@ describe('routes', () => { it('should be correct when eligible for refund', () => { const { previousRoute } = getRoutes('/vysledky', { - mozeZiadatVyplatitDanovyBonus: true, + mozeZiadatVratitPreplatkyBonusyUroky: true, } as TaxForm) expect(previousRoute()).toBe('/iban') }) diff --git a/__tests__/testCases/bugReport6Input.ts b/__tests__/testCases/bugReport6Input.ts index 3d4b218e..f3c7dcf2 100644 --- a/__tests__/testCases/bugReport6Input.ts +++ b/__tests__/testCases/bugReport6Input.ts @@ -58,9 +58,8 @@ export const bugReport6Input: E2eTestUserInput = { r142_obchMeno: '', XIIoddiel_suhlasZaslUdaje: false, iban: 'SK6807200002891987426353', - ziadamVyplatitDanovyBonus: true, + ziadamVyplatitDanovyBonusUrokPreplatok: true, datum: '', partner_spolocna_domacnost: true, r006_titul_za: '', - ziadamVratitDanovyPreplatok: true, } diff --git a/__tests__/testCases/withBonusInput.ts b/__tests__/testCases/withBonusInput.ts index fb59678a..2b265894 100644 --- a/__tests__/testCases/withBonusInput.ts +++ b/__tests__/testCases/withBonusInput.ts @@ -48,7 +48,7 @@ export const withBonusInput: E2eTestUserInput = { hasChildren: true, /** SECTION Danovy bonus */ - ziadamVyplatitDanovyBonus: true, + ziadamVyplatitDanovyBonusUrokPreplatok: true, iban: 'SK6807200002891987426353', expectNgoDonationValue: false, diff --git a/__tests__/testCases/withEmploymentBonusInput.ts b/__tests__/testCases/withEmploymentBonusInput.ts index 72fa0fc2..60d8f485 100644 --- a/__tests__/testCases/withEmploymentBonusInput.ts +++ b/__tests__/testCases/withEmploymentBonusInput.ts @@ -41,8 +41,7 @@ export const withEmploymentBonusInput: E2eTestUserInput = { }, ], datum: '22.02.2020', - ziadamVyplatitDanovyBonus: false, - ziadamVratitDanovyPreplatok: true, + ziadamVyplatitDanovyBonusUrokPreplatok: true, iban: 'SK6807200002891987426353', expectNgoDonationValue: false, diff --git a/__tests__/testCases/withTaxReturnInput.ts b/__tests__/testCases/withTaxReturnInput.ts index f7b96336..053121cd 100644 --- a/__tests__/testCases/withTaxReturnInput.ts +++ b/__tests__/testCases/withTaxReturnInput.ts @@ -19,7 +19,7 @@ export const withTaxReturnInput: E2eTestUserInput = { children: [], /** SECTION Danovy preplatok */ - ziadamVratitDanovyPreplatok: true, + ziadamVyplatitDanovyBonusUrokPreplatok: true, iban: 'SK6807200002891987426353', expectNgoDonationValue: true, diff --git a/__tests__/xml/schema.xsd b/__tests__/xml/schema.xsd index c455c8e3..2a98c25f 100644 --- a/__tests__/xml/schema.xsd +++ b/__tests__/xml/schema.xsd @@ -588,9 +588,7 @@ - - - + diff --git a/cypress/e2e/executeCase.ts b/cypress/e2e/executeCase.ts index e6ac0255..908c8eb0 100644 --- a/cypress/e2e/executeCase.ts +++ b/cypress/e2e/executeCase.ts @@ -351,7 +351,7 @@ const executeTestCase = (testCase: string) => { const taxForm = calculate(input) - if (taxForm.mozeZiadatVyplatitDanovyBonus) { + if (taxForm.mozeZiadatVratitPreplatkyBonusyUroky) { /** SECTION IBAN */ assertUrl('/iban') @@ -360,45 +360,11 @@ const executeTestCase = (testCase: string) => { ) cy.get('[data-test=ineligible-message]').should('not.exist') - if (input.ziadamVyplatitDanovyBonus) { - getInput('ziadamVyplatitDanovyBonus', '-yes').click() + if (input.ziadamVyplatitDanovyBonusUrokPreplatok) { + getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-yes').click() typeToInput('iban', input) } else { - getInput('ziadamVyplatitDanovyBonus', '-no').click() - } - - next() - } - - if (taxForm.mozeZiadatVratitDanovyBonusUroky) { - /** SECTION IBAN */ - assertUrl('/iban') - - cy.contains('Žiadam o vyplatenie daňového bonusu na zaplatené úroky') - cy.get('[data-test=ineligible-message]').should('not.exist') - - if (input.ziadamVratitDanovyBonusUroky) { - getInput('ziadamVratitDanovyBonusUroky', '-yes').click() - typeToInput('iban', input) - } else { - getInput('ziadamVratitDanovyBonusUroky', '-no').click() - } - - next() - } - - if (taxForm.mozeZiadatVratitDanovyPreplatok) { - /** SECTION IBAN */ - assertUrl('/iban') - - cy.contains('Žiadam o vrátenie daňového preplatku') - cy.get('[data-test=ineligible-message]').should('not.exist') - - if (input.ziadamVratitDanovyPreplatok) { - getInput('ziadamVratitDanovyPreplatok', '-yes').click() - typeToInput('iban', input) - } else { - getInput('ziadamVratitDanovyPreplatok', '-no').click() + getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-no').click() } next() diff --git a/cypress/e2e/pages.spec.ts b/cypress/e2e/pages.spec.ts index b0a24c7e..1225d82e 100644 --- a/cypress/e2e/pages.spec.ts +++ b/cypress/e2e/pages.spec.ts @@ -902,7 +902,7 @@ describe('IBAN page', () => { getError().should('have.length', 1) - getInput('ziadamVyplatitDanovyBonus', '-no').click() + getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-no').click() next() getError().should('have.length', 0) @@ -910,7 +910,7 @@ describe('IBAN page', () => { cy.get('.govuk-back-link').click() getError().should('have.length', 0) - getInput('ziadamVyplatitDanovyBonus', '-yes').click() + getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-yes').click() getInput('iban').should('exist') next() diff --git a/public/form/form.572_files/form.572.xmlfdf.js b/public/form/form.572_files/form.572.xmlfdf.js index 1a9c0778..6248e73e 100644 --- a/public/form/form.572_files/form.572.xmlfdf.js +++ b/public/form/form.572_files/form.572.xmlfdf.js @@ -576,9 +576,7 @@ function createxmlfinal() { // XV. Oddiel stringBuilder.appendLine('\t'); - stringBuilder.appendLine('\t\t' + (document.getElementById("cbVyplatit").checked ? '1' : '0') + ''); - stringBuilder.appendLine('\t\t' + (document.getElementById("chBonus").checked ? '1' : '0') + ''); - stringBuilder.appendLine('\t\t' + (document.getElementById("cbVratenie").checked ? '1' : '0') + ''); + stringBuilder.appendLine('\t\t' + (document.getElementById("cbVyplatit").checked ? '1' : '0') + ''); stringBuilder.appendLine('\t\t'); stringBuilder.appendLine('\t\t\t' + (document.getElementById("cbPoukazkaDB").checked ? '1' : '0') + ''); stringBuilder.appendLine('\t\t\t' + (document.getElementById("cbUcetDB").checked ? '1' : '0') + ''); @@ -1619,7 +1617,6 @@ function processTelo(telo) { if (bNode.nodeName == "vyplatitDanovyBonus") $("#cbVyplatit").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); if (bNode.nodeName == "vyplatitDanovyBonusUroky") $("#chBonus").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); - if (bNode.nodeName == "vratitDanPreplatok") $("#cbVratenie").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); if (bNode.nodeName == "sposobPlatby") { for (var k = 0; k < bNode.childNodes.length; k++) { diff --git a/src/lib/calculation.ts b/src/lib/calculation.ts index f7348365..5b716a4c 100644 --- a/src/lib/calculation.ts +++ b/src/lib/calculation.ts @@ -723,14 +723,8 @@ export function calculate(input: TaxFormUserInput): TaxForm { get r126() { return round(Decimal.max(this.r123.minus(this.r125), 0)) }, - get mozeZiadatVyplatitDanovyBonus() { - return this.r121.gt(0) - }, - get mozeZiadatVratitDanovyPreplatok() { - return this.r136_danovy_preplatok.gt(0) - }, - get mozeZiadatVratitDanovyBonusUroky() { - return this.r127.gt(0) + get mozeZiadatVratitPreplatkyBonusyUroky() { + return this.r121.gt(0) || this.r136_danovy_preplatok.gt(0) || this.r127.gt(0) }, get r127() { return round(Decimal.max(this.r126.minus(this.r118), 0)) @@ -849,9 +843,7 @@ export function calculate(input: TaxFormUserInput): TaxForm { }, /** SECTION Danovy bonus */ - ziadamVyplatitDanovyBonus: input?.ziadamVyplatitDanovyBonus ?? false, - ziadamVratitDanovyPreplatok: input?.ziadamVratitDanovyPreplatok ?? false, - ziadamVratitDanovyBonusUroky: input?.ziadamVratitDanovyBonusUroky ?? false, + ziadamVyplatitDanovyBonusUrokPreplatok: input?.ziadamVyplatitDanovyBonusUrokPreplatok ?? false, iban: input?.iban ? input?.iban.replace(/\s/g, '') : '', datum: input.datum, diff --git a/src/lib/initialValues.ts b/src/lib/initialValues.ts index 6fc9137c..7006543f 100644 --- a/src/lib/initialValues.ts +++ b/src/lib/initialValues.ts @@ -117,7 +117,7 @@ export const twoPercentInitialValues: TwoPercentUserInput = { export const taxBonusInitialInput: TaxBonusUserInput = { iban: '', - ziadamVyplatitDanovyBonus: undefined, + ziadamVyplatitDanovyBonusUrokPreplatok: undefined, } export const initTaxFormUserInputValues: TaxFormUserInput = { diff --git a/src/lib/routes.ts b/src/lib/routes.ts index bedbedfd..ee308744 100644 --- a/src/lib/routes.ts +++ b/src/lib/routes.ts @@ -30,9 +30,7 @@ export type Route = export const getOrderedRoutes = (taxForm: TaxForm): ReadonlyArray => { const getIbanRoute = (): Route[] => { const isIbanRequired = - taxForm.mozeZiadatVyplatitDanovyBonus || - taxForm.mozeZiadatVratitDanovyPreplatok || - taxForm.mozeZiadatVratitDanovyBonusUroky + taxForm.mozeZiadatVratitPreplatkyBonusyUroky return isIbanRequired ? ['/iban'] : [] } diff --git a/src/lib/xml/outputBasis.ts b/src/lib/xml/outputBasis.ts index 292be4cd..fe7bc7f3 100644 --- a/src/lib/xml/outputBasis.ts +++ b/src/lib/xml/outputBasis.ts @@ -565,9 +565,7 @@ const sampleSchema: OutputJson = { r153: '0', datumVyhlasenia: '', danovyPreplatokBonus: { - vyplatitDanovyBonus: '0', - vyplatitDanovyBonusUroky: '0', - vratitDanPreplatok: '0', + vyplatitDanovyBonusUrokPreplatok: '0', sposobPlatby: { poukazka: '0', ucet: '0', diff --git a/src/lib/xml/xmlConverter.ts b/src/lib/xml/xmlConverter.ts index e97add64..c8a9f8ca 100644 --- a/src/lib/xml/xmlConverter.ts +++ b/src/lib/xml/xmlConverter.ts @@ -214,29 +214,12 @@ export function convertToJson(taxForm: TaxForm): OutputJson { form.dokument.telo.r153 = taxForm.employed || taxForm.dohoda ? '5' : '4' - const maDanovyBonus = - taxForm.mozeZiadatVyplatitDanovyBonus && taxForm.ziadamVyplatitDanovyBonus - const maDanovyBonusUroky = - taxForm.mozeZiadatVratitDanovyBonusUroky && - taxForm.ziadamVratitDanovyBonusUroky - const maDanovyPreplatok = - taxForm.mozeZiadatVratitDanovyPreplatok && - taxForm.ziadamVratitDanovyPreplatok - - if (maDanovyBonus || maDanovyPreplatok || maDanovyBonusUroky) { + if (taxForm.mozeZiadatVratitPreplatkyBonusyUroky && taxForm.ziadamVyplatitDanovyBonusUrokPreplatok) { form.dokument.telo.danovyPreplatokBonus.bankovyUcet.IBAN = taxForm.iban form.dokument.telo.danovyPreplatokBonus.datum = taxForm.datum form.dokument.telo.danovyPreplatokBonus.sposobPlatby.ucet = '1' - if (taxForm.ziadamVyplatitDanovyBonus) { - form.dokument.telo.danovyPreplatokBonus.vyplatitDanovyBonus = '1' - } - if (taxForm.ziadamVratitDanovyPreplatok) { - form.dokument.telo.danovyPreplatokBonus.vratitDanPreplatok = '1' - } - if (taxForm.ziadamVratitDanovyBonusUroky) { - form.dokument.telo.danovyPreplatokBonus.vyplatitDanovyBonusUroky = '1' - } + form.dokument.telo.danovyPreplatokBonus.vyplatitDanovyBonusUrokPreplatok = '1' } form.dokument.telo.datumVyhlasenia = taxForm.datum diff --git a/src/pages/iban.tsx b/src/pages/iban.tsx index ae21c7bf..2b84dd6b 100644 --- a/src/pages/iban.tsx +++ b/src/pages/iban.tsx @@ -23,9 +23,7 @@ const Iban: Page = ({ nextRoute, }) => { if ( - !taxForm.mozeZiadatVyplatitDanovyBonus && - !taxForm.mozeZiadatVratitDanovyPreplatok && - !taxForm.mozeZiadatVratitDanovyBonusUroky + !taxForm.mozeZiadatVratitPreplatkyBonusyUroky ) { return ( <> @@ -52,15 +50,11 @@ const Iban: Page = ({ validate={makeValidate(taxForm)} onSubmit={(values) => { const userInput = - values.ziadamVyplatitDanovyBonus || - values.ziadamVratitDanovyPreplatok || - values.ziadamVratitDanovyBonusUroky + values.ziadamVyplatitDanovyBonusUrokPreplatok ? values : { ...taxBonusInitialInput, - ziadamVyplatitDanovyBonus: false, - ziadamVratitDanovyPreplatok: false, - ziadamVratitDanovyBonusUroky: false, + ziadamVyplatitDanovyBonusziadamVyplatitDanovyBonus: false, } setTaxFormUserInput(userInput) router.push(nextRoute) @@ -72,30 +66,14 @@ const Iban: Page = ({
errors={errors} /> - {taxForm.mozeZiadatVyplatitDanovyBonus && ( + {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && ( )} - {taxForm.mozeZiadatVratitDanovyPreplatok && ( - - )} - - {taxForm.mozeZiadatVratitDanovyBonusUroky && ( - - )} - - {(values.ziadamVyplatitDanovyBonus || - values.ziadamVratitDanovyPreplatok || - values.ziadamVratitDanovyBonusUroky) && ( + {values.ziadamVyplatitDanovyBonusUrokPreplatok && ( > = {} if ( - taxForm.mozeZiadatVyplatitDanovyBonus && - typeof values.ziadamVyplatitDanovyBonus === 'undefined' - ) { - errors.ziadamVyplatitDanovyBonus = 'Vyznačte odpoveď na daňový bonus' - } - - if ( - taxForm.mozeZiadatVratitDanovyPreplatok && - typeof values.ziadamVratitDanovyPreplatok === 'undefined' + taxForm.mozeZiadatVratitPreplatkyBonusyUroky && + typeof values.ziadamVyplatitDanovyBonusUrokPreplatok === 'undefined' ) { - errors.ziadamVratitDanovyPreplatok = - 'Vyznačte odpoveď na daňový preplatok' + errors.ziadamVyplatitDanovyBonusUrokPreplatok = 'Vyznačte odpoveď na daňový bonus alebo preplatok' } - if ( - taxForm.mozeZiadatVratitDanovyBonusUroky && - typeof values.ziadamVratitDanovyBonusUroky === 'undefined' - ) { - errors.ziadamVratitDanovyBonusUroky = 'Vyznačte odpoveď na daňový bonus' - } - - if ( - values.ziadamVyplatitDanovyBonus || - values.ziadamVratitDanovyPreplatok || - values.ziadamVratitDanovyBonusUroky - ) { + if (values.ziadamVyplatitDanovyBonusUrokPreplatok) { if (!values.iban || values.iban === '') { // Medzinárodné bankové číslo účtu (angl. International Bank Account Number, skr. IBAN) errors.iban = 'Zadajte váš IBAN' diff --git a/src/types/OutputJson.ts b/src/types/OutputJson.ts index 4e555128..146b7e2f 100644 --- a/src/types/OutputJson.ts +++ b/src/types/OutputJson.ts @@ -487,9 +487,7 @@ export interface BankovyUcet { } export interface DanovyPreplatokBonus { - vyplatitDanovyBonus: string - vyplatitDanovyBonusUroky: string - vratitDanPreplatok: string + vyplatitDanovyBonusUrokPreplatok: string sposobPlatby: SposobPlatby bankovyUcet: BankovyUcet datum: string diff --git a/src/types/PageUserInputs.ts b/src/types/PageUserInputs.ts index 5a81174a..4e29e9a6 100644 --- a/src/types/PageUserInputs.ts +++ b/src/types/PageUserInputs.ts @@ -129,9 +129,7 @@ export type TwoPercentUserInput = Pick< export type TaxBonusUserInput = Pick< TaxFormUserInput, - | 'ziadamVyplatitDanovyBonus' - | 'ziadamVratitDanovyPreplatok' - | 'ziadamVratitDanovyBonusUroky' + | 'ziadamVyplatitDanovyBonusUrokPreplatok' | 'iban' > diff --git a/src/types/TaxForm.ts b/src/types/TaxForm.ts index 6b5d60ee..f7e02a5b 100644 --- a/src/types/TaxForm.ts +++ b/src/types/TaxForm.ts @@ -241,12 +241,8 @@ export interface TaxForm { socZdravPoistenieDatum: string /** SECTION Danovy bonus */ - mozeZiadatVyplatitDanovyBonus: boolean - ziadamVyplatitDanovyBonus: boolean - mozeZiadatVratitDanovyPreplatok: boolean - ziadamVratitDanovyPreplatok: boolean - mozeZiadatVratitDanovyBonusUroky: boolean - ziadamVratitDanovyBonusUroky: boolean + mozeZiadatVratitPreplatkyBonusyUroky: boolean + ziadamVyplatitDanovyBonusUrokPreplatok: boolean iban: string /** Helper properties from input, that are not part of taxForm */ diff --git a/src/types/TaxFormUserInput.ts b/src/types/TaxFormUserInput.ts index c03f2b44..849c9ac7 100644 --- a/src/types/TaxFormUserInput.ts +++ b/src/types/TaxFormUserInput.ts @@ -129,9 +129,7 @@ export interface TaxFormUserInput { XIIoddiel_suhlasZaslUdaje?: boolean /** SECTION Danovy bonus */ - ziadamVyplatitDanovyBonus?: boolean - ziadamVratitDanovyPreplatok?: boolean - ziadamVratitDanovyBonusUroky?: boolean + ziadamVyplatitDanovyBonusUrokPreplatok?: boolean iban?: string /** Musi byt sucastou user inputu, aj ked sa generuje automaticky, inac by From da87de85008217bdabd30c3a3cf094b6ce382ca2 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 12:49:13 +0100 Subject: [PATCH 02/17] add tex returns summary --- public/form/form.572_files/form.572.xmlfdf.js | 3 +- src/lib/calculation.ts | 9 +++ src/pages/iban.tsx | 59 ++++++++++++++++++- src/types/TaxForm.ts | 3 + 4 files changed, 70 insertions(+), 4 deletions(-) diff --git a/public/form/form.572_files/form.572.xmlfdf.js b/public/form/form.572_files/form.572.xmlfdf.js index 6248e73e..d09d7a5a 100644 --- a/public/form/form.572_files/form.572.xmlfdf.js +++ b/public/form/form.572_files/form.572.xmlfdf.js @@ -1615,8 +1615,7 @@ function processTelo(telo) { for (var j = 0; j < aNode.childNodes.length; j++) { var bNode = aNode.childNodes[j]; - if (bNode.nodeName == "vyplatitDanovyBonus") $("#cbVyplatit").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); - if (bNode.nodeName == "vyplatitDanovyBonusUroky") $("#chBonus").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); + if (bNode.nodeName == "vyplatitDanovyBonusUrokPreplatok") $("#cbVyplatit").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); if (bNode.nodeName == "sposobPlatby") { for (var k = 0; k < bNode.childNodes.length; k++) { diff --git a/src/lib/calculation.ts b/src/lib/calculation.ts index 5b716a4c..7d04a514 100644 --- a/src/lib/calculation.ts +++ b/src/lib/calculation.ts @@ -723,6 +723,15 @@ export function calculate(input: TaxFormUserInput): TaxForm { get r126() { return round(Decimal.max(this.r123.minus(this.r125), 0)) }, + get mozeZiadatVyplatitDanovyBonus() { + return this.r121.gt(0) + }, + get mozeZiadatVratitDanovyPreplatok() { + return this.r136_danovy_preplatok.gt(0) + }, + get mozeZiadatVratitDanovyBonusUroky() { + return this.r127.gt(0) + }, get mozeZiadatVratitPreplatkyBonusyUroky() { return this.r121.gt(0) || this.r136_danovy_preplatok.gt(0) || this.r127.gt(0) }, diff --git a/src/pages/iban.tsx b/src/pages/iban.tsx index 2b84dd6b..8f0ca2be 100644 --- a/src/pages/iban.tsx +++ b/src/pages/iban.tsx @@ -1,10 +1,11 @@ -import React from 'react' +import React, { useMemo } from 'react' import Link from 'next/link' import { FormErrors, TaxBonusUserInput } from '../types/PageUserInputs' import { Form, FormikProps } from 'formik' import { ErrorSummary } from '../components/ErrorSummary' import { BooleanRadio, FormWrapper, Input } from '../components/FormComponents' import { + formatCurrency, formatIban, validateIbanCountry, validateIbanFormat, @@ -22,6 +23,59 @@ const Iban: Page = ({ previousRoute, nextRoute, }) => { + const Preplatky = useMemo(() => + { + const danovyBonus = Number(taxForm.r121); + const danovyBonusUroky = Number(taxForm.r127); + const danovyPreplatok = Number(taxForm.r136_danovy_preplatok); + const spolu = danovyBonus + danovyBonusUroky + danovyPreplatok; + + return ( +
+ {taxForm.mozeZiadatVyplatitDanovyBonus && ( +
+ + Daňový bonus: + +

+ {formatCurrency(danovyBonus)} +

+
+ )} + {taxForm.mozeZiadatVratitDanovyBonusUroky && ( +
+ + Daňový bonus na zaplatené úroky: + +

+ {formatCurrency(danovyBonusUroky)} +

+
+ )} + {taxForm.mozeZiadatVratitDanovyPreplatok && ( +
+ + Daňový preplatok: + +

+ {formatCurrency(danovyPreplatok)} +

+
+ )} + {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && ( +
+ + Spolu: + +

+ {formatCurrency(spolu)} +

+
+ )} +
+ ) + }, [taxForm]) + if ( !taxForm.mozeZiadatVratitPreplatkyBonusyUroky ) { @@ -69,7 +123,8 @@ const Iban: Page = ({ {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && ( )} diff --git a/src/types/TaxForm.ts b/src/types/TaxForm.ts index f7e02a5b..b8de6656 100644 --- a/src/types/TaxForm.ts +++ b/src/types/TaxForm.ts @@ -241,6 +241,9 @@ export interface TaxForm { socZdravPoistenieDatum: string /** SECTION Danovy bonus */ + mozeZiadatVyplatitDanovyBonus: boolean + mozeZiadatVratitDanovyPreplatok: boolean + mozeZiadatVratitDanovyBonusUroky: boolean mozeZiadatVratitPreplatkyBonusyUroky: boolean ziadamVyplatitDanovyBonusUrokPreplatok: boolean iban: string From 25285dc242ac1f472e032bb02eba291c81a189d4 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 12:52:07 +0100 Subject: [PATCH 03/17] ditch use memo --- src/pages/iban.tsx | 101 ++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 52 deletions(-) diff --git a/src/pages/iban.tsx b/src/pages/iban.tsx index 8f0ca2be..c7405f61 100644 --- a/src/pages/iban.tsx +++ b/src/pages/iban.tsx @@ -1,4 +1,4 @@ -import React, { useMemo } from 'react' +import React from 'react' import Link from 'next/link' import { FormErrors, TaxBonusUserInput } from '../types/PageUserInputs' import { Form, FormikProps } from 'formik' @@ -23,58 +23,55 @@ const Iban: Page = ({ previousRoute, nextRoute, }) => { - const Preplatky = useMemo(() => - { - const danovyBonus = Number(taxForm.r121); - const danovyBonusUroky = Number(taxForm.r127); - const danovyPreplatok = Number(taxForm.r136_danovy_preplatok); - const spolu = danovyBonus + danovyBonusUroky + danovyPreplatok; + const danovyBonus = Number(taxForm.r121); + const danovyBonusUroky = Number(taxForm.r127); + const danovyPreplatok = Number(taxForm.r136_danovy_preplatok); + const spolu = danovyBonus + danovyBonusUroky + danovyPreplatok; - return ( -
- {taxForm.mozeZiadatVyplatitDanovyBonus && ( -
- - Daňový bonus: - -

- {formatCurrency(danovyBonus)} -

-
- )} - {taxForm.mozeZiadatVratitDanovyBonusUroky && ( -
- - Daňový bonus na zaplatené úroky: - -

- {formatCurrency(danovyBonusUroky)} -

-
- )} - {taxForm.mozeZiadatVratitDanovyPreplatok && ( -
- - Daňový preplatok: - -

- {formatCurrency(danovyPreplatok)} -

-
- )} - {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && ( -
- - Spolu: - -

- {formatCurrency(spolu)} -

-
- )} -
- ) - }, [taxForm]) + const Preplatky = ( +
+ {taxForm.mozeZiadatVyplatitDanovyBonus && ( +
+ + Daňový bonus: + +

+ {formatCurrency(danovyBonus)} +

+
+ )} + {taxForm.mozeZiadatVratitDanovyBonusUroky && ( +
+ + Daňový bonus na zaplatené úroky: + +

+ {formatCurrency(danovyBonusUroky)} +

+
+ )} + {taxForm.mozeZiadatVratitDanovyPreplatok && ( +
+ + Daňový preplatok: + +

+ {formatCurrency(danovyPreplatok)} +

+
+ )} + {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && ( +
+ + Spolu: + +

+ {formatCurrency(spolu)} +

+
+ )} +
+ ); if ( !taxForm.mozeZiadatVratitPreplatkyBonusyUroky From 035c82a96965b73674dada94186e719beac5c642 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 12:59:11 +0100 Subject: [PATCH 04/17] rever form.572 changes --- public/form/form.572_files/form.572.xmlfdf.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/public/form/form.572_files/form.572.xmlfdf.js b/public/form/form.572_files/form.572.xmlfdf.js index d09d7a5a..1a9c0778 100644 --- a/public/form/form.572_files/form.572.xmlfdf.js +++ b/public/form/form.572_files/form.572.xmlfdf.js @@ -576,7 +576,9 @@ function createxmlfinal() { // XV. Oddiel stringBuilder.appendLine('\t'); - stringBuilder.appendLine('\t\t' + (document.getElementById("cbVyplatit").checked ? '1' : '0') + ''); + stringBuilder.appendLine('\t\t' + (document.getElementById("cbVyplatit").checked ? '1' : '0') + ''); + stringBuilder.appendLine('\t\t' + (document.getElementById("chBonus").checked ? '1' : '0') + ''); + stringBuilder.appendLine('\t\t' + (document.getElementById("cbVratenie").checked ? '1' : '0') + ''); stringBuilder.appendLine('\t\t'); stringBuilder.appendLine('\t\t\t' + (document.getElementById("cbPoukazkaDB").checked ? '1' : '0') + ''); stringBuilder.appendLine('\t\t\t' + (document.getElementById("cbUcetDB").checked ? '1' : '0') + ''); @@ -1615,7 +1617,9 @@ function processTelo(telo) { for (var j = 0; j < aNode.childNodes.length; j++) { var bNode = aNode.childNodes[j]; - if (bNode.nodeName == "vyplatitDanovyBonusUrokPreplatok") $("#cbVyplatit").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); + if (bNode.nodeName == "vyplatitDanovyBonus") $("#cbVyplatit").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); + if (bNode.nodeName == "vyplatitDanovyBonusUroky") $("#chBonus").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); + if (bNode.nodeName == "vratitDanPreplatok") $("#cbVratenie").attr("checked", (getNodeValue(bNode) == '1' ? true : false)).change(); if (bNode.nodeName == "sposobPlatby") { for (var k = 0; k < bNode.childNodes.length; k++) { From f75962bb02ff40ff098d2de6e378abd6a52f1931 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 13:37:12 +0100 Subject: [PATCH 05/17] revert test changes --- __tests__/testCases/withoutTaxReturnInput.ts | 28 ++++++++++++++ cypress/e2e/executeCase.ts | 40 ++++++++++++++++++-- src/types/TaxFormUserInput.ts | 3 ++ 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 __tests__/testCases/withoutTaxReturnInput.ts diff --git a/__tests__/testCases/withoutTaxReturnInput.ts b/__tests__/testCases/withoutTaxReturnInput.ts new file mode 100644 index 00000000..b176e213 --- /dev/null +++ b/__tests__/testCases/withoutTaxReturnInput.ts @@ -0,0 +1,28 @@ +import { E2eTestUserInput } from '../../src/types/E2eTestUserInput' + +export const withouTaxReturnInput: E2eTestUserInput = { + priloha3_r11_socialne: '1000', + priloha3_r13_zdravotne: '1000', + zaplatenePreddavky: '5000', + r005_meno: 'Fake', + r004_priezvisko: 'Name', + r001_dic: '233123123', + r003_nace: '62010 - Počítačové programovanie', + r007_ulica: 'Mierova', + r008_cislo: '4', + r009_psc: '82105', + r010_obec: 'Bratislava 3', + r011_stat: 'Slovensko', + t1r10_prijmy: '25000', + datum: '22.02.2020', + hasChildren: false, + children: [], + + /** SECTION Danovy preplatok */ + ziadamVyplatitDanovyBonusUrokPreplatok: false, + + expectNgoDonationValue: true, + + percent2: '9,23', + percent3: '15,39', +} diff --git a/cypress/e2e/executeCase.ts b/cypress/e2e/executeCase.ts index 908c8eb0..766cb9e9 100644 --- a/cypress/e2e/executeCase.ts +++ b/cypress/e2e/executeCase.ts @@ -351,7 +351,7 @@ const executeTestCase = (testCase: string) => { const taxForm = calculate(input) - if (taxForm.mozeZiadatVratitPreplatkyBonusyUroky) { + if (taxForm.mozeZiadatVyplatitDanovyBonus) { /** SECTION IBAN */ assertUrl('/iban') @@ -361,10 +361,44 @@ const executeTestCase = (testCase: string) => { cy.get('[data-test=ineligible-message]').should('not.exist') if (input.ziadamVyplatitDanovyBonusUrokPreplatok) { - getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-yes').click() + getInput('ziadamVyplatitDanovyBonus', '-yes').click() typeToInput('iban', input) } else { - getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-no').click() + getInput('ziadamVyplatitDanovyBonus', '-no').click() + } + + next() + } + + if (taxForm.mozeZiadatVratitDanovyBonusUroky) { + /** SECTION IBAN */ + assertUrl('/iban') + + cy.contains('Žiadam o vyplatenie daňového bonusu na zaplatené úroky') + cy.get('[data-test=ineligible-message]').should('not.exist') + + if (input.ziadamVyplatitDanovyBonusUrokPreplatok) { + getInput('ziadamVratitDanovyBonusUroky', '-yes').click() + typeToInput('iban', input) + } else { + getInput('ziadamVratitDanovyBonusUroky', '-no').click() + } + + next() + } + + if (taxForm.mozeZiadatVratitDanovyPreplatok) { + /** SECTION IBAN */ + assertUrl('/iban') + + cy.contains('Žiadam o vrátenie daňového preplatku') + cy.get('[data-test=ineligible-message]').should('not.exist') + + if (input.ziadamVyplatitDanovyBonusUrokPreplatok) { + getInput('ziadamVratitDanovyPreplatok', '-yes').click() + typeToInput('iban', input) + } else { + getInput('ziadamVratitDanovyPreplatok', '-no').click() } next() diff --git a/src/types/TaxFormUserInput.ts b/src/types/TaxFormUserInput.ts index 849c9ac7..2baec663 100644 --- a/src/types/TaxFormUserInput.ts +++ b/src/types/TaxFormUserInput.ts @@ -129,6 +129,9 @@ export interface TaxFormUserInput { XIIoddiel_suhlasZaslUdaje?: boolean /** SECTION Danovy bonus */ + ziadamVyplatitDanovyBonus?: boolean + ziadamVratitDanovyPreplatok?: boolean + ziadamVratitDanovyBonusUroky?: boolean ziadamVyplatitDanovyBonusUrokPreplatok?: boolean iban?: string From c1c3b4d266f53617ca64fea75e1b6ec4f152acdc Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 14:36:27 +0100 Subject: [PATCH 06/17] revert changes --- .../SK Digital_100223_DP FO typ B_Priklad c. 3.xml | 4 +++- .../SK Digital_110223_DP FO typ B_Priklad c. 1.xml | 4 +++- .../SK Digital_110223_DP FO typ B_Priklad c. 2.xml | 4 +++- .../SK Digital_110223_DP FO typ B_Priklad c. 4.xml | 4 +++- .../SK Digital_110223_DP FO typ B_Priklad c. 5.xml | 4 +++- __tests__/fixtures/unicodeInput.xml | 4 +++- __tests__/fixtures/unicodeOutput.xml | 4 +++- __tests__/xml/schema.xsd | 4 +++- src/lib/xml/outputBasis.ts | 4 +++- src/lib/xml/xmlConverter.ts | 11 ++++++++++- src/types/OutputJson.ts | 4 +++- src/types/TaxFormUserInput.ts | 4 ++++ 12 files changed, 44 insertions(+), 11 deletions(-) diff --git a/__tests__/examples/2022/SK Digital_100223_DP FO typ B_Priklad c. 3.xml b/__tests__/examples/2022/SK Digital_100223_DP FO typ B_Priklad c. 3.xml index 4dfc13d5..07d5ee81 100644 --- a/__tests__/examples/2022/SK Digital_100223_DP FO typ B_Priklad c. 3.xml +++ b/__tests__/examples/2022/SK Digital_100223_DP FO typ B_Priklad c. 3.xml @@ -576,7 +576,9 @@ 4 10.02.2023 - 1 + 1 + 0 + 0 0 1 diff --git a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 1.xml b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 1.xml index 21ed49f0..216171b8 100644 --- a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 1.xml +++ b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 1.xml @@ -576,7 +576,9 @@ 5 11.02.2023 - 0 + 0 + 0 + 0 0 0 diff --git a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 2.xml b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 2.xml index 20693e9b..c81ac334 100644 --- a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 2.xml +++ b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 2.xml @@ -576,7 +576,9 @@ 4 11.02.2023 - 0 + 0 + 0 + 0 0 0 diff --git a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 4.xml b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 4.xml index 7ade8356..0f324287 100644 --- a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 4.xml +++ b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 4.xml @@ -576,7 +576,9 @@ 5 11.02.2023 - 0 + 0 + 0 + 0 0 0 diff --git a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 5.xml b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 5.xml index 86b1c863..9e4bb58f 100644 --- a/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 5.xml +++ b/__tests__/examples/2022/SK Digital_110223_DP FO typ B_Priklad c. 5.xml @@ -576,7 +576,9 @@ 4 11.02.2023 - 1 + 1 + 0 + 0 1 0 diff --git a/__tests__/fixtures/unicodeInput.xml b/__tests__/fixtures/unicodeInput.xml index 07e84377..b76be45a 100644 --- a/__tests__/fixtures/unicodeInput.xml +++ b/__tests__/fixtures/unicodeInput.xml @@ -597,7 +597,9 @@ 3 22.02.2020 - 0 + 0 + 0 + 0 0 0 diff --git a/__tests__/fixtures/unicodeOutput.xml b/__tests__/fixtures/unicodeOutput.xml index 88e34429..01805cd8 100644 --- a/__tests__/fixtures/unicodeOutput.xml +++ b/__tests__/fixtures/unicodeOutput.xml @@ -597,7 +597,9 @@ 3 22.02.2020 - 0 + 0 + 0 + 0 0 0 diff --git a/__tests__/xml/schema.xsd b/__tests__/xml/schema.xsd index 2a98c25f..425340cb 100644 --- a/__tests__/xml/schema.xsd +++ b/__tests__/xml/schema.xsd @@ -588,7 +588,9 @@ - + + + diff --git a/src/lib/xml/outputBasis.ts b/src/lib/xml/outputBasis.ts index fe7bc7f3..292be4cd 100644 --- a/src/lib/xml/outputBasis.ts +++ b/src/lib/xml/outputBasis.ts @@ -565,7 +565,9 @@ const sampleSchema: OutputJson = { r153: '0', datumVyhlasenia: '', danovyPreplatokBonus: { - vyplatitDanovyBonusUrokPreplatok: '0', + vyplatitDanovyBonus: '0', + vyplatitDanovyBonusUroky: '0', + vratitDanPreplatok: '0', sposobPlatby: { poukazka: '0', ucet: '0', diff --git a/src/lib/xml/xmlConverter.ts b/src/lib/xml/xmlConverter.ts index c8a9f8ca..6110a13a 100644 --- a/src/lib/xml/xmlConverter.ts +++ b/src/lib/xml/xmlConverter.ts @@ -214,12 +214,21 @@ export function convertToJson(taxForm: TaxForm): OutputJson { form.dokument.telo.r153 = taxForm.employed || taxForm.dohoda ? '5' : '4' + if (taxForm.mozeZiadatVratitPreplatkyBonusyUroky && taxForm.ziadamVyplatitDanovyBonusUrokPreplatok) { form.dokument.telo.danovyPreplatokBonus.bankovyUcet.IBAN = taxForm.iban form.dokument.telo.danovyPreplatokBonus.datum = taxForm.datum form.dokument.telo.danovyPreplatokBonus.sposobPlatby.ucet = '1' - form.dokument.telo.danovyPreplatokBonus.vyplatitDanovyBonusUrokPreplatok = '1' + if (taxForm.mozeZiadatVyplatitDanovyBonus) { + form.dokument.telo.danovyPreplatokBonus.vyplatitDanovyBonus = '1' + } + if (taxForm.mozeZiadatVratitDanovyPreplatok) { + form.dokument.telo.danovyPreplatokBonus.vratitDanPreplatok = '1' + } + if (taxForm.mozeZiadatVratitDanovyBonusUroky) { + form.dokument.telo.danovyPreplatokBonus.vyplatitDanovyBonusUroky = '1' + } } form.dokument.telo.datumVyhlasenia = taxForm.datum diff --git a/src/types/OutputJson.ts b/src/types/OutputJson.ts index 146b7e2f..507426e8 100644 --- a/src/types/OutputJson.ts +++ b/src/types/OutputJson.ts @@ -487,7 +487,9 @@ export interface BankovyUcet { } export interface DanovyPreplatokBonus { - vyplatitDanovyBonusUrokPreplatok: string + vyplatitDanovyBonus: string + vratitDanPreplatok: string + vyplatitDanovyBonusUroky: string sposobPlatby: SposobPlatby bankovyUcet: BankovyUcet datum: string diff --git a/src/types/TaxFormUserInput.ts b/src/types/TaxFormUserInput.ts index 2baec663..e5f9d849 100644 --- a/src/types/TaxFormUserInput.ts +++ b/src/types/TaxFormUserInput.ts @@ -129,6 +129,10 @@ export interface TaxFormUserInput { XIIoddiel_suhlasZaslUdaje?: boolean /** SECTION Danovy bonus */ + r121?: string + r127?: string + r136_danovy_preplatok?: string + ziadamVyplatitDanovyBonus?: boolean ziadamVratitDanovyPreplatok?: boolean ziadamVratitDanovyBonusUroky?: boolean From cfe410afb762d8db79ee7ae282d331521e632a0e Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 14:40:04 +0100 Subject: [PATCH 07/17] remove extra fields --- src/types/TaxFormUserInput.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/types/TaxFormUserInput.ts b/src/types/TaxFormUserInput.ts index e5f9d849..2baec663 100644 --- a/src/types/TaxFormUserInput.ts +++ b/src/types/TaxFormUserInput.ts @@ -129,10 +129,6 @@ export interface TaxFormUserInput { XIIoddiel_suhlasZaslUdaje?: boolean /** SECTION Danovy bonus */ - r121?: string - r127?: string - r136_danovy_preplatok?: string - ziadamVyplatitDanovyBonus?: boolean ziadamVratitDanovyPreplatok?: boolean ziadamVratitDanovyBonusUroky?: boolean From 58d308e89b34206f3b1cc9f6c544eeaab832ebff Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 14:55:17 +0100 Subject: [PATCH 08/17] update tests, lint --- __tests__/xml/schema.xsd | 2 +- cypress/e2e/executeCase.ts | 53 ++++++++++++++------------------------ 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/__tests__/xml/schema.xsd b/__tests__/xml/schema.xsd index 425340cb..c455c8e3 100644 --- a/__tests__/xml/schema.xsd +++ b/__tests__/xml/schema.xsd @@ -588,7 +588,7 @@ - + diff --git a/cypress/e2e/executeCase.ts b/cypress/e2e/executeCase.ts index 766cb9e9..2105c804 100644 --- a/cypress/e2e/executeCase.ts +++ b/cypress/e2e/executeCase.ts @@ -351,54 +351,41 @@ const executeTestCase = (testCase: string) => { const taxForm = calculate(input) - if (taxForm.mozeZiadatVyplatitDanovyBonus) { + if (taxForm.mozeZiadatVratitPreplatkyBonusyUroky) { /** SECTION IBAN */ assertUrl('/iban') cy.contains( - 'Žiadam o vyplatenie daňového bonusu alebo rozdielu daňového bonusu', + 'Žiadam o vyplatenie daňových bonusov alebo preplatkov', ) cy.get('[data-test=ineligible-message]').should('not.exist') + cy.contains( + 'Spolu:', + ) if (input.ziadamVyplatitDanovyBonusUrokPreplatok) { - getInput('ziadamVyplatitDanovyBonus', '-yes').click() + getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-yes').click() typeToInput('iban', input) } else { - getInput('ziadamVyplatitDanovyBonus', '-no').click() + getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-no').click() } - next() - } - - if (taxForm.mozeZiadatVratitDanovyBonusUroky) { - /** SECTION IBAN */ - assertUrl('/iban') - - cy.contains('Žiadam o vyplatenie daňového bonusu na zaplatené úroky') - cy.get('[data-test=ineligible-message]').should('not.exist') - - if (input.ziadamVyplatitDanovyBonusUrokPreplatok) { - getInput('ziadamVratitDanovyBonusUroky', '-yes').click() - typeToInput('iban', input) - } else { - getInput('ziadamVratitDanovyBonusUroky', '-no').click() + if (taxForm.mozeZiadatVyplatitDanovyBonus) { + cy.contains( + 'Daňový bonus:', + ) } - next() - } - - if (taxForm.mozeZiadatVratitDanovyPreplatok) { - /** SECTION IBAN */ - assertUrl('/iban') - - cy.contains('Žiadam o vrátenie daňového preplatku') - cy.get('[data-test=ineligible-message]').should('not.exist') + if (taxForm.mozeZiadatVratitDanovyBonusUroky) { + cy.contains( + 'Daňový bonus na zaplatené úroky:', + ) + } - if (input.ziadamVyplatitDanovyBonusUrokPreplatok) { - getInput('ziadamVratitDanovyPreplatok', '-yes').click() - typeToInput('iban', input) - } else { - getInput('ziadamVratitDanovyPreplatok', '-no').click() + if (taxForm.mozeZiadatVratitDanovyPreplatok) { + cy.contains( + 'Daňový preplatok:', + ) } next() From 654db637669e483539e9d9d637c13ddd28e97738 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 15:24:37 +0100 Subject: [PATCH 09/17] remove unnecessary test --- __tests__/testCases/withoutTaxReturnInput.ts | 28 -------------------- 1 file changed, 28 deletions(-) delete mode 100644 __tests__/testCases/withoutTaxReturnInput.ts diff --git a/__tests__/testCases/withoutTaxReturnInput.ts b/__tests__/testCases/withoutTaxReturnInput.ts deleted file mode 100644 index b176e213..00000000 --- a/__tests__/testCases/withoutTaxReturnInput.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { E2eTestUserInput } from '../../src/types/E2eTestUserInput' - -export const withouTaxReturnInput: E2eTestUserInput = { - priloha3_r11_socialne: '1000', - priloha3_r13_zdravotne: '1000', - zaplatenePreddavky: '5000', - r005_meno: 'Fake', - r004_priezvisko: 'Name', - r001_dic: '233123123', - r003_nace: '62010 - Počítačové programovanie', - r007_ulica: 'Mierova', - r008_cislo: '4', - r009_psc: '82105', - r010_obec: 'Bratislava 3', - r011_stat: 'Slovensko', - t1r10_prijmy: '25000', - datum: '22.02.2020', - hasChildren: false, - children: [], - - /** SECTION Danovy preplatok */ - ziadamVyplatitDanovyBonusUrokPreplatok: false, - - expectNgoDonationValue: true, - - percent2: '9,23', - percent3: '15,39', -} From 36bd8c679c770530381e90a86d2b131f953468f2 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 15:29:52 +0100 Subject: [PATCH 10/17] run prettier --- __tests__/iban.test.ts | 7 +++-- cypress/e2e/executeCase.ts | 20 +++--------- src/lib/calculation.ts | 7 +++-- src/lib/routes.ts | 3 +- src/lib/xml/xmlConverter.ts | 6 ++-- src/pages/iban.tsx | 62 +++++++++++++------------------------ src/types/PageUserInputs.ts | 3 +- 7 files changed, 43 insertions(+), 65 deletions(-) diff --git a/__tests__/iban.test.ts b/__tests__/iban.test.ts index 5f5f88de..97adcf3c 100644 --- a/__tests__/iban.test.ts +++ b/__tests__/iban.test.ts @@ -6,7 +6,7 @@ describe('iban', () => { describe('#validate', () => { describe('mozeZiadatVratitPreplatkyBonusyUroky', () => { const taxFormMock = { - mozeZiadatVratitPreplatkyBonusyUroky: true + mozeZiadatVratitPreplatkyBonusyUroky: true, } as TaxForm testValidation(makeValidate(taxFormMock), [ @@ -14,7 +14,10 @@ describe('iban', () => { input: { ziadamVyplatitDanovyBonusUrokPreplatok: undefined }, expected: ['ziadamVyplatitDanovyBonusUrokPreplatok'], }, - { input: { ziadamVyplatitDanovyBonusUrokPreplatok: false }, expected: [] }, + { + input: { ziadamVyplatitDanovyBonusUrokPreplatok: false }, + expected: [], + }, { input: { ziadamVyplatitDanovyBonusUrokPreplatok: true }, expected: ['iban'], diff --git a/cypress/e2e/executeCase.ts b/cypress/e2e/executeCase.ts index 2105c804..eddb212c 100644 --- a/cypress/e2e/executeCase.ts +++ b/cypress/e2e/executeCase.ts @@ -355,13 +355,9 @@ const executeTestCase = (testCase: string) => { /** SECTION IBAN */ assertUrl('/iban') - cy.contains( - 'Žiadam o vyplatenie daňových bonusov alebo preplatkov', - ) + cy.contains('Žiadam o vyplatenie daňových bonusov alebo preplatkov') cy.get('[data-test=ineligible-message]').should('not.exist') - cy.contains( - 'Spolu:', - ) + cy.contains('Spolu:') if (input.ziadamVyplatitDanovyBonusUrokPreplatok) { getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-yes').click() @@ -371,21 +367,15 @@ const executeTestCase = (testCase: string) => { } if (taxForm.mozeZiadatVyplatitDanovyBonus) { - cy.contains( - 'Daňový bonus:', - ) + cy.contains('Daňový bonus:') } if (taxForm.mozeZiadatVratitDanovyBonusUroky) { - cy.contains( - 'Daňový bonus na zaplatené úroky:', - ) + cy.contains('Daňový bonus na zaplatené úroky:') } if (taxForm.mozeZiadatVratitDanovyPreplatok) { - cy.contains( - 'Daňový preplatok:', - ) + cy.contains('Daňový preplatok:') } next() diff --git a/src/lib/calculation.ts b/src/lib/calculation.ts index 7d04a514..2fcb9723 100644 --- a/src/lib/calculation.ts +++ b/src/lib/calculation.ts @@ -733,7 +733,9 @@ export function calculate(input: TaxFormUserInput): TaxForm { return this.r127.gt(0) }, get mozeZiadatVratitPreplatkyBonusyUroky() { - return this.r121.gt(0) || this.r136_danovy_preplatok.gt(0) || this.r127.gt(0) + return ( + this.r121.gt(0) || this.r136_danovy_preplatok.gt(0) || this.r127.gt(0) + ) }, get r127() { return round(Decimal.max(this.r126.minus(this.r118), 0)) @@ -852,7 +854,8 @@ export function calculate(input: TaxFormUserInput): TaxForm { }, /** SECTION Danovy bonus */ - ziadamVyplatitDanovyBonusUrokPreplatok: input?.ziadamVyplatitDanovyBonusUrokPreplatok ?? false, + ziadamVyplatitDanovyBonusUrokPreplatok: + input?.ziadamVyplatitDanovyBonusUrokPreplatok ?? false, iban: input?.iban ? input?.iban.replace(/\s/g, '') : '', datum: input.datum, diff --git a/src/lib/routes.ts b/src/lib/routes.ts index ee308744..98e4257d 100644 --- a/src/lib/routes.ts +++ b/src/lib/routes.ts @@ -29,8 +29,7 @@ export type Route = export const getOrderedRoutes = (taxForm: TaxForm): ReadonlyArray => { const getIbanRoute = (): Route[] => { - const isIbanRequired = - taxForm.mozeZiadatVratitPreplatkyBonusyUroky + const isIbanRequired = taxForm.mozeZiadatVratitPreplatkyBonusyUroky return isIbanRequired ? ['/iban'] : [] } diff --git a/src/lib/xml/xmlConverter.ts b/src/lib/xml/xmlConverter.ts index 6110a13a..1ae4a746 100644 --- a/src/lib/xml/xmlConverter.ts +++ b/src/lib/xml/xmlConverter.ts @@ -214,8 +214,10 @@ export function convertToJson(taxForm: TaxForm): OutputJson { form.dokument.telo.r153 = taxForm.employed || taxForm.dohoda ? '5' : '4' - - if (taxForm.mozeZiadatVratitPreplatkyBonusyUroky && taxForm.ziadamVyplatitDanovyBonusUrokPreplatok) { + if ( + taxForm.mozeZiadatVratitPreplatkyBonusyUroky && + taxForm.ziadamVyplatitDanovyBonusUrokPreplatok + ) { form.dokument.telo.danovyPreplatokBonus.bankovyUcet.IBAN = taxForm.iban form.dokument.telo.danovyPreplatokBonus.datum = taxForm.datum form.dokument.telo.danovyPreplatokBonus.sposobPlatby.ucet = '1' diff --git a/src/pages/iban.tsx b/src/pages/iban.tsx index c7405f61..ad6149ad 100644 --- a/src/pages/iban.tsx +++ b/src/pages/iban.tsx @@ -23,59 +23,41 @@ const Iban: Page = ({ previousRoute, nextRoute, }) => { - const danovyBonus = Number(taxForm.r121); - const danovyBonusUroky = Number(taxForm.r127); - const danovyPreplatok = Number(taxForm.r136_danovy_preplatok); - const spolu = danovyBonus + danovyBonusUroky + danovyPreplatok; + const danovyBonus = Number(taxForm.r121) + const danovyBonusUroky = Number(taxForm.r127) + const danovyPreplatok = Number(taxForm.r136_danovy_preplatok) + const spolu = danovyBonus + danovyBonusUroky + danovyPreplatok const Preplatky = (
{taxForm.mozeZiadatVyplatitDanovyBonus && (
- - Daňový bonus: - -

- {formatCurrency(danovyBonus)} -

+ Daňový bonus: +

{formatCurrency(danovyBonus)}

)} {taxForm.mozeZiadatVratitDanovyBonusUroky && (
- - Daňový bonus na zaplatené úroky: - -

- {formatCurrency(danovyBonusUroky)} -

+ Daňový bonus na zaplatené úroky: +

{formatCurrency(danovyBonusUroky)}

)} {taxForm.mozeZiadatVratitDanovyPreplatok && (
- - Daňový preplatok: - -

- {formatCurrency(danovyPreplatok)} -

+ Daňový preplatok: +

{formatCurrency(danovyPreplatok)}

)} {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && (
- - Spolu: - -

- {formatCurrency(spolu)} -

+ Spolu: +

{formatCurrency(spolu)}

)}
- ); + ) - if ( - !taxForm.mozeZiadatVratitPreplatkyBonusyUroky - ) { + if (!taxForm.mozeZiadatVratitPreplatkyBonusyUroky) { return ( <>

@@ -100,13 +82,12 @@ const Iban: Page = ({ initialValues={taxFormUserInput} validate={makeValidate(taxForm)} onSubmit={(values) => { - const userInput = - values.ziadamVyplatitDanovyBonusUrokPreplatok - ? values - : { - ...taxBonusInitialInput, - ziadamVyplatitDanovyBonusziadamVyplatitDanovyBonus: false, - } + const userInput = values.ziadamVyplatitDanovyBonusUrokPreplatok + ? values + : { + ...taxBonusInitialInput, + ziadamVyplatitDanovyBonusziadamVyplatitDanovyBonus: false, + } setTaxFormUserInput(userInput) router.push(nextRoute) }} @@ -162,7 +143,8 @@ export const makeValidate = taxForm.mozeZiadatVratitPreplatkyBonusyUroky && typeof values.ziadamVyplatitDanovyBonusUrokPreplatok === 'undefined' ) { - errors.ziadamVyplatitDanovyBonusUrokPreplatok = 'Vyznačte odpoveď na daňový bonus alebo preplatok' + errors.ziadamVyplatitDanovyBonusUrokPreplatok = + 'Vyznačte odpoveď na daňový bonus alebo preplatok' } if (values.ziadamVyplatitDanovyBonusUrokPreplatok) { diff --git a/src/types/PageUserInputs.ts b/src/types/PageUserInputs.ts index 4e29e9a6..46f41aba 100644 --- a/src/types/PageUserInputs.ts +++ b/src/types/PageUserInputs.ts @@ -129,8 +129,7 @@ export type TwoPercentUserInput = Pick< export type TaxBonusUserInput = Pick< TaxFormUserInput, - | 'ziadamVyplatitDanovyBonusUrokPreplatok' - | 'iban' + 'ziadamVyplatitDanovyBonusUrokPreplatok' | 'iban' > export type IncomeSourceCountryUserInput = Pick< From 193e0e9aba20227a403a3963e89cf79e7dc9f094 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 15:46:27 +0100 Subject: [PATCH 11/17] form calculator mozeZiadatVratitPreplatkyBonusyUroky --- src/lib/calculation.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/calculation.ts b/src/lib/calculation.ts index 2fcb9723..ef8b745d 100644 --- a/src/lib/calculation.ts +++ b/src/lib/calculation.ts @@ -734,7 +734,7 @@ export function calculate(input: TaxFormUserInput): TaxForm { }, get mozeZiadatVratitPreplatkyBonusyUroky() { return ( - this.r121.gt(0) || this.r136_danovy_preplatok.gt(0) || this.r127.gt(0) + this.mozeZiadatVyplatitDanovyBonus || this.mozeZiadatVratitDanovyPreplatok || this.mozeZiadatVratitDanovyBonusUroky ) }, get r127() { From aa876f010c23e04c110acf4bc829828da943181a Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 16:03:00 +0100 Subject: [PATCH 12/17] rever OutputJson change --- src/types/OutputJson.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/OutputJson.ts b/src/types/OutputJson.ts index 507426e8..4e555128 100644 --- a/src/types/OutputJson.ts +++ b/src/types/OutputJson.ts @@ -488,8 +488,8 @@ export interface BankovyUcet { export interface DanovyPreplatokBonus { vyplatitDanovyBonus: string - vratitDanPreplatok: string vyplatitDanovyBonusUroky: string + vratitDanPreplatok: string sposobPlatby: SposobPlatby bankovyUcet: BankovyUcet datum: string From 55f13b1b9803bd447bd41f68baac4e75d0752262 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 16:07:51 +0100 Subject: [PATCH 13/17] change number calculations to use .plus methods in iban page --- src/pages/iban.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/pages/iban.tsx b/src/pages/iban.tsx index ad6149ad..8287c2d0 100644 --- a/src/pages/iban.tsx +++ b/src/pages/iban.tsx @@ -23,35 +23,37 @@ const Iban: Page = ({ previousRoute, nextRoute, }) => { - const danovyBonus = Number(taxForm.r121) - const danovyBonusUroky = Number(taxForm.r127) - const danovyPreplatok = Number(taxForm.r136_danovy_preplatok) - const spolu = danovyBonus + danovyBonusUroky + danovyPreplatok + const danovyBonus = taxForm.r121 + const danovyBonusUroky = taxForm.r127 + const danovyPreplatok = taxForm.r136_danovy_preplatok + const spolu = danovyBonus + .plus(danovyBonusUroky) + .plus(danovyPreplatok) const Preplatky = (

{taxForm.mozeZiadatVyplatitDanovyBonus && (
Daňový bonus: -

{formatCurrency(danovyBonus)}

+

{formatCurrency(danovyBonus.toNumber())}

)} {taxForm.mozeZiadatVratitDanovyBonusUroky && (
Daňový bonus na zaplatené úroky: -

{formatCurrency(danovyBonusUroky)}

+

{formatCurrency(danovyBonusUroky.toNumber())}

)} {taxForm.mozeZiadatVratitDanovyPreplatok && (
Daňový preplatok: -

{formatCurrency(danovyPreplatok)}

+

{formatCurrency(danovyPreplatok.toNumber())}

)} {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && (
Spolu: -

{formatCurrency(spolu)}

+

{formatCurrency(spolu.toNumber())}

)}
From 6216c4c6f3ca886d0748d6fca6f4cfeae8c61c9f Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 16:11:06 +0100 Subject: [PATCH 14/17] change iban step title --- cypress/e2e/executeCase.ts | 2 +- src/pages/iban.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/e2e/executeCase.ts b/cypress/e2e/executeCase.ts index eddb212c..af9d45ef 100644 --- a/cypress/e2e/executeCase.ts +++ b/cypress/e2e/executeCase.ts @@ -355,7 +355,7 @@ const executeTestCase = (testCase: string) => { /** SECTION IBAN */ assertUrl('/iban') - cy.contains('Žiadam o vyplatenie daňových bonusov alebo preplatkov') + cy.contains('Chcete požiadať o vyplatenie daňových bonusov alebo preplatkov?') cy.get('[data-test=ineligible-message]').should('not.exist') cy.contains('Spolu:') diff --git a/src/pages/iban.tsx b/src/pages/iban.tsx index 8287c2d0..9f2c762c 100644 --- a/src/pages/iban.tsx +++ b/src/pages/iban.tsx @@ -103,7 +103,7 @@ const Iban: Page = ({ {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && ( )} From 3be610c127494a7b1d069c4a9210e12710e69432 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 16:23:31 +0100 Subject: [PATCH 15/17] fix text formatiing --- cypress/e2e/executeCase.ts | 8 ++++---- src/pages/iban.tsx | 36 +++++++++++++++--------------------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/cypress/e2e/executeCase.ts b/cypress/e2e/executeCase.ts index af9d45ef..68b67d1e 100644 --- a/cypress/e2e/executeCase.ts +++ b/cypress/e2e/executeCase.ts @@ -355,7 +355,7 @@ const executeTestCase = (testCase: string) => { /** SECTION IBAN */ assertUrl('/iban') - cy.contains('Chcete požiadať o vyplatenie daňových bonusov alebo preplatkov?') + cy.contains('Chcete požiadať o vyplatenie daňových bonusov alebo preplatkov vo výške') cy.get('[data-test=ineligible-message]').should('not.exist') cy.contains('Spolu:') @@ -367,15 +367,15 @@ const executeTestCase = (testCase: string) => { } if (taxForm.mozeZiadatVyplatitDanovyBonus) { - cy.contains('Daňový bonus:') + cy.contains('Daňový bonus: ') } if (taxForm.mozeZiadatVratitDanovyBonusUroky) { - cy.contains('Daňový bonus na zaplatené úroky:') + cy.contains('Daňový bonus na zaplatené úroky: ') } if (taxForm.mozeZiadatVratitDanovyPreplatok) { - cy.contains('Daňový preplatok:') + cy.contains('Daňový preplatok: ') } next() diff --git a/src/pages/iban.tsx b/src/pages/iban.tsx index 9f2c762c..0b4fbe67 100644 --- a/src/pages/iban.tsx +++ b/src/pages/iban.tsx @@ -31,32 +31,26 @@ const Iban: Page = ({ .plus(danovyPreplatok) const Preplatky = ( -
+
    {taxForm.mozeZiadatVyplatitDanovyBonus && ( -
    - Daňový bonus: -

    {formatCurrency(danovyBonus.toNumber())}

    -
    +
  • + Daňový bonus: + {formatCurrency(danovyBonus.toNumber())} +
  • )} {taxForm.mozeZiadatVratitDanovyBonusUroky && ( -
    - Daňový bonus na zaplatené úroky: -

    {formatCurrency(danovyBonusUroky.toNumber())}

    -
    +
  • + Daňový bonus na zaplatené úroky: + {formatCurrency(danovyBonusUroky.toNumber())} +
  • )} {taxForm.mozeZiadatVratitDanovyPreplatok && ( -
    - Daňový preplatok: -

    {formatCurrency(danovyPreplatok.toNumber())}

    -
    +
  • + Daňový preplatok: + {formatCurrency(danovyPreplatok.toNumber())} +
  • )} - {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && ( -
    - Spolu: -

    {formatCurrency(spolu.toNumber())}

    -
    - )} -
+ ) if (!taxForm.mozeZiadatVratitPreplatkyBonusyUroky) { @@ -103,7 +97,7 @@ const Iban: Page = ({ {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && ( )} From 4aa0426313cc2b38405522b6ce4a6e827cf887d5 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 16:26:12 +0100 Subject: [PATCH 16/17] run prettier --- cypress/e2e/executeCase.ts | 4 +++- src/lib/calculation.ts | 4 +++- src/pages/iban.tsx | 8 ++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/executeCase.ts b/cypress/e2e/executeCase.ts index 68b67d1e..ad1aab2c 100644 --- a/cypress/e2e/executeCase.ts +++ b/cypress/e2e/executeCase.ts @@ -355,7 +355,9 @@ const executeTestCase = (testCase: string) => { /** SECTION IBAN */ assertUrl('/iban') - cy.contains('Chcete požiadať o vyplatenie daňových bonusov alebo preplatkov vo výške') + cy.contains( + 'Chcete požiadať o vyplatenie daňových bonusov alebo preplatkov vo výške', + ) cy.get('[data-test=ineligible-message]').should('not.exist') cy.contains('Spolu:') diff --git a/src/lib/calculation.ts b/src/lib/calculation.ts index ef8b745d..0d10d003 100644 --- a/src/lib/calculation.ts +++ b/src/lib/calculation.ts @@ -734,7 +734,9 @@ export function calculate(input: TaxFormUserInput): TaxForm { }, get mozeZiadatVratitPreplatkyBonusyUroky() { return ( - this.mozeZiadatVyplatitDanovyBonus || this.mozeZiadatVratitDanovyPreplatok || this.mozeZiadatVratitDanovyBonusUroky + this.mozeZiadatVyplatitDanovyBonus || + this.mozeZiadatVratitDanovyPreplatok || + this.mozeZiadatVratitDanovyBonusUroky ) }, get r127() { diff --git a/src/pages/iban.tsx b/src/pages/iban.tsx index 0b4fbe67..41487947 100644 --- a/src/pages/iban.tsx +++ b/src/pages/iban.tsx @@ -26,9 +26,7 @@ const Iban: Page = ({ const danovyBonus = taxForm.r121 const danovyBonusUroky = taxForm.r127 const danovyPreplatok = taxForm.r136_danovy_preplatok - const spolu = danovyBonus - .plus(danovyBonusUroky) - .plus(danovyPreplatok) + const spolu = danovyBonus.plus(danovyBonusUroky).plus(danovyPreplatok) const Preplatky = (
    @@ -97,7 +95,9 @@ const Iban: Page = ({ {taxForm.mozeZiadatVratitPreplatkyBonusyUroky && ( )} From a4677dc2721f8a45bd576d2a3da7108202726458 Mon Sep 17 00:00:00 2001 From: Stefan Sarmir Date: Sat, 16 Nov 2024 16:36:07 +0100 Subject: [PATCH 17/17] update tests --- cypress/e2e/executeCase.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/cypress/e2e/executeCase.ts b/cypress/e2e/executeCase.ts index ad1aab2c..946b51cd 100644 --- a/cypress/e2e/executeCase.ts +++ b/cypress/e2e/executeCase.ts @@ -359,7 +359,6 @@ const executeTestCase = (testCase: string) => { 'Chcete požiadať o vyplatenie daňových bonusov alebo preplatkov vo výške', ) cy.get('[data-test=ineligible-message]').should('not.exist') - cy.contains('Spolu:') if (input.ziadamVyplatitDanovyBonusUrokPreplatok) { getInput('ziadamVyplatitDanovyBonusUrokPreplatok', '-yes').click()