Skip to content

Commit

Permalink
12968: fix product import update
Browse files Browse the repository at this point in the history
  • Loading branch information
chahmedejaz committed Nov 25, 2024
1 parent 2837061 commit 3a3d729
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/product_import/entry_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def primary_producer_error(entry)
end

def unit_fields_validation(entry)
unit_types = ['g', 'oz', 'lb', 'kg', 't', 'ml', 'l', 'kl', '']
unit_types = ['mg', 'g', 'kg', 'oz', 'lb', 't', 'ml', 'cl', 'dl', 'l', 'kl', 'gal', '']

if entry.units.blank?
mark_as_invalid(entry, attribute: 'units',
Expand Down
6 changes: 5 additions & 1 deletion app/models/product_import/unit_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,18 @@ def convert_custom_unit_fields

def unit_scales
{
'mg' => { scale: 0.001, unit: 'weight' },
'g' => { scale: 1, unit: 'weight' },
'kg' => { scale: 1000, unit: 'weight' },
'oz' => { scale: 28.35, unit: 'weight' },
'lb' => { scale: 453.6, unit: 'weight' },
't' => { scale: 1_000_000, unit: 'weight' },
'ml' => { scale: 0.001, unit: 'volume' },
'cl' => { scale: 0.01, unit: 'volume' },
'dl' => { scale: 0.1, unit: 'volume' },
'l' => { scale: 1, unit: 'volume' },
'kl' => { scale: 1000, unit: 'volume' }
'kl' => { scale: 1000, unit: 'volume' },
'gal' => { scale: 4.54609, unit: 'volume' },
}
end

Expand Down

0 comments on commit 3a3d729

Please sign in to comment.