diff --git a/app/models/ordergroup.rb b/app/models/ordergroup.rb index bf82afc4..745b6e3e 100644 --- a/app/models/ordergroup.rb +++ b/app/models/ordergroup.rb @@ -26,6 +26,11 @@ class Ordergroup < Group User.natural_order.all.reject { |u| (users.include?(u) || u.ordergroup) } end + # the most recent order this ordergroup was participating in + def last_order + orders.order('orders.starts DESC').first + end + def value_of_open_orders(exclude = nil) group_orders.in_open_orders.reject{|go| go == exclude}.collect(&:price).sum end diff --git a/app/views/foodcoop/ordergroups/_ordergroups.html.haml b/app/views/foodcoop/ordergroups/_ordergroups.html.haml index b8b34084..a2beb812 100644 --- a/app/views/foodcoop/ordergroups/_ordergroups.html.haml +++ b/app/views/foodcoop/ordergroups/_ordergroups.html.haml @@ -7,13 +7,13 @@ %tr %th= heading_helper Ordergroup, :name %th= heading_helper Ordergroup, :user_tokens - %th= heading_helper Ordergroup, :last_ordered + %th= heading_helper Ordergroup, :last_order %tbody - for ordergroup in @ordergroups %tr %td= ordergroup.name %td=h ordergroup.users.collect { |u| show_user(u) }.join(", ") - %td= format_date ordergroup.orders.order('orders.starts DESC').first.try(:starts) + %td= format_date ordergroup.last_order.try(:starts) %td= link_to_new_message(message_params: {group_id: ordergroup.id}) diff --git a/config/locales/en.yml b/config/locales/en.yml index a2c87178..496b29c3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -88,6 +88,7 @@ en: contact_phone: Phone description: Description ignore_apple_restriction: Ignore order stop by apple points restriction + last_order: Last order name: Name user_tokens: Members page: