Adding 'Open Orders' section to the top of customer accounts page

This commit is contained in:
Rob Harrington
2017-04-12 11:29:12 +10:00
parent b94bcd697f
commit 893331c7bb
8 changed files with 105 additions and 8 deletions

View File

@@ -8,3 +8,9 @@ Darkswarm.filter "sensible_timeframe", (date_in_wordsFilter)->
t 'orders_open'
else
t('closing') + date_in_wordsFilter(date)
Darkswarm.filter "changesAllowed", ->
(date) ->
return t('say_no') unless date?
return t('spree.users.open_orders.closed') if date < moment()
t('spree.users.open_orders.until') + " " + moment(date).calendar()

View File

@@ -3,10 +3,12 @@ Darkswarm.factory 'Orders', (orders_by_distributor, currencyConfig, CurrentHub,
constructor: ->
# Populate Orders.orders from json in page.
@orders_by_distributor = orders_by_distributor
@editable_orders = []
@currency_symbol = currencyConfig.symbol
for distributor in @orders_by_distributor
@updateRunningBalance(distributor.distributed_orders)
@findEditableOrders(distributor.distributed_orders)
@updateRunningBalance(distributor.distributed_orders)
updateRunningBalance: (orders) ->
@@ -14,3 +16,7 @@ Darkswarm.factory 'Orders', (orders_by_distributor, currencyConfig, CurrentHub,
balances = orders.slice(i,orders.length).map (o) -> parseFloat(o.outstanding_balance)
running_balance = balances.reduce (a,b) -> a+b
order.running_balance = running_balance.toFixed(2)
findEditableOrders: (orders) ->
for order in orders when order.editable
@editable_orders.push(order)