mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Use js-big-decimal package for calculation
This commit is contained in:
@@ -676,14 +676,14 @@ describe "AdminProductEditCtrl", ->
|
||||
unit_description: ''
|
||||
unit_value_with_description: "250,5"
|
||||
|
||||
it "rounds off the unit_value upto 8 decimal places and removes the trailing zeroes", ->
|
||||
it "rounds off the unit_value upto 2 decimal places", ->
|
||||
testProduct = {id: 123, variant_unit_scale: 28.35}
|
||||
testVariant = {unit_value_with_description: "1234.5"}
|
||||
testVariant = {unit_value_with_description: "1234.567"}
|
||||
$scope.packVariant(testProduct, testVariant)
|
||||
expect(testVariant).toEqual
|
||||
unit_value: 1234.5
|
||||
unit_value: 1234.57
|
||||
unit_description: ''
|
||||
unit_value_with_description: "1234.5"
|
||||
unit_value_with_description: "1234.567"
|
||||
|
||||
|
||||
describe "filtering products", ->
|
||||
|
||||
@@ -152,10 +152,10 @@ describe "BulkProducts service", ->
|
||||
variant = {unit_value: 5}
|
||||
expect(BulkProducts.variantUnitValue(product, variant)).toEqual 5000
|
||||
|
||||
it "returns the scaled value rounded off upto 8 decimal points removing the trailing zeroes", ->
|
||||
it "returns the scaled value rounded off upto 2 decimal points", ->
|
||||
product = {variant_unit_scale: 28.35}
|
||||
variant = {unit_value: 1234.5}
|
||||
expect(BulkProducts.variantUnitValue(product, variant)).toEqual 43.54497354
|
||||
expect(BulkProducts.variantUnitValue(product, variant)).toEqual 43.54
|
||||
|
||||
it "returns the unscaled value when the product has no scale", ->
|
||||
product = {}
|
||||
|
||||
Reference in New Issue
Block a user