Created
October 4, 2011 02:38
-
-
Save ngmaloney/1260782 to your computer and use it in GitHub Desktop.
RetentionCalculator
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
function retentionCalculator(opts) { | |
var opts = opts || {}; | |
this.init = function(opts) { | |
this.price = opts.price || 300; //Product Price | |
this.margin = opts.margin || 0.085; //Profit Margin | |
this.cost = opts.cost || 0; //Retention Cost | |
this.lifetime = opts.lifetime || 3; //Product Lifetime | |
this.inflation = opts.inflation || 0.05; //Inflation Rate | |
this.network = opts.network || 100; //Network Size | |
this.influence = opts.influence || 0.01; //Network Conversion Influence | |
this.duration = opts.duration || 5; //Customer Duration | |
} | |
this.annual_customer_revenue = function() { | |
return parseFloat(((this.price - this.cost) / this.lifetime) * this.margin).toFixed(2); | |
} | |
this.lifetime_customer_revenue = function() { | |
return parseFloat(this.annual_customer_revenue() * this.duration * (1 + this.inflation)).toFixed(2); | |
} | |
this.lifetime_customer_revenu = function() { | |
return parseFloat(this.annual_customer_revenue() * this.duration * (1 + this.inflation)).toFixed(2); | |
} | |
this.annual_network_revenue = function() { | |
return parseFloat(this.annual_customer_revenue() * this.network * this.influence).toFixed(2); | |
} | |
this.lifetime_network_revenue = function() { | |
return parseFloat(this.annual_network_revenue() * this.duration * (1 + this.inflation)).toFixed(2); | |
} | |
this.init(opts); | |
return this; | |
} | |
var dishwasher = { | |
price: 500, | |
margin: 0.1, | |
cost: 100, | |
lifetime: 5, | |
duration: 10 | |
} | |
var rc = retentionCalculator(dishwasher); | |
console.log(rc.annual_customer_revenue()); | |
console.log(rc.lifetime_customer_revenue()); | |
console.log(rc.annual_network_revenue()); | |
console.log(rc.lifetime_network_revenue()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment