Skip to content

Instantly share code, notes, and snippets.

@pedrozath
Created November 6, 2012 19:10
Show Gist options
  • Save pedrozath/4026796 to your computer and use it in GitHub Desktop.
Save pedrozath/4026796 to your computer and use it in GitHub Desktop.
Calculo Preços Mandic
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