mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-20 04:59:16 +00:00
BOM: view information about max quantities ordered
This commit is contained in:
@@ -486,8 +486,8 @@ feature %q{
|
||||
let!(:p3) { FactoryGirl.create(:product_with_option_types, group_buy: true, group_buy_unit_size: 5000, variant_unit: "weight", variants: [FactoryGirl.create(:variant, unit_value: 1000)] ) }
|
||||
let!(:v3) { p3.variants.first }
|
||||
let!(:o3) { FactoryGirl.create(:order, state: 'complete', completed_at: Time.now ) }
|
||||
let!(:li3) { FactoryGirl.create(:line_item, order: o3, variant: v3, quantity: 3 ) }
|
||||
let!(:li4) { FactoryGirl.create(:line_item, order: o2, variant: v3, quantity: 1 ) }
|
||||
let!(:li3) { FactoryGirl.create(:line_item, order: o3, variant: v3, quantity: 3, max_quantity: 6 ) }
|
||||
let!(:li4) { FactoryGirl.create(:line_item, order: o2, variant: v3, quantity: 1, max_quantity: 3 ) }
|
||||
|
||||
before :each do
|
||||
visit '/admin/orders/bulk_management'
|
||||
@@ -500,12 +500,16 @@ feature %q{
|
||||
page.should have_selector "div#group_buy_calculation", :visible => true
|
||||
|
||||
within "div#group_buy_calculation" do
|
||||
page.should have_text "Group Buy Unit"
|
||||
page.should have_text "Group Buy Unit Size"
|
||||
page.should have_text "5 kg"
|
||||
page.should have_text "Total Quantity Ordered"
|
||||
page.should have_text "4 kg"
|
||||
page.should have_text "Max Quantity Ordered"
|
||||
page.should have_text "9 kg"
|
||||
page.should have_text "Fulfilled Units"
|
||||
page.should have_text "0.8"
|
||||
page.should have_text "Total Units Ordered"
|
||||
page.should have_text "4 kg"
|
||||
page.should have_text "Max Fulfilled Units"
|
||||
page.should have_text "1.8"
|
||||
page.should have_selector "div.shared_resource", :visible => true
|
||||
within "div.shared_resource" do
|
||||
page.should have_selector "span", :text => "Shared Resource?"
|
||||
|
||||
@@ -257,9 +257,7 @@ describe "AdminOrderMgmtCtrl", ->
|
||||
|
||||
it "returns the quantity of fulfilled group buy units", ->
|
||||
scope.selectedUnitsProduct = { variant_unit: "weight", group_buy_unit_size: 1000 }
|
||||
spyOn(scope,"sumUnitValues").andReturn 1500
|
||||
expect(scope.fulfilled()).toEqual 1.5
|
||||
expect(scope.sumUnitValues).toHaveBeenCalled()
|
||||
expect(scope.fulfilled(1500)).toEqual 1.5
|
||||
|
||||
describe "allUnitValuesPresent()", ->
|
||||
it "returns false if the unit_value of any item in filteredLineItems does not exist", ->
|
||||
@@ -304,6 +302,18 @@ describe "AdminOrderMgmtCtrl", ->
|
||||
sp2 = scope.filteredLineItems[2].units_variant.unit_value * scope.filteredLineItems[2].quantity
|
||||
expect(scope.sumUnitValues()).toEqual (sp0 + sp1 + sp2)
|
||||
|
||||
describe "sumMaxUnitValues()", ->
|
||||
it "returns the sum of the product of unit_value and maxOf(max_quantity,quantity) for specified line_items", ->
|
||||
scope.filteredLineItems = [
|
||||
{ units_variant: { unit_value: 1 }, quantity: 2, max_quantity: 5 }
|
||||
{ units_variant: { unit_value: 2 }, quantity: 3, max_quantity: 1 }
|
||||
{ units_variant: { unit_value: 3 }, quantity: 7, max_quantity: 10 }
|
||||
]
|
||||
sp0 = scope.filteredLineItems[0].units_variant.unit_value * Math.max(scope.filteredLineItems[0].quantity, scope.filteredLineItems[0].max_quantity)
|
||||
sp1 = scope.filteredLineItems[1].units_variant.unit_value * Math.max(scope.filteredLineItems[1].quantity, scope.filteredLineItems[1].max_quantity)
|
||||
sp2 = scope.filteredLineItems[2].units_variant.unit_value * Math.max(scope.filteredLineItems[2].quantity, scope.filteredLineItems[2].max_quantity)
|
||||
expect(scope.sumMaxUnitValues()).toEqual (sp0 + sp1 + sp2)
|
||||
|
||||
describe "formatting a value based upon the properties of a specified Units Variant", ->
|
||||
# A Units Variant is an API object which holds unit properies of a variant
|
||||
|
||||
|
||||
Reference in New Issue
Block a user