php - Calculate new subscription cost on upgrade / downgrade -
i developing subscription system web application. need regarding approach new subscription costs when user decides downgrade or upgrade account.
i created image make example of user keeps changing levels.
a user can choose pay each month, quarter or year.
i want add discount when user decides downgrade. discount factored new cost using formula:
[final plan cost] = [new plan cost] * 12 - [discount] / [12 - month / 3 - quarter / 1 - year]
if have user keeps changing plans this, how can calculate discount dynamically? it's easy 1 change - can take difference between 2 plans , multiply each payment made before. need regarding approach several changes, , how can keep track of discount.
i think should put information in database table , call cells. if user @ plan getting discount based on sub; eg if(price this) discount {discount value database} x price of subscription.. not have worry if changes subscription in middle of month, have put information in different table , @ end of month application apply new subscription , calculations. not hard approach..
Comments
Post a Comment