Skip to content

Instantly share code, notes, and snippets.

@8vius
Created September 2, 2015 17:39
Show Gist options
  • Save 8vius/0286739e40af0c19b0e4 to your computer and use it in GitHub Desktop.
Save 8vius/0286739e40af0c19b0e4 to your computer and use it in GitHub Desktop.
calculateTotal = (perception) ->
total = perception.taxedAmount + perception.exemptAmount
total.toFixed(2)
perceptionFields = ->
scope: true
require: "^payrollItems"
link: (scope, _element, attrs, ctrl) ->
scope.perception = { total: "0.00" }
scope.firstItem = (angular.element("perception-fields").length == 1)
scope.updateTotal = ->
if scope.perception.taxedAmount && scope.perception.exemptAmount
scope.perception.total = calculateTotal(scope.perception)
ctrl.updateTotals()
scope.removePerception = ->
ctrl.removePerception(scope.perception)
ctrl.updateTotals()
ctrl.registerPerception(scope.perception)
angular.module("app.invoices").directive("perceptionFields", perceptionFields)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment