mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-04-07 07:36:58 +00:00
Adding 'Open Orders' section to the top of customer accounts page
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user