mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-26 20:56:48 +00:00
NOTE: Moved estimatedSubtotal and estimatedTotal functions to the new factory from the subscription line items controller
13 lines
473 B
CoffeeScript
13 lines
473 B
CoffeeScript
# Provides additional auxillary functions to instances of SubsciptionResource
|
|
# Used to extend the prototype of the subscription resource created by SubscriptionResource
|
|
|
|
angular.module("admin.subscriptions").factory 'SubscriptionFunctions', ->
|
|
estimatedSubtotal: ->
|
|
@subscription_line_items.reduce (subtotal, item) ->
|
|
return subtotal if item._destroy
|
|
subtotal += item.price_estimate * item.quantity
|
|
, 0
|
|
|
|
estimatedTotal: ->
|
|
@estimatedSubtotal()
|