Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
475 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of | ||
# hitobito_sac_cas and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_sac_cas | ||
|
||
class SacMembershipConfigsController < CrudController | ||
self.nesting = Group | ||
self.permitted_attrs =[:valid_from, | ||
:sac_fee_adult, | ||
:sac_fee_family, | ||
:sac_fee_youth, | ||
:entry_fee_adult, | ||
:entry_fee_family, | ||
:entry_fee_youth, | ||
:hut_solidarity_fee_with_hut_adult, | ||
:hut_solidarity_fee_with_hut_family, | ||
:hut_solidarity_fee_with_hut_youth, | ||
:hut_solidarity_fee_without_hut_adult, | ||
:hut_solidarity_fee_without_hut_family, | ||
:hut_solidarity_fee_without_hut_youth, | ||
:magazine_fee_adult, | ||
:magazine_fee_family, | ||
:magazine_fee_youth, | ||
:service_fee, | ||
:magazine_postage_abroad, | ||
:reduction_amount, | ||
:reduction_required_membership_years, | ||
:sac_fee_article_number, | ||
:sac_entry_fee_article_number, | ||
:hut_solidarity_fee_article_number, | ||
:magazine_fee_article_number, | ||
:section_bulletin_postage_abroad_article_number, | ||
:service_fee_article_number, | ||
:balancing_payment_article_number, | ||
:course_fee_article_number, | ||
:discount_date_1, | ||
:discount_percent_1, | ||
:discount_date_2, | ||
:discount_percent_2, | ||
:discount_date_3, | ||
:discount_percent_3] | ||
|
||
decorates :sac_membership_config | ||
helper_method :cancel_url | ||
|
||
def index | ||
redirect_to latest_config_entry_path | ||
end | ||
|
||
def show | ||
redirect_to edit_path(params[:id]) | ||
end | ||
|
||
private | ||
|
||
def find_entry | ||
SacMembershipConfig.find(params[:id]) | ||
end | ||
|
||
def latest_config_entry_path | ||
latest_config = SacMembershipConfig.all.order(valid_from: :desc).limit(1).first | ||
edit_path(latest_config.id) | ||
end | ||
|
||
def edit_path(id) | ||
helpers.edit_group_sac_membership_config_path(group_id: Group.root.id, id: id) | ||
end | ||
|
||
def cancel_url | ||
group_path(id: Group.root.id) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of | ||
# hitobito_sac_cas and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_sac_cas. | ||
|
||
class SacMembershipConfigDecorator < ApplicationDecorator | ||
decorates SacMembershipConfig | ||
|
||
def to_s | ||
"#{@object.class.model_name.human} (#{valid_from})" | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of | ||
# hitobito_sac_cas and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_sac_cas | ||
|
||
module SacCas::Dropdown::GroupEdit | ||
def initialize(template, group) | ||
super(template, group) | ||
if group.root? | ||
add_item(translate(:sac_membership_configs), | ||
template.group_sac_membership_configs_path( | ||
group_id: Group.root.id)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of | ||
# hitobito_sac_cas and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_sac_cas | ||
|
||
module Sheet | ||
class SacMembershipConfig < Base | ||
self.parent_sheet = Sheet::Group | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of | ||
# hitobito_sac_cas and licensed under the Affero General Public License version 3 | ||
# or later. See the COPYING file at the top-level directory or at | ||
# https://github.com/hitobito/hitobito_sac_cas | ||
|
||
class SacMembershipConfig < ApplicationRecord | ||
validates_by_schema | ||
|
||
attr_readonly :valid_from | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
-# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of | ||
-# hitobito_sac_cas and licensed under the Affero General Public License version 3 | ||
-# or later. See the COPYING file at the top-level directory or at | ||
-# https://github.com/hitobito/hitobito_sac_cas. | ||
= entry_form(cancel_url: cancel_url) do |f| | ||
= field_set_tag do | ||
- if entry.new_record? | ||
= f.labeled_input_field :sac_fee_adult | ||
|
||
= field_set_tag(t('sac_membership_configs.form.fees')) do | ||
.container.ml-0 | ||
.row | ||
.col-3.p-1 | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.membership_adult') | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.membership_family') | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.membership_youth') | ||
.row | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.sac_fee') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :sac_fee_adult | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :sac_fee_family | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :sac_fee_youth | ||
%span.input-group-text | ||
= t('global.currency') | ||
.row | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.entry_fee') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :entry_fee_adult | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :entry_fee_family | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :entry_fee_youth | ||
%span.input-group-text | ||
= t('global.currency') | ||
.row | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.hut_solidarity_fee_without_hut') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :hut_solidarity_fee_without_hut_adult | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :hut_solidarity_fee_without_hut_family | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :hut_solidarity_fee_without_hut_youth | ||
%span.input-group-text | ||
= t('global.currency') | ||
.row | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.hut_solidarity_fee_with_hut') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :hut_solidarity_fee_with_hut_adult | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :hut_solidarity_fee_with_hut_family | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :hut_solidarity_fee_with_hut_youth | ||
%span.input-group-text | ||
= t('global.currency') | ||
.row | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.magazine_fee') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :magazine_fee_adult | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :magazine_fee_family | ||
%span.input-group-text | ||
= t('global.currency') | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :magazine_fee_youth | ||
%span.input-group-text | ||
= t('global.currency') | ||
.row.pt-5 | ||
.col-3.p-1 | ||
= SacMembershipConfig.human_attribute_name(:magazine_postage_abroad) | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :magazine_postage_abroad | ||
%span.input-group-text | ||
= t('global.currency') | ||
|
||
= field_set_tag(t('sac_membership_configs.form.reductions')) do | ||
.container.ml-0 | ||
.row | ||
.col-3.p-1 | ||
= SacMembershipConfig.human_attribute_name(:reduction_amount) | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :reduction_amount | ||
%span.input-group-text | ||
= t('global.currency') | ||
.row | ||
.col-3.p-1 | ||
= SacMembershipConfig.human_attribute_name(:reduction_required_membership_years) | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :reduction_required_membership_years | ||
%span.input-group-text | ||
= t('global.years') | ||
|
||
= field_set_tag(t('sac_membership_configs.form.discounts')) do | ||
.container.ml-0 | ||
.row | ||
.col-3.p-1 | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.discount_date') | ||
.col-3.p-1 | ||
= t('sac_membership_configs.form.discount') | ||
.row | ||
.col-3.p-1 | ||
= SacMembershipConfig.human_attribute_name(:discount_date_1) | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :discount_date_1 | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :discount_percent_1 | ||
%span.input-group-text | ||
= '%' | ||
.row | ||
.col-3.p-1 | ||
= SacMembershipConfig.human_attribute_name(:discount_date_2) | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :discount_date_2 | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :discount_percent_2 | ||
%span.input-group-text | ||
= '%' | ||
.row | ||
.col-3.p-1 | ||
= SacMembershipConfig.human_attribute_name(:discount_date_3) | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :discount_date_3 | ||
.col-3.p-1 | ||
.input-group.input-group-sm | ||
= f.input_field :discount_percent_3 | ||
%span.input-group-text | ||
= '%' | ||
|
||
= field_set_tag(t('sac_membership_configs.form.article_numbers')) do | ||
= f.labeled_input_fields(:sac_fee_article_number, | ||
:sac_entry_fee_article_number, | ||
:hut_solidarity_fee_article_number, | ||
:magazine_fee_article_number, | ||
:section_bulletin_postage_abroad_article_number, | ||
:service_fee_article_number, | ||
:balancing_payment_article_number, | ||
:course_fee_article_number) |
Oops, something went wrong.