             ben.fixedAmount = ben.amount
         ben
 
+    getOption: (line, optionName) =>
+      line.options.filter((x) -> x.name == optionName)[0]
+
+

      computing.totalSpentAmount = line.payers.sum (x) -> x.amount
      computing.totalFixedAmount = line.beneficiaries.sum (x) -> x.fixedAmount
      computing.totalOffset = line.beneficiaries.sum (x) -> x.offset
      computing.totalMultiply =line.beneficiaries.sum (x) -> x.multiply 
      # save intermediate computation in line
      line.computing = computing
      # return line object
      line

    preprocessLine: (line) => 
      # add beneficiaries from context if none is defined
      unless line.beneficiaries?
        line.beneficiaries = line.context.people.map (name) -> {name: name}
      # compute fixed amount, offset and multiply
      line.beneficiaries = line.beneficiaries.map (ben) ->
        ben.fixedAmount = 0

define ->

  Array::sum = (fn = (x) -> x) ->
    @reduce ((a, b) -> a + fn b), 0

  Array::hasElementMatching = (fn = (x) -> x) ->
    filtered = @filter ((item, i) -> fn item)
    filtered.length > 0

  class Brain

