diff --git a/app/domain/export/tabular/people/sac_mitglied_row.rb b/app/domain/export/tabular/people/sac_mitglied_row.rb index e58d7c274..cb8b47420 100644 --- a/app/domain/export/tabular/people/sac_mitglied_row.rb +++ b/app/domain/export/tabular/people/sac_mitglied_row.rb @@ -116,6 +116,10 @@ def phone_number(label) entry.phone_numbers.find { |p| p.label.downcase == label.to_s }&.number end + def phone_number_main + phone_number("haupt-telefon") + end + def postfach entry.postbox end diff --git a/app/domain/export/tabular/people/sac_mitglieder.rb b/app/domain/export/tabular/people/sac_mitglieder.rb index 9b8b07a40..65af0131a 100755 --- a/app/domain/export/tabular/people/sac_mitglieder.rb +++ b/app/domain/export/tabular/people/sac_mitglieder.rb @@ -33,7 +33,7 @@ def attributes # rubocop:disable Metrics/MethodLength :town, :country, :birthday, - :phone_number_direkt, + :phone_number_main, :phone_number_privat, :empty, # 1 leere Spalte :phone_number_mobil, @@ -65,9 +65,9 @@ def mitglieder Person .where(roles: { group_id: non_layer_children_ids, - type: (SacCas::MITGLIED_ROLES - SacCas::NEUANMELDUNG_ROLES).map(&:sti_name) + type: SacCas::MITGLIED_ROLES.map(&:sti_name) }) - .joins(:roles_unscoped) + .joins(:roles) .includes(:phone_numbers, :roles, roles: :group) .distinct end diff --git a/app/jobs/export/backup_mitglieder_schedule_job.rb b/app/jobs/export/backup_mitglieder_schedule_job.rb index 315ae239d..e03d2b311 100644 --- a/app/jobs/export/backup_mitglieder_schedule_job.rb +++ b/app/jobs/export/backup_mitglieder_schedule_job.rb @@ -10,9 +10,7 @@ class Export::BackupMitgliederScheduleJob < RecurringJob ROLE_TYPES_TO_BACKUP = [Group::Sektion, Group::Ortsgruppe].map(&:sti_name) - # Job is temporarily disabled (https://github.com/hitobito/hitobito_sac_cas/issues/1426) - # When re-enabling, also un-skip the corresponding specs. - def perform_internal_DISABLED + def perform_internal relevant_groups.find_each do |group| Export::BackupMitgliederExportJob.new(group.id).enqueue! end diff --git a/spec/domain/export/tabular/people/sac_mitglied_row_spec.rb b/spec/domain/export/tabular/people/sac_mitglied_row_spec.rb index 700b9ec8c..e7885ae07 100644 --- a/spec/domain/export/tabular/people/sac_mitglied_row_spec.rb +++ b/spec/domain/export/tabular/people/sac_mitglied_row_spec.rb @@ -267,6 +267,11 @@ expect(row.phone_number("mobile")).to eq(mobile1.number).or eq(mobile2.number) end + it "#phone_number_main returns number with label Haupt-Telefon" do + main = Fabricate(:phone_number, contactable: person, label: "Haupt-Telefon", number: "0311234567") + expect(row.phone_number_main).to eq main.number + end + it "#phone_number_mobile returns any number with label mobile" do mobile = Fabricate(:phone_number, contactable: person, label: "mobile", number: "0781234567") expect(row.phone_number_mobile).to eq mobile.number diff --git a/spec/domain/export/tabular/people/sac_mitglieder_spec.rb b/spec/domain/export/tabular/people/sac_mitglieder_spec.rb index 0cfed8015..4a8a3bdb6 100644 --- a/spec/domain/export/tabular/people/sac_mitglieder_spec.rb +++ b/spec/domain/export/tabular/people/sac_mitglieder_spec.rb @@ -38,7 +38,7 @@ :town, :country, :birthday, - :phone_number_direkt, + :phone_number_main, :phone_number_privat, :empty, # 1 leere Spalte :phone_number_mobil, @@ -73,6 +73,15 @@ roles(:familienmitglied_kind).person ) end + + it "former mitglieder are not included" do + roles(:mitglied).update!(end_on: 1.day.ago) + expect(tabular.list).to contain_exactly( + roles(:familienmitglied).person, + roles(:familienmitglied2).person, + roles(:familienmitglied_kind).person + ) + end end context "zusatzsektion mitglieder of the layer" do diff --git a/spec/jobs/export/backup_mitglieder_schedule_job_spec.rb b/spec/jobs/export/backup_mitglieder_schedule_job_spec.rb index 81a0b8e67..12822c830 100644 --- a/spec/jobs/export/backup_mitglieder_schedule_job_spec.rb +++ b/spec/jobs/export/backup_mitglieder_schedule_job_spec.rb @@ -7,7 +7,7 @@ require "spec_helper" -xdescribe Export::BackupMitgliederScheduleJob do +describe Export::BackupMitgliederScheduleJob do subject(:job) { described_class.new } let(:relevant_groups) { Group.where(type: [Group::Sektion, Group::Ortsgruppe].map(&:sti_name)) } diff --git a/spec/jobs/sac_cas/export/mitglieder_export_job_spec.rb b/spec/jobs/sac_cas/export/mitglieder_export_job_spec.rb index 51d8e60f1..379fd0b7d 100644 --- a/spec/jobs/sac_cas/export/mitglieder_export_job_spec.rb +++ b/spec/jobs/sac_cas/export/mitglieder_export_job_spec.rb @@ -54,6 +54,14 @@ expect { job.perform }.to change { AsyncDownloadFile.count }.by(1) expect(contents).to match(/\$#{person.last_name}\$"#{person.first_name}"\$/) end + + it "has quotation marks for strings containing col_sep" do + person = people(:mitglied) + person.update!(first_name: "Hello$World") + Person.where.not(id: people(:mitglied, :admin).map(&:id)).destroy_all + expect { job.perform }.to change { AsyncDownloadFile.count }.by(1) + expect(contents).to include %($#{person.last_name}$"#{person.first_name}"$) + end end it "file name" do