function calculate(salary: number): { net: number, tax: number } {
const rates: any = {
socialContributionTax: {
type: 'gross',
rate: 0.155,// 15.5%
partOfGross: false
},
vocationalTrainingContribution: {
type: 'gross',
rate: 0.015,// 1.5%
partOfGross: false
},
personalIncomeTax: {
type: 'gross',
rate: 0.15,// 15%
partOfGross: true
},
socialInsuranceTax: {
type: 'gross',
rate: 0.185,// 18.5%
partOfGross: true
},
}
const p = parseFloat(Object.keys(rates)
.map(k => rates[k])
.filter(i => i.partOfGross === false)
.map(i => i.rate)
.reduce((a,b) => a + b, 0)
.toFixed(2))
const gross = simplify(salary / (1 + p))
const tax = Object.keys(rates)
.map(k => simplify(rates[k].rate * gross))
.reduce((a,b) => a + b, 0)
const net = salary - tax
return {
net,
tax
}
}
function simplify(n: number): number {
return Math.floor(parseFloat(n.toFixed(2)) + 0.5)
}
-
Notifications
You must be signed in to change notification settings - Fork 0
peterszombati/taxation-in-hungary
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description or website provided.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published