@@ -4,8 +4,8 @@ module Export
44 class ExportChemicals
55 CHEMICAL_FIELDS = %w[
66 chemical_sample_id cas status vendor order_number amount volume price person required_date
7- ordered_date storage_temperature expiration_date required_by pictograms h_statements p_statements safety_sheet_link_merck
8- safety_sheet_link_thermofischer product_link_merck product_link_thermofischer
7+ ordered_date storage_temperature expiration_date required_by pictograms h_statements p_statements
8+ safety_sheet_link_merck safety_sheet_link_thermofischer product_link_merck product_link_thermofischer
99 host_building host_room host_cabinet host_group owner borrowed_by current_building
1010 current_room current_cabinet current_group disposal_info important_notes
1111 ] . freeze
@@ -70,8 +70,9 @@ def self.format_chemical_results(result)
7070 end
7171
7272 def self . construct_column_name ( column_name , index , columns_index )
73- format_chemical_column = [ 'p statements' , 'h statements' , 'amount' , 'volume' , 'storage temperature' , 'safety sheet link thermofischer' ,
74- 'safety sheet link merck' , 'product link thermofischer' , 'product link merck' ] . freeze
73+ format_chemical_column = [ 'p statements' , 'h statements' , 'amount' , 'volume' , 'storage temperature' ,
74+ 'safety sheet link thermofischer' , 'safety sheet link merck' , 'product link thermofischer' ,
75+ 'product link merck' ] . freeze
7576 if column_name . is_a? ( String ) && CHEMICAL_FIELDS . include? ( column_name )
7677 column_name = column_name . tr ( '_' , ' ' )
7778 construct_column_name_hash ( columns_index , column_name , index ) if format_chemical_column . include? ( column_name )
@@ -116,7 +117,7 @@ def self.format_row(row, columns_index, indexes_to_delete)
116117 when columns_index [ 'p_statements' ] , columns_index [ 'h_statements' ]
117118 value = format_p_and_h_statements ( value )
118119 when columns_index [ 'amount' ] , columns_index [ 'volume' ] , columns_index [ 'storage_temperature' ]
119- value = format_chemical_amount_or_volume ( value )
120+ value = format_chemical_fields ( value )
120121 when columns_index [ 'safety_sheet_link' ] [ 0 ]
121122 value = format_link ( value , row , columns_index [ 'safety_sheet_link' ] [ 1 ] , indexes_to_delete )
122123 when columns_index [ 'product_link' ] [ 0 ]
@@ -131,7 +132,7 @@ def self.format_p_and_h_statements(value)
131132 keys . join ( '-' )
132133 end
133134
134- def self . format_chemical_amount_or_volume ( value )
135+ def self . format_chemical_fields ( value )
135136 value_unit = JSON . parse ( value ) . values
136137 sorted = value_unit . sort_by { |element | [ element . is_a? ( Integer ) || element . is_a? ( Float ) ? 0 : 1 , element ] }
137138 sorted . join ( ' ' )
0 commit comments