Add methods to check for novel suppliers and distributors in an order cycle

This commit is contained in:
Rohan Mitchell
2015-11-20 07:22:40 +11:00
parent 1a4448c6d2
commit ef603a070e
2 changed files with 38 additions and 2 deletions

View File

@@ -6,11 +6,20 @@ angular.module('admin.orderCycles').factory('OrderCycle', ($resource, $window, $
'update': { method: 'PUT'}}
{
order_cycle: {}
order_cycle: {incoming_exchanges: [], outgoing_exchanges: []}
showProducts: {incoming: false, outgoing: false}
loaded: false
exchangeIds: (direction) ->
parseInt(exchange.enterprise_id) for exchange in @exchangesByDirection(direction)
novelSupplier: (enterprise) ->
@exchangeIds('incoming').indexOf(enterprise.id) == -1
novelDistributor: (enterprise) ->
@exchangeIds('outgoing').indexOf(enterprise.id) == -1
exchangeSelectedVariants: (exchange) ->
numActiveVariants = 0
numActiveVariants++ for id, active of exchange.variants when active