Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bettysteger committed Feb 29, 2024
1 parent bd9049f commit ad89d12
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
20 changes: 19 additions & 1 deletion tests/est.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { einkommensteuer, freibetragValues, investGewinnfreibetrag } from "../src/est";
import { einkommensteuer, freibetragValues, investGewinnfreibetrag } from '../src/est.js';

test('should return 0 for 0-11693 income', () => {
expect(einkommensteuer(0, 2024)).toBe(0);
Expand Down Expand Up @@ -51,6 +51,24 @@ test('should return correct ESt for all levels in 2022', () => {
});
});

test('should return correct ESt for all levels + 1€ in 2024', () => {
const limits = [11693, 19134, 32075, 62080, 93120, 1000000];
const percentages = [0, 0.2, 0.3, 0.4, 0.48, 0.5, 0.55];
const levels = limits.map((limit, index) => {
return {
amount: limit,
est: (limit - (index > 0 ? limits[index-1] : 0)) * percentages[index],
pct: percentages[index]
};
});
levels.forEach((level, i) => { level.est += (levels[i-1] ? levels[i-1].est : 0); });
levels.forEach((level, i) => {
expect(Math.round(einkommensteuer(level.amount + 1, 2024))).toBe(Math.round(
level.est + (levels[i+1] ? levels[i+1].pct : level.pct) // 1€ = next percentage
));
});
});

// Maximalausmaß von 46.400 EUR
// @see https://www.wko.at/steuern/der-gewinnfreibetrag
test('should return correct investGewinnfreibetrag for 2024', () => {
Expand Down
27 changes: 27 additions & 0 deletions tests/sv.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { SVbeitrag } from '../src/sv.js';
import { fixValues, percentages } from '../src/sv-values.js';

// Wenn Sie weniger als 6.221,28 € Gewinn pro Jahr selbstständig erzielen, können Sie
// sich bei der SVA von der Kranken- und Pensionsversicherung ausnehmen lassen.
// Sie bezahlen dann für Ihre Selbstständigkeit nur mehr die Unfallversicherung.
test('should return minimum SV-Beitrag if profit is smaller than the current year limit', () => {
const year = 2024;
const options = { year, tipps: new Set() };
expect(SVbeitrag(fixValues[year].limit - 1, options).toPay).toBe(fixValues[year].uv * 12); // 12 months Unfallversicherung
expect(options.tipps.has('EXCLUDE_KV_PV')).toBe(true);
});

test('should return SV-Beitrag for the founding year', () => {
const year = 2024;
const months = 10;
const options = { year, foundingYear: year, foundingMonth: 3, tipps: new Set() };
const { limit, uv, kvMinBeitragsgrundlage, pvMinBeitragsgrundlage, svsMinBeitragsgrundlage } = fixValues[year];
const profitOnEStBescheid = limit;

expect(SVbeitrag(profitOnEStBescheid, options).toPay).toBeCloseTo((
uv +
kvMinBeitragsgrundlage * percentages[year].kv +
pvMinBeitragsgrundlage * percentages[year].pv +
svsMinBeitragsgrundlage * percentages.vorsorge
) * months);
});
4 changes: 2 additions & 2 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import hundert11 from "../src/index.js";
import { fixValues } from "../src/sv-values.js";
import hundert11 from '../src/index.js';
import { fixValues } from '../src/sv-values.js';

// Wenn man weniger als 5.710,32 € Gewinn pro Jahr erzielt, kann man
// sich bei der SVA von der KV+PV ausnehmen lassen. Man bezahlt dann nur die UV.
Expand Down

0 comments on commit ad89d12

Please sign in to comment.