diff --git a/app/mailers/spree/stock_mailer.rb b/app/mailers/spree/stock_mailer.rb index 55286aa..7745e28 100644 --- a/app/mailers/spree/stock_mailer.rb +++ b/app/mailers/spree/stock_mailer.rb @@ -62,7 +62,7 @@ module Spree forecast.push(generate_estimate(var)) } - forecast + forecast.sort { |x,y| x['days'] <=> y['days'] } end def stock_report_email() diff --git a/app/views/spree/stock_mailer/stock_report_email.text.erb b/app/views/spree/stock_mailer/stock_report_email.text.erb index a34fbde..96c6267 100644 --- a/app/views/spree/stock_mailer/stock_report_email.text.erb +++ b/app/views/spree/stock_mailer/stock_report_email.text.erb @@ -5,7 +5,7 @@ will run low. Estimates: <% @forecast.each do |dict| %> -<%= dict['name'] %> (<%= dict['available'] %>) => <%= dict['days'].round(2) %> days until sold out. +<%= dict['name'] %> (<%= dict['available'] %>) => <%= dict['days'].round(2) %> days until sold out. <% end %>