diff --git a/src/lib/calculation.ts b/src/lib/calculation.ts index 9357d4bd..78473310 100644 --- a/src/lib/calculation.ts +++ b/src/lib/calculation.ts @@ -404,48 +404,19 @@ export function calculate(input: TaxFormUserInput): TaxForm { if (!this.eligibleForChildrenBonus) { return new Decimal(0) } - return new Decimal(this.r117a).plus(this.r117b) - }, - get r117a() { - return this.r034.reduce((previousSum, currentChild) => { - let currentSum = new Decimal(0) - - if (currentChild.m00 || currentChild.m01) { - const rate = getRate(Months.January, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m02) { - const rate = getRate(Months.February, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m03) { - const rate = getRate(Months.March, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m04) { - const rate = getRate(Months.April, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m05) { - const rate = getRate(Months.May, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m06) { - const rate = getRate(Months.June, currentChild) - currentSum = currentSum.plus(rate) - } - - return previousSum.plus(currentSum) - }, new Decimal(0)) - }, - get r117b() { const zakladDane = this.r038.plus(this.r045) const polovicaZakladuDane = zakladDane.times(0.5) const zakladPreBonus = this.r034a && this.r034a.length > 0 ? zakladDane : polovicaZakladuDane - const novyVypocet = [ + return [ + Months.January, + Months.February, + Months.March, + Months.April, + Months.May, + Months.June, Months.July, Months.August, Months.September, @@ -460,7 +431,48 @@ export function calculate(input: TaxFormUserInput): TaxForm { const skutocnyVysledok = this.r034.reduce( (previousSum, currentChild) => { let currentSum = new Decimal(0) - + if ( + currentMonth === Months.January && + (currentChild.m01 || currentChild.m00) + ) { + const rate = getRate(Months.January, currentChild) + currentSum = currentSum.plus(rate) + } + if ( + currentMonth === Months.February && + (currentChild.m02 || currentChild.m00) + ) { + const rate = getRate(Months.February, currentChild) + currentSum = currentSum.plus(rate) + } + if ( + currentMonth === Months.March && + (currentChild.m03 || currentChild.m00) + ) { + const rate = getRate(Months.March, currentChild) + currentSum = currentSum.plus(rate) + } + if ( + currentMonth === Months.April && + (currentChild.m04 || currentChild.m00) + ) { + const rate = getRate(Months.April, currentChild) + currentSum = currentSum.plus(rate) + } + if ( + currentMonth === Months.May && + (currentChild.m05 || currentChild.m00) + ) { + const rate = getRate(Months.May, currentChild) + currentSum = currentSum.plus(rate) + } + if ( + currentMonth === Months.June && + (currentChild.m06 || currentChild.m00) + ) { + const rate = getRate(Months.June, currentChild) + currentSum = currentSum.plus(rate) + } if ( currentMonth === Months.July && (currentChild.m07 || currentChild.m00) @@ -513,10 +525,6 @@ export function calculate(input: TaxFormUserInput): TaxForm { return previusSum.add(vysledok) }, new Decimal(0)) - - const staryVypocet = this.staryVypocetBonusovNaDieta - - return Decimal.max(novyVypocet, staryVypocet) }, get r118() { return Decimal.max(this.r116_dan.minus(this.r117), 0) @@ -651,39 +659,6 @@ export function calculate(input: TaxFormUserInput): TaxForm { } return false }, - - get staryVypocetBonusovNaDieta() { - return this.r034.reduce((previousSum, currentChild) => { - let currentSum = new Decimal(0) - - if (currentChild.m00 || currentChild.m07) { - const rate = getOldRate(Months.July, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m08) { - const rate = getOldRate(Months.August, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m09) { - const rate = getOldRate(Months.September, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m10) { - const rate = getOldRate(Months.October, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m11) { - const rate = getOldRate(Months.November, currentChild) - currentSum = currentSum.plus(rate) - } - if (currentChild.m00 || currentChild.m12) { - const rate = getOldRate(Months.December, currentChild) - currentSum = currentSum.plus(rate) - } - - return previousSum.plus(currentSum) - }, new Decimal(0)) - }, } } @@ -716,39 +691,9 @@ const getRate = (month: number, child) => { month - 1, ) - const isUnderSix = age < 6 - const isUnderFifteen = age < 15 - if (month <= Months.June) { - if (isUnderSix) { - return new Decimal(CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY) - } else { - return isUnderFifteen - ? new Decimal(CHILD_RATE_OVER_SIX_UNTIL_JULY) - : new Decimal(CHILD_RATE_FIFTEEN_AND_OLDER_UNTIL_JULY) - } - } else { - return isUnderFifteen - ? new Decimal(CHILD_RATE_FIFTEEN_AND_YOUNGER_FROM_JULY) - : new Decimal(CHILD_RATE_FIFTEEN_AND_OLDER_FROM_JULY) - } -} - -const getOldRate = (month: number, child) => { - const age = getRodneCisloAgeAtYearAndMonth( - child.rodneCislo, - TAX_YEAR, - month - 1, - ) - - const isUnderSix = age < 6 - const isUnderFifteen = age < 15 - - if (isUnderSix) { - return new Decimal(CHILD_RATE_SIX_AND_YOUNGER_UNTIL_JULY) - } - return isUnderFifteen - ? new Decimal(CHILD_RATE_OVER_SIX_UNTIL_JULY) - : new Decimal(CHILD_RATE_FIFTEEN_AND_OLDER_UNTIL_JULY) + return age < 18 + ? new Decimal(CHILD_RATE_EIGHTEEN_AND_YOUNGER) + : new Decimal(CHILD_RATE_EIGHTEEN_AND_OLDER) } const getPocetDetivMesiaci = (deti: TaxForm['r034'], month: Months): number => { diff --git a/src/lib/xml/xmlConverter.ts b/src/lib/xml/xmlConverter.ts index 0c23d4d8..768ac884 100644 --- a/src/lib/xml/xmlConverter.ts +++ b/src/lib/xml/xmlConverter.ts @@ -132,8 +132,6 @@ export function convertToJson(taxForm: TaxForm): OutputJson { form.dokument.telo.r115 = '0.00' form.dokument.telo.r116 = roundDecimal(taxForm.r116_dan) form.dokument.telo.r117 = decimalToString(taxForm.r117) - form.dokument.telo.r117a = decimalToString(taxForm.r117a) - form.dokument.telo.r117b = decimalToString(taxForm.r117b) form.dokument.telo.r118 = roundDecimal(taxForm.r118) form.dokument.telo.r119 = decimalToString(taxForm.r119) diff --git a/src/types/OutputJson.ts b/src/types/OutputJson.ts index ad4fe7f8..421078a1 100644 --- a/src/types/OutputJson.ts +++ b/src/types/OutputJson.ts @@ -689,8 +689,6 @@ export interface Telo { r115: string r116: string r117: string - r117a: string - r117b: string r118: string r119: string r120: string diff --git a/src/types/TaxForm.ts b/src/types/TaxForm.ts index ba8b9b61..226a1ce9 100644 --- a/src/types/TaxForm.ts +++ b/src/types/TaxForm.ts @@ -147,15 +147,6 @@ export interface TaxForm { /** Nárok na daňový bonus (na jedno dieťa alebo úhrn na viac vyživovaných detí) podľa § 33 zákona 22) */ r117: Decimal - /** - * Nárok na daňový bonus nárok za január až jún 2022 - */ - r117a: Decimal - /** - * Nárok na daňový bonus nárok za júl až december 2022 - */ - r117b: Decimal - /** Daň (daňová povinnosť) znížená o daňový bonus (r. 105 - r. 106) Zrkadlenie * r081*/ r118: Decimal @@ -218,10 +209,4 @@ export interface TaxForm { XIIoddiel_uplatnujem2percenta: boolean eligibleForChildrenBonus: boolean canDonateTwoPercentOfTax: boolean - - /** - * Pre druhu polovicu roka 2022 sa pouzivaju dva vypocty bonusu na dieta. - * Danovnik si moze uplatnit sumu podla vypoctu ktory je pre neho vyhodnejsi - */ - staryVypocetBonusovNaDieta: Decimal }