mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Multiply by unit_value as sumOfUnitValues is now scaled
This commit is contained in:
@@ -168,7 +168,7 @@ angular.module("admin.lineItems").controller 'LineItemsCtrl', ($scope, $timeout,
|
||||
if $scope.selectedUnitsProduct.hasOwnProperty("group_buy_unit_size") && $scope.selectedUnitsProduct.group_buy_unit_size > 0 &&
|
||||
$scope.selectedUnitsProduct.hasOwnProperty("variant_unit") &&
|
||||
( $scope.selectedUnitsProduct.variant_unit == "weight" || $scope.selectedUnitsProduct.variant_unit == "volume" )
|
||||
$scope.roundToThreeDecimals(sumOfUnitValues / $scope.selectedUnitsProduct.group_buy_unit_size)
|
||||
$scope.roundToThreeDecimals(sumOfUnitValues / $scope.selectedUnitsProduct.group_buy_unit_size * $scope.selectedUnitsVariant.unit_value)
|
||||
else
|
||||
''
|
||||
|
||||
|
||||
@@ -171,8 +171,14 @@ describe "LineItemsCtrl", ->
|
||||
|
||||
it "returns the quantity of fulfilled group buy units", ->
|
||||
scope.selectedUnitsProduct = { variant_unit: "weight", group_buy_unit_size: 1000 }
|
||||
scope.selectedUnitsVariant = { unit_value: 1 }
|
||||
expect(scope.fulfilled(1500)).toEqual 1.5
|
||||
|
||||
it "returns the quantity of fulfilled group buy units by volume", ->
|
||||
scope.selectedUnitsProduct = { variant_unit: "volume", group_buy_unit_size: 5000 }
|
||||
scope.selectedUnitsVariant = { unit_value: 1000 }
|
||||
expect(scope.fulfilled(5)).toEqual 1
|
||||
|
||||
describe "allFinalWeightVolumesPresent()", ->
|
||||
it "returns false if the unit_value of any item in filteredLineItems does not exist", ->
|
||||
scope.filteredLineItems = [
|
||||
|
||||
Reference in New Issue
Block a user