Skip to content

Commit

Permalink
Swapped XPA for XPK
Browse files Browse the repository at this point in the history
  • Loading branch information
lentschi committed Oct 28, 2023
1 parent 948ef32 commit 4aad223
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion app/views/shared/_article_fields_units.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
.fold-line.d-flex
= f.hidden_field :unit, id: 'article_unit_hidden', value: ''
-# title: unit in which article can be ordered from supplier
= f.input :supplier_order_unit, as: :select, collection: @article_units, value: article.supplier_order_unit, include_blank: t('Custom (avoid if possible!)') + ':', input_html: {class: 'input-medium'}
- supplier_order_unit_override = article.supplier_order_unit
- supplier_order_unit_override = 'XPP' if supplier_order_unit_override.nil? && article.unit.nil?
= f.input :supplier_order_unit, as: :select, collection: @article_units, selected: supplier_order_unit_override, include_blank: t('Custom (avoid if possible!)') + ':', input_html: {class: 'input-medium'}
-# title: free text unit
= f.input :unit, input_html: {class: 'input-mini ml-1'}, label: false
.fold-line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def convert_old_unit(old_compound_unit_str, unit_quantity)
group_order_unit: unit
}
else
supplier_order_unit = unit == 'XPP' ? 'XPA' : 'XPP'
supplier_order_unit = unit == 'XPP' ? 'XPK' : 'XPP'
{
supplier_order_unit: supplier_order_unit,
first_ratio: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,13 @@
it 'converts "4 piece" correctly' do
result = migration.send(:convert_old_unit, '4 piece', 1)
expect(result).to eq({
supplier_order_unit: 'XPA',
supplier_order_unit: 'XPK',
first_ratio: {
unit: 'XPP',
quantity: 4
},
group_order_granularity: 1.0,
group_order_unit: 'XPA'
group_order_unit: 'XPK'
})
end

Expand Down
2 changes: 1 addition & 1 deletion lib/article_units.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class ArticleUnits
@un_ece_20_units = YAML.safe_load(ERB.new(File.read(File.expand_path('config/units-of-measure/un-ece-20-remastered.yml', Rails.root))).result)
@un_ece_21_units = YAML.safe_load(ERB.new(File.read(File.expand_path('config/units-of-measure/un-ece-21.yml', Rails.root))).result)

@allowed_units = %w[GRM HGM KGM LTR MLT XPP XCB XBO XBH XGR XPA]
@allowed_units = %w[GRM HGM KGM LTR MLT XPP XCB XBO XBH XGR XPK]

def self.untranslated_units
options = {}
Expand Down

0 comments on commit 4aad223

Please sign in to comment.