Thursday, 4 September 2014

conditional multiplication of rates as per increase count

What is best approach and coding practice for my below requirements:
As I have user records in my table, and I want to charge user as per conditional basis
Condition is, If user has 20 record then system will charge by 500 USD per record If user has 30 record then System will charge then system will charge 500 USD per record for 20 records and 300 USD for next 10 records also If user has more than 30 records then charges then calculation will be (20 * 500 + 10 * 300 + addition-records * 100 )

Record Table

Post(:id, :content, :user_id)

I have also subscription table where I manage charges
I will appreciate If coders will uses constant for static values, like
$ {1 to 20 => 500, 20 to 30 => 300, 30 to x => 100 } ...etc

No comments:

Post a Comment