diff --git a/app/controllers/contributions_controller.rb b/app/controllers/contributions_controller.rb index a65daff..d388c79 100644 --- a/app/controllers/contributions_controller.rb +++ b/app/controllers/contributions_controller.rb @@ -23,6 +23,23 @@ class ContributionsController < ApplicationController end end + # GET /contributions/due + def due + @due_members = Member.where(status: %i[expired cancelled]).to_a + + @due_contributions = (2000..Date.today.year) + .to_a + .map do |year| + [year, @due_members.select {|m| m.expires_on < Date.new(year, 12, 31) }.map { |m| + OpenStruct.new( + member: m, + amount: m.category == 'normal' ? 30 : 6, + ) + }] + end + .reject { |(_, m)| m.empty? } + end + # GET /contributions/new def new @contribution = Contribution.new diff --git a/app/views/contributions/due.html.erb b/app/views/contributions/due.html.erb new file mode 100644 index 0000000..5f0762c --- /dev/null +++ b/app/views/contributions/due.html.erb @@ -0,0 +1,31 @@ +
<%= t('members.attributes.display_name') %> | +<%= t('members.attributes.expires_on') %> | +<%= t('members.attributes.category') %> | +<%= t('contributions.attributes.amount') %> | +
---|---|---|---|
+ <%= link_to contribution.member do %><%= contribution.member.number %>. <%= contribution.member.display_name %><% end %> + | +<%= contribution.member.expires_on %> | +<%= contribution.member.category %> | +<%= number_to_currency(contribution.amount, unit: "€") %> | +
Total | ++ | + | <%= number_to_currency(contributions.map(&:amount).sum, unit: "€") %> | +