Use js-big-decimal package for calculation

This commit is contained in:
saunmanoj888
2022-10-21 21:30:00 +05:30
parent b40cd579bc
commit ee8454bd2c
4 changed files with 8 additions and 9 deletions

View File

@@ -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", ->

View File

@@ -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 = {}