Last active
July 31, 2020 01:02
-
-
Save mpelos/4e36de78671c336907c4f703aaa66f2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Main = () => { | |
... | |
const salaryCalculate = new SalaryCalculator(); | |
const salary = salaryCalculate.calculate(grossSalary); | |
return ( | |
... | |
<LisResult | |
inss={salary.inss} | |
irpf={salary.irpf} | |
salary={salary.grossSalary} | |
discounts={salary.seiLaOqEisso} | |
netSalary={salary.netSalary} | |
/> | |
... | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { inssSections } from 'algum-lugar'; | |
import { irpfSections } from 'outro-lugar'; | |
class SalaryCalculator { | |
calculate(salary) { | |
// calcula a porra toda de uma vez | |
return new Salary({ | |
grossSalary: salary, | |
irpf: this.calculateIrpf(salary), | |
inss: this.calculateInss(salary), | |
netSalary: this.calculateNetSalary(salary), | |
}); | |
} | |
calculateIrpf(salary) { | |
// faça uso dos seus métodos internos para calcular caso seja necessário | |
} | |
calculateInss(salary) { | |
// faça uso dos seus métodos internos para calcular caso seja necessário | |
} | |
calculateNetSalary(salary) { | |
// faça uso dos seus métodos internos para calcular caso seja necessário | |
} | |
calculateInssSection(salary) { | |
// faça uso dos seus métodos internos para calcular caso seja necessário | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Salary { | |
constructor({ grossSalary, inss, irpf, netSalary }) { | |
this.grossSalary = grossSalary; | |
this.inss = inss; | |
this.irpf = irpf; | |
this.netSalary = netSalary; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment