Verified Commit 37ef96f9 authored by Kaspar Vollenweider's avatar Kaspar Vollenweider 👻
Browse files

add semester filter to the /billing_expenses/new form

- so that the user can change the selection made on /billing_expenses
- so that the filter respects billeable records, and not billed as it was
  probably by mistake before
parent 5d8f439d
class BillingExpensesController < ApplicationController
before_action :set_billing_expense, only: [:show, :update_overwritten_amount, :destroy]
before_action :set_billing_semesters, only: [:index, :new, :create]
before_action :set_billing_semesters, only: [:new, :create]
before_action :set_selection, only: [:index, :download]
def index
authorize BillingExpense
@billing_semesters = BillingExpense.generate_semester_filters
set_default_filter(semester: default_billing_semester)
@q = policy_scope(BillingExpense).ransack(params[:q])
@q.sorts = ['created_at desc'] if @q.sorts.empty?
......@@ -55,7 +55,7 @@ class BillingExpensesController < ApplicationController
authorize @billing_expense
@selected_billing_semester = selected_billing_semester
set_default_filter(semester: @selected_billing_semester)
@q = Volunteer.with_billable_hours(@selected_billing_semester).ransack(params[:q])
@volunteers = @q.result
......@@ -95,7 +95,7 @@ class BillingExpensesController < ApplicationController
end
def set_billing_semesters
@billing_semesters = BillingExpense.generate_semester_filters
@billing_semesters = BillingExpense.generate_semester_filters(:billable)
end
def set_selection
......
......@@ -72,7 +72,7 @@ class BillingExpense < ApplicationRecord
end
end
def self.generate_semester_filters
def self.generate_semester_filters(scope = :billed)
semesters = []
first_semester = semester_from_hours(scope, date_position: :minimum)
......
......@@ -2,12 +2,16 @@
h1 Spesenformulare erfassen
ul.list-inline
= button_link navigation_glyph(:back), billing_expenses_path
li= clear_filter_button
= custom_filter_dropdown(t_attr(:semester, BillingExpense), *@billing_semesters)
= simple_form_for @billing_expense do |f|
= hidden_field_tag 'selected_semester', @selected_billing_semester
.row
.col-xs-12
=> button_link navigation_glyph(:back), billing_expenses_path
=> f.button :submit, 'Spesenformulare erstellen', 'data-confirm' => 'Sind Sie sicher dass Sie die Spesenformulare für die ausgewählten Freiwilligen erstellen möchten?'
= f.button :submit, 'Spesenformulare erstellen', 'data-confirm' => 'Sind Sie sicher dass Sie die Spesenformulare für die ausgewählten Freiwilligen erstellen möchten?'
.table-responsive
table.table.table-striped.list-responses-table
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment