Skip to content

Commit

Permalink
run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
stevo95 committed Nov 16, 2024
1 parent 654db63 commit 36bd8c6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 65 deletions.
7 changes: 5 additions & 2 deletions __tests__/iban.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ describe('iban', () => {
describe('#validate', () => {
describe('mozeZiadatVratitPreplatkyBonusyUroky', () => {
const taxFormMock = {
mozeZiadatVratitPreplatkyBonusyUroky: true
mozeZiadatVratitPreplatkyBonusyUroky: true,
} as TaxForm

testValidation(makeValidate(taxFormMock), [
{
input: { ziadamVyplatitDanovyBonusUrokPreplatok: undefined },
expected: ['ziadamVyplatitDanovyBonusUrokPreplatok'],
},
{ input: { ziadamVyplatitDanovyBonusUrokPreplatok: false }, expected: [] },
{
input: { ziadamVyplatitDanovyBonusUrokPreplatok: false },
expected: [],
},
{
input: { ziadamVyplatitDanovyBonusUrokPreplatok: true },
expected: ['iban'],
Expand Down
20 changes: 5 additions & 15 deletions cypress/e2e/executeCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
7 changes: 5 additions & 2 deletions src/lib/calculation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions src/lib/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export type Route =

export const getOrderedRoutes = (taxForm: TaxForm): ReadonlyArray<Route> => {
const getIbanRoute = (): Route[] => {
const isIbanRequired =
taxForm.mozeZiadatVratitPreplatkyBonusyUroky
const isIbanRequired = taxForm.mozeZiadatVratitPreplatkyBonusyUroky
return isIbanRequired ? ['/iban'] : []
}

Expand Down
6 changes: 4 additions & 2 deletions src/lib/xml/xmlConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
62 changes: 22 additions & 40 deletions src/pages/iban.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,59 +23,41 @@ const Iban: Page<TaxBonusUserInput> = ({
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 = (
<section>
{taxForm.mozeZiadatVyplatitDanovyBonus && (
<div>
<strong>
Daňový bonus:
</strong>
<p>
{formatCurrency(danovyBonus)}
</p>
<strong>Daňový bonus:</strong>
<p>{formatCurrency(danovyBonus)}</p>
</div>
)}
{taxForm.mozeZiadatVratitDanovyBonusUroky && (
<div>
<strong>
Daňový bonus na zaplatené úroky:
</strong>
<p>
{formatCurrency(danovyBonusUroky)}
</p>
<strong>Daňový bonus na zaplatené úroky:</strong>
<p>{formatCurrency(danovyBonusUroky)}</p>
</div>
)}
{taxForm.mozeZiadatVratitDanovyPreplatok && (
<div>
<strong>
Daňový preplatok:
</strong>
<p>
{formatCurrency(danovyPreplatok)}
</p>
<strong>Daňový preplatok:</strong>
<p>{formatCurrency(danovyPreplatok)}</p>
</div>
)}
{taxForm.mozeZiadatVratitPreplatkyBonusyUroky && (
<div>
<strong>
Spolu:
</strong>
<p>
{formatCurrency(spolu)}
</p>
<strong>Spolu:</strong>
<p>{formatCurrency(spolu)}</p>
</div>
)}
</section>
);
)

if (
!taxForm.mozeZiadatVratitPreplatkyBonusyUroky
) {
if (!taxForm.mozeZiadatVratitPreplatkyBonusyUroky) {
return (
<>
<p data-test="ineligible-message">
Expand All @@ -100,13 +82,12 @@ const Iban: Page<TaxBonusUserInput> = ({
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)
}}
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions src/types/PageUserInputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ export type TwoPercentUserInput = Pick<

export type TaxBonusUserInput = Pick<
TaxFormUserInput,
| 'ziadamVyplatitDanovyBonusUrokPreplatok'
| 'iban'
'ziadamVyplatitDanovyBonusUrokPreplatok' | 'iban'
>

export type IncomeSourceCountryUserInput = Pick<
Expand Down

0 comments on commit 36bd8c6

Please sign in to comment.