Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upozorni danovnika na preddavky init #794

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/lib/calculation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ export const CHILD_RATE_FIFTEEN_AND_OLDER_FROM_JULY = 40

const ZIVOTNE_MINIMUM_44_NASOBOK = 9638.25

export const SPODNA_ZADZBA_PRE_PREDDAVKY = 5000
export const VRCHNA_ZADZBA_PRE_PREDDAVKY = 16600

const POCET_KVARTALOV = 4
const POCET_MESIACOV = 12

// 63,4-násobok platného životného minima
const ZVYHODNENIE_NA_PARTNERA = 13_825
export const TAX_YEAR = 2022
Expand Down Expand Up @@ -705,6 +711,7 @@ export function buildSummary(form: TaxForm): Summary {
zakladDane: form.r080_zaklad_dane_celkovo,
danovyPreplatok: form.r136_danovy_preplatok,
danNaUhradu: form.r135_dan_na_uhradu,
zaplatenePreddavky: form.r133,
}
}

Expand Down Expand Up @@ -903,3 +910,11 @@ export const monthKeyValues = (months: string[]): optionWithValue[] => {
export const donateOnly3Percent = (form: TaxForm): boolean => {
return form.canDonateTwoPercentOfTax && (form.suma_2_percenta.toNumber() < MIN_2_PERCENT_CALCULATED_DONATION)
}

export const countPreddavky = (form: TaxForm): Number => {
if (Number(form.r135_dan_na_uhradu) > VRCHNA_ZADZBA_PRE_PREDDAVKY) {
return Number(round((form.r055.mul(DAN_Z_PRIJMU_SADZBA).div(POCET_MESIACOV))))
} else if (Number(form.r135_dan_na_uhradu) > SPODNA_ZADZBA_PRE_PREDDAVKY) {
return Number(round((form.r055.mul(DAN_Z_PRIJMU_SADZBA).div(POCET_KVARTALOV))))
}
}
62 changes: 61 additions & 1 deletion src/pages/vysledky.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import React from 'react'
import { formatCurrency } from '../lib/utils'
import { TaxFormUserInput } from '../types/TaxFormUserInput'
import { Page } from '../components/Page'
import { Warning } from '../components/Warning'
import Decimal from 'decimal.js'
import { BackLink } from '../components/BackLink'
import Link from 'next/link'
import { buildSummary } from '../lib/calculation'
import { TAX_YEAR } from '../lib/calculation'
import { countPreddavky } from '../lib/calculation'
import {
TAX_YEAR,
SPODNA_ZADZBA_PRE_PREDDAVKY,
VRCHNA_ZADZBA_PRE_PREDDAVKY,
} from '../lib/calculation'


interface SummaryRow {
key: string
Expand Down Expand Up @@ -114,6 +121,58 @@ const Vysledky: Page<Partial<TaxFormUserInput>> = ({
},
]

if (Number(summary.danNaUhradu) > VRCHNA_ZADZBA_PRE_PREDDAVKY && Number(summary.zaplatenePreddavky) == 0) {
return (
<>
<BackLink href={previousRoute} />
<h1 className="govuk-heading-l govuk-!-margin-top-3">
{`Výpočet dane za rok ${TAX_YEAR}`}
</h1>
<h2 className="govuk-heading-m govuk-!-margin-top-3">Stručný prehľad</h2>
<Summary rows={summaryRows} />
<Warning>
<p>
Tvoja daň presiahla limit platcu preddavkov na daň. Pre viac informácií navštív web <a href="https://www.financnasprava.sk/sk/elektronicke-sluzby/verejne-sluzby/danove-kalkulacky/vypocet-preddavkov-fo-2023">Finančnej správy</a>. Od dalšieho roka môžeš očakávať mesačné preddavky na daň. Finančná správa by ťa mala na tento fakt upozorniť. Očakávaj preddavky približne {countPreddavky(taxForm)} € každý mesiac. Výpočet má informatívny charakter.
</p>
</Warning>
MarekVigas marked this conversation as resolved.
Show resolved Hide resolved
<Link href={nextRoute} legacyBehavior>
<button
data-test="next"
className="govuk-button govuk-!-margin-top-3"
type="submit"
>
Pokračovať
</button>
</Link>
</>
)
} else if (Number(summary.danNaUhradu) > SPODNA_ZADZBA_PRE_PREDDAVKY && Number(summary.zaplatenePreddavky) == 0) {
MarekVigas marked this conversation as resolved.
Show resolved Hide resolved
return (
<>
<BackLink href={previousRoute} />
<h1 className="govuk-heading-l govuk-!-margin-top-3">
{`Výpočet dane za rok ${TAX_YEAR}`}
</h1>
<h2 className="govuk-heading-m govuk-!-margin-top-3">Stručný prehľad</h2>
<Summary rows={summaryRows} />
<Warning>
<p>
Tvoja daň presiahla limit platcu preddavkov na daň. Pre viac informácií navštív web <a href="https://www.financnasprava.sk/sk/elektronicke-sluzby/verejne-sluzby/danove-kalkulacky/vypocet-preddavkov-fo-2023">Finančnej správy</a>. Od dalšieho roka môžeš očakávať kvartálne preddavky na daň. Finančná správa by ťa mala upozorniť na tento fakt. Očakávaj preddavky približne {countPreddavky(taxForm)} € každý kvartál. Výpočet má informatívny charakter.
</p>
</Warning>
<Link href={nextRoute} legacyBehavior>
<button
data-test="next"
className="govuk-button govuk-!-margin-top-3"
type="submit"
>
Pokračovať
</button>
</Link>
</>
)
}

return (
<>
<BackLink href={previousRoute} />
Expand All @@ -122,6 +181,7 @@ const Vysledky: Page<Partial<TaxFormUserInput>> = ({
</h1>
<h2 className="govuk-heading-m govuk-!-margin-top-3">Stručný prehľad</h2>
<Summary rows={summaryRows} />

<Link href={nextRoute} legacyBehavior>
<button
data-test="next"
Expand Down
1 change: 1 addition & 0 deletions src/types/Summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ export interface Summary {
zakladDane: Decimal
danovyPreplatok: Decimal
danNaUhradu: Decimal
zaplatenePreddavky: Decimal
}
Loading