mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-06 02:51:34 +00:00
Click to add coordinator fee
This commit is contained in:
@@ -36,6 +36,10 @@ angular.module('order_cycle', ['ngResource'])
|
||||
$event.preventDefault()
|
||||
OrderCycle.addDistributor($scope.new_distributor_id)
|
||||
|
||||
$scope.addCoordinatorFee = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addCoordinatorFee()
|
||||
|
||||
$scope.submit = ->
|
||||
OrderCycle.create()
|
||||
])
|
||||
@@ -78,6 +82,10 @@ angular.module('order_cycle', ['ngResource'])
|
||||
$event.preventDefault()
|
||||
OrderCycle.addDistributor($scope.new_distributor_id)
|
||||
|
||||
$scope.addCoordinatorFee = ($event) ->
|
||||
$event.preventDefault()
|
||||
OrderCycle.addCoordinatorFee()
|
||||
|
||||
$scope.submit = ->
|
||||
OrderCycle.update()
|
||||
])
|
||||
@@ -96,6 +104,7 @@ angular.module('order_cycle', ['ngResource'])
|
||||
order_cycle:
|
||||
incoming_exchanges: []
|
||||
outgoing_exchanges: []
|
||||
coordinator_fees: []
|
||||
|
||||
exchangeSelectedVariants: (exchange) ->
|
||||
numActiveVariants = 0
|
||||
@@ -111,6 +120,9 @@ angular.module('order_cycle', ['ngResource'])
|
||||
addDistributor: (new_distributor_id) ->
|
||||
this.order_cycle.outgoing_exchanges.push({enterprise_id: new_distributor_id, active: true, variants: {}})
|
||||
|
||||
addCoordinatorFee: ->
|
||||
this.order_cycle.coordinator_fees.push({})
|
||||
|
||||
productSuppliedToOrderCycle: (product) ->
|
||||
product_variant_ids = (variant.id for variant in product.variants)
|
||||
variant_ids = [product.master_id].concat(product_variant_ids)
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
%table
|
||||
%tr{'ng-repeat' => 'enterprise_fee in order_cycle.coordinator_fees'}
|
||||
%td= select_tag 'order_cycle_coordinator_fee_{{ $index }}_id', nil, {'ng-model' => 'enterprise_fee.id', 'ng-options' => 'enterprise_fee.id as enterprise_fee.name for enterprise_fee in enterpriseFeesForEnterprise(order_cycle.coordinator_id)'}
|
||||
= f.submit 'Add coordinator fee', 'ng-click' => 'addCoordinatorFee($event)'
|
||||
|
||||
|
||||
%h2 Outgoing
|
||||
|
||||
@@ -20,6 +20,7 @@ describe 'OrderCycle controllers', ->
|
||||
toggleProducts: jasmine.createSpy('toggleProducts')
|
||||
addSupplier: jasmine.createSpy('addSupplier')
|
||||
addDistributor: jasmine.createSpy('addDistributor')
|
||||
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
|
||||
create: jasmine.createSpy('create')
|
||||
Enterprise =
|
||||
index: jasmine.createSpy('index').andReturn('enterprises list')
|
||||
@@ -83,6 +84,11 @@ describe 'OrderCycle controllers', ->
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.addDistributor).toHaveBeenCalledWith('new distributor id')
|
||||
|
||||
it 'Adds coordinator fees', ->
|
||||
scope.addCoordinatorFee(event)
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.addCoordinatorFee).toHaveBeenCalled()
|
||||
|
||||
it 'Submits the order cycle via OrderCycle create', ->
|
||||
scope.submit()
|
||||
expect(OrderCycle.create).toHaveBeenCalled()
|
||||
@@ -111,6 +117,7 @@ describe 'OrderCycle controllers', ->
|
||||
toggleProducts: jasmine.createSpy('toggleProducts')
|
||||
addSupplier: jasmine.createSpy('addSupplier')
|
||||
addDistributor: jasmine.createSpy('addDistributor')
|
||||
addCoordinatorFee: jasmine.createSpy('addCoordinatorFee')
|
||||
update: jasmine.createSpy('update')
|
||||
Enterprise =
|
||||
index: jasmine.createSpy('index').andReturn('enterprises list')
|
||||
@@ -173,6 +180,11 @@ describe 'OrderCycle controllers', ->
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.addDistributor).toHaveBeenCalledWith('new distributor id')
|
||||
|
||||
it 'Adds coordinator fees', ->
|
||||
scope.addCoordinatorFee(event)
|
||||
expect(event.preventDefault).toHaveBeenCalled()
|
||||
expect(OrderCycle.addCoordinatorFee).toHaveBeenCalled()
|
||||
|
||||
it 'Submits the order cycle via OrderCycle update', ->
|
||||
scope.submit()
|
||||
expect(OrderCycle.update).toHaveBeenCalled()
|
||||
@@ -268,6 +280,7 @@ describe 'OrderCycle services', ->
|
||||
id: 123
|
||||
name: 'Test Order Cycle'
|
||||
coordinator_id: 456
|
||||
coordinator_fees: []
|
||||
exchanges: [
|
||||
{sender_id: 1, receiver_id: 456}
|
||||
{sender_id: 456, receiver_id: 2}
|
||||
@@ -277,6 +290,7 @@ describe 'OrderCycle services', ->
|
||||
expect(OrderCycle.order_cycle).toEqual
|
||||
incoming_exchanges: []
|
||||
outgoing_exchanges: []
|
||||
coordinator_fees: []
|
||||
|
||||
it 'counts selected variants in an exchange', ->
|
||||
result = OrderCycle.exchangeSelectedVariants({variants: {1: true, 2: false, 3: true}})
|
||||
@@ -320,6 +334,11 @@ describe 'OrderCycle services', ->
|
||||
{enterprise_id: '123', active: true, variants: {}}
|
||||
]
|
||||
|
||||
describe 'adding coordinator fees', ->
|
||||
it 'adds the coordinator fee', ->
|
||||
OrderCycle.addCoordinatorFee()
|
||||
expect(OrderCycle.order_cycle.coordinator_fees).toEqual [{}]
|
||||
|
||||
describe 'fetching all variants supplied on incoming exchanges', ->
|
||||
it 'collects variants from incoming exchanges', ->
|
||||
OrderCycle.order_cycle.incoming_exchanges = [
|
||||
|
||||
Reference in New Issue
Block a user