mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-24 05:38:52 +00:00
Running balances
This commit is contained in:
@@ -4,3 +4,11 @@ Darkswarm.factory 'Orders', (orders_by_distributor, currencyConfig, CurrentHub,
|
||||
# Populate Orders.orders from json in page.
|
||||
@orders_by_distributor = orders_by_distributor
|
||||
@currency_symbol = currencyConfig.symbol
|
||||
|
||||
for distributor in @orders_by_distributor
|
||||
console.log distributor
|
||||
for order, i in distributor.distributed_orders
|
||||
balances = distributor.distributed_orders.slice(i,distributor.distributed_orders.length).map (o) -> parseFloat(o.outstanding_balance)
|
||||
running_balance = balances.reduce (a,b) -> a+b
|
||||
order.running_balance = running_balance.toFixed(2)
|
||||
console.log order
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
%th.order4{"bo-text" => "'shipping_state' | t"}
|
||||
%th.order5.text-right{"bo-text" => "'value' | t"}
|
||||
%th.order6.text-right{"bo-text" => "'balance' | t"}
|
||||
%th.order6.text-right{"bo-text" => "'running_balance' | t"}
|
||||
%tbody.transaction-group{"ng-repeat" => "order in distributor.distributed_orders", "ng-class-odd"=>"'odd'", "ng-class-even"=>"'even'"}
|
||||
%tr.order-row
|
||||
%td.order1
|
||||
@@ -17,6 +18,7 @@
|
||||
%td.order4{"bo-text" => "order.shipment_state | t"}
|
||||
%td.order5.text-right{"bo-text" => "order.total | localizeCurrency"}
|
||||
%td.order6.text-right{"ng-class" => "{'credit' : order.outstanding_balance < 0, 'debit' : order.outstanding_balance > 0, 'paid' : order.outstanding_balance == 0}", "bo-text" => "order.outstanding_balance | localizeCurrency"}
|
||||
%td.order7.text-right{"ng-class" => "{'credit' : order.running_balance < 0, 'debit' : order.running_balance > 0, 'paid' : order.running_balance == 0}", "bo-text" => "order.running_balance | localizeCurrency"}
|
||||
%tr.payment-row{"ng-repeat" => "payment in order.payments"}
|
||||
%td.order1{"bo-text" => "()'payment' | t) + ' ' + payment.identifier"}
|
||||
%td.order2{"bo-text" => "payment.updated_at"}
|
||||
@@ -24,3 +26,4 @@
|
||||
%td.order4
|
||||
%td.order5.text-right{"bo-text" => "payment.amount | localizeCurrency"}
|
||||
%td.order6
|
||||
%td.order7
|
||||
|
||||
@@ -687,3 +687,4 @@ Please follow the instructions there to make your enterprise visible on the Open
|
||||
Paid: "Paid"
|
||||
Ready: "Ready"
|
||||
you_have_no_orders_yet: "You have no orders yet"
|
||||
running_balance: "Running balance"
|
||||
|
||||
Reference in New Issue
Block a user