Skip to content

Instantly share code, notes, and snippets.

@adamrneary
Created August 8, 2013 21:43
Show Gist options
  • Save adamrneary/6189053 to your computer and use it in GitHub Desktop.
Save adamrneary/6189053 to your computer and use it in GitHub Desktop.
calculate: (periodId) =>
r =
periodUnix: app.periods.idToUnix(periodId)
beginningCash: @get(app.periods.prevId(periodId))?.endingCash
if app.periods.notPast(periodId)
s = app.scenario.toJSON()
keys = ['revenue', 'cogs', 'custAcq', 'team', 'vendor']
_.each keys, (key) =>
days = if key is 'custAcq' then s.cust_acq_days else s["#{key}_days"]
val = @_periodCash periodId, (days ? 0), "#{key}Plan"
multiplier = if key is 'custAcq'
s.cust_acq_multiplier
else s["#{key}_multiplier"]
val *= (1 + (multiplier ? 0)/100)
r["#{key}Plan"] = val
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment