mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Merge pull request #9869 from abdellani/fix-unit_value_with_description-calculation-on-products-page_admin_dashboard
use js-big-decimal to calculate unit_value_with_description in products page
This commit is contained in:
@@ -36,7 +36,7 @@ angular.module("admin.products")
|
||||
$scope.product.master.unit_description = match[3]
|
||||
else
|
||||
value = $scope.product.master.unit_value
|
||||
value /= $scope.product.variant_unit_scale if $scope.product.master.unit_value && $scope.product.variant_unit_scale
|
||||
value = window.bigDecimal.divide(value, $scope.product.variant_unit_scale, 2) if $scope.product.master.unit_value && $scope.product.variant_unit_scale
|
||||
$scope.product.master.unit_value_with_description = value + " " + $scope.product.master.unit_description
|
||||
|
||||
$scope.processUnitPrice = ->
|
||||
|
||||
@@ -54,7 +54,7 @@ module ProductImport
|
||||
end
|
||||
|
||||
def assign_weight_or_volume_attributes
|
||||
units = @attrs['units'].to_f
|
||||
units = @attrs['units'].to_d
|
||||
unit_type = @attrs['unit_type'].to_s.downcase
|
||||
|
||||
return unless valid_unit_type? unit_type
|
||||
|
||||
@@ -37,7 +37,7 @@ describe '
|
||||
|
||||
select @supplier.name, from: 'product_supplier_id'
|
||||
select "Weight (kg)", from: 'product_variant_unit_with_scale'
|
||||
fill_in 'product_unit_value_with_description', with: "5 g"
|
||||
fill_in 'product_unit_value_with_description', with: "5.00 g"
|
||||
assert_selector(:field, placeholder: "5kg g")
|
||||
fill_in 'product_display_as', with: "Big Box of Chocolates"
|
||||
select taxon.name, from: "product_primary_taxon_id"
|
||||
@@ -51,7 +51,7 @@ describe '
|
||||
|
||||
expect(page).to have_content "Name can't be blank"
|
||||
expect(page).to have_field 'product_supplier_id', with: @supplier.id
|
||||
expect(page).to have_field 'product_unit_value_with_description', with: "5 g"
|
||||
expect(page).to have_field 'product_unit_value_with_description', with: "5.00 g"
|
||||
expect(page).to have_field 'product_display_as', with: "Big Box of Chocolates"
|
||||
expect(page).to have_field 'product_primary_taxon_id', with: taxon.id
|
||||
expect(page).to have_field 'product_price', with: '19.99'
|
||||
|
||||
Reference in New Issue
Block a user