Created
March 3, 2020 13:04
-
-
Save Cussa/0394b0f5a5e522b17f1dae60b1bcde63 to your computer and use it in GitHub Desktop.
Evitando código duplicado
This file contains hidden or 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
public class ImpostosNotaFiscal | |
{ | |
public decimal CalcularValorLiquido(decimal valorNotaFiscal) | |
{ | |
var impostoPis = CalcularPis(valorNotaFiscal); | |
var impostoCofins = CalcularCofins(valorNotaFiscal); | |
var impostoIrpj = CalcularIrpj(valorNotaFiscal); | |
var impostoCsll = CalcularCsll(valorNotaFiscal); | |
var impostos = impostoPis + impostoCofins + impostoIrpj + impostoCsll; | |
return valorNotaFiscal - impostos; | |
} | |
public decimal CalcularImpostos(decimal valorNotaFiscal) | |
{ | |
var impostoPis = CalcularPis(valorNotaFiscal); | |
var impostoCofins = CalcularCofins(valorNotaFiscal); | |
var impostoIrpj = CalcularIrpj(valorNotaFiscal); | |
var impostoCsll = CalcularCsll(valorNotaFiscal); | |
return impostoPis + impostoCofins + impostoIrpj + impostoCsll; | |
} | |
public decimal CalcularPis(decimal valorNotaFiscal) | |
{ | |
var taxaImposto = 1.65M; | |
return valorNotaFiscal * taxaImposto / 100; | |
} | |
public decimal CalcularCofins(decimal valorNotaFiscal) | |
{ | |
var taxaImposto = 7.6M; | |
return valorNotaFiscal * taxaImposto / 100; | |
} | |
public decimal CalcularIrpj(decimal valorNotaFiscal) | |
{ | |
var taxaImposto = 15M; | |
return valorNotaFiscal * taxaImposto / 100; | |
} | |
public decimal CalcularCsll(decimal valorNotaFiscal) | |
{ | |
var taxaImposto = 9M; | |
return valorNotaFiscal * taxaImposto / 100; | |
} | |
} |
This file contains hidden or 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
public class ImpostosNotaFiscal | |
{ | |
public decimal CalcularValorLiquido(decimal valorNotaFiscal) | |
{ | |
return valorNotaFiscal - CalcularImpostos(valorNotaFiscal); | |
} | |
public decimal CalcularImpostos(decimal valorNotaFiscal) | |
{ | |
var impostoPis = CalcularPis(valorNotaFiscal); | |
var impostoCofins = CalcularCofins(valorNotaFiscal); | |
var impostoIrpj = CalcularIrpj(valorNotaFiscal); | |
var impostoCsll = CalcularCsll(valorNotaFiscal); | |
return impostoPis + impostoCofins + impostoIrpj + impostoCsll; | |
} | |
public decimal CalcularPis(decimal valorNotaFiscal) | |
{ | |
var taxaImposto = 1.65M; | |
return valorNotaFiscal * taxaImposto / 100; | |
} | |
public decimal CalcularCofins(decimal valorNotaFiscal) | |
{ | |
var taxaImposto = 7.6M; | |
return valorNotaFiscal * taxaImposto / 100; | |
} | |
public decimal CalcularIrpj(decimal valorNotaFiscal) | |
{ | |
var taxaImposto = 15M; | |
return valorNotaFiscal * taxaImposto / 100; | |
} | |
public decimal CalcularCsll(decimal valorNotaFiscal) | |
{ | |
var taxaImposto = 9M; | |
return valorNotaFiscal * taxaImposto / 100; | |
} | |
} |
This file contains hidden or 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
public class ImpostosNotaFiscal | |
{ | |
public decimal CalcularValorLiquido(decimal valorNotaFiscal) | |
{ | |
return valorNotaFiscal - CalcularImpostos(valorNotaFiscal); | |
} | |
public decimal CalcularImpostos(decimal valorNotaFiscal) | |
{ | |
var impostoPis = CalcularPis(valorNotaFiscal); | |
var impostoCofins = CalcularCofins(valorNotaFiscal); | |
var impostoIrpj = CalcularIrpj(valorNotaFiscal); | |
var impostoCsll = CalcularCsll(valorNotaFiscal); | |
return impostoPis + impostoCofins + impostoIrpj + impostoCsll; | |
} | |
public decimal CalcularPis(decimal valorNotaFiscal) | |
{ | |
return CalcularImposto(valorNotaFiscal, 1.65M); | |
} | |
public decimal CalcularCofins(decimal valorNotaFiscal) | |
{ | |
return CalcularImposto(valorNotaFiscal, 7.6M); | |
} | |
public decimal CalcularIrpj(decimal valorNotaFiscal) | |
{ | |
return CalcularImposto(valorNotaFiscal, 15M); | |
} | |
public decimal CalcularCsll(decimal valorNotaFiscal) | |
{ | |
return CalcularImposto(valorNotaFiscal, 9M); | |
} | |
public decimal CalcularImposto(decimal valorNotaFiscal, decimal taxaImposto) | |
{ | |
return valorNotaFiscal * taxaImposto / 100; | |
} | |
} |
This file contains hidden or 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
public class ImpostosNotaFiscal | |
{ | |
public decimal CalcularValorLiquido(decimal valorNotaFiscal) | |
=> valorNotaFiscal - CalcularImpostos(valorNotaFiscal); | |
public decimal CalcularImpostos(decimal valorNotaFiscal) | |
{ | |
var impostoPis = CalcularPis(valorNotaFiscal); | |
var impostoCofins = CalcularCofins(valorNotaFiscal); | |
var impostoIrpj = CalcularIrpj(valorNotaFiscal); | |
var impostoCsll = CalcularCsll(valorNotaFiscal); | |
return impostoPis + impostoCofins + impostoIrpj + impostoCsll; | |
} | |
public decimal CalcularPis(decimal valorNotaFiscal) | |
=> CalcularImposto(valorNotaFiscal, 1.65M); | |
public decimal CalcularCofins(decimal valorNotaFiscal) | |
=> CalcularImposto(valorNotaFiscal, 7.6M); | |
public decimal CalcularIrpj(decimal valorNotaFiscal) | |
=> CalcularImposto(valorNotaFiscal, 15M); | |
public decimal CalcularCsll(decimal valorNotaFiscal) | |
=> CalcularImposto(valorNotaFiscal, 9M); | |
public decimal CalcularImposto(decimal valorNotaFiscal, decimal taxaImposto) | |
=> valorNotaFiscal * taxaImposto / 100; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment