Created
November 6, 2012 19:10
-
-
Save pedrozath/4026796 to your computer and use it in GitHub Desktop.
Calculo Preços Mandic
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
require "json" | |
@descontos = { | |
trimestral: 5.0/100, | |
semestral: 10.0/100, | |
anual: 15.0/100, | |
} | |
def descontar(preco, periodo) | |
(preco*(1-@descontos[periodo]))/2 | |
end | |
precos = [ | |
{mensal:{de:127.50}}, | |
{mensal:{de:217.50}}, | |
{mensal:{de:397.50}}, | |
{mensal:{de:757.75}} | |
] | |
for preco in precos do | |
preco[:mensal][:por] = preco[:mensal][:de]/2 | |
for periodo in [:trimestral, :semestral, :anual] do | |
preco[periodo] = { | |
de: (preco[:mensal][:de]*3) , | |
por: (descontar preco[:mensal][:de]*3, periodo) | |
} | |
end | |
puts preco.to_json | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment