Nested Helper calculations


#1

I defined the following helper to allow a template to display just the table count, the total cost of the marquee plus tables and chairs as well as things like just the seating price component of that total.

However in my template {{costs.tableCount}} renders as NaN. But rendered the proper amount when I make tableCount it’s own helper.

Have I got my syntax wrong? Is there no way to keep my helpers modular and DRY for simple calculations like this?

costs: (marqueePrice) ->

	@tableCost = () ->
		if Session.get('result.seating') == 'trestleCount' then Meteor.settings.public.TRESTLE_TABLE_UNIT_COST else Meteor.settings.public.ROUND_TABLE_UNIT_COST

	@tableCount= () ->
		Math.ceil Session.get('result.attendees')/(if Session.get('result.seating') == 'trestleCapacity' then Meteor.settings.public.TRESTLE_TABLE_CAPACITY else Meteor.settings.public.ROUND_TABLE_CAPACITY)

	@chairs= Session.get('result.attendees') * Meteor.settings.public.CHAIR_UNIT_COST
	@tables= @tableCount() * @tableCost()
	@seating= @chairs + @tables
	@total= marqueePrice + @seating