Verified Commit 9b8aeabd authored by Kaspar Vollenweider's avatar Kaspar Vollenweider
Browse files

Coplaner excel additions and fixes feedback

parent bc43dc1d
......@@ -12,7 +12,8 @@ class Client < ApplicationRecord
GENDER_REQUESTS = [:no_matter, :man, :woman].freeze
AGE_REQUESTS = [:age_no_matter, :age_young, :age_middle, :age_old].freeze
PERMITS = [:N, :B, :'B-FL', :'F-FL', :'F-A', :C, :CH].freeze
SALUTATIONS = [:mrs, :mr, :family].freeze
SALUTATIONS = (Volunteer::SALUTATIONS + [:family]).freeze
SALUTATION_GENDER_MAP = Volunteer::SALUTATION_GENDER_MAP.merge(family: :family).freeze
AVAILABILITY = [:flexible, :morning, :afternoon, :evening, :workday, :weekend].freeze
belongs_to :user, -> { with_deleted }, inverse_of: 'clients'
......@@ -112,6 +113,14 @@ class Client < ApplicationRecord
cost_units.keys.map(&:to_sym)
end
def gender
SALUTATION_GENDER_MAP[salutation.to_sym]
end
def gender_t
I18n.t("activerecord.attributes.client.genders.#{gender}")
end
def to_s
contact.full_name
end
......@@ -135,6 +144,10 @@ class Client < ApplicationRecord
accepted? && assignments.active.any?
end
def active_inactive_key
active? ? :active : :inactive
end
def inactive?
accepted? && assignments.active.blank?
end
......
......@@ -28,6 +28,10 @@ module VolunteersGroupAndTandemStateUpdate
!ended? && started? || period_start.blank? && will_end?
end
def active_inactive_key
inactive? ? :inactive : :active
end
def inactive?
ended? || period_start.blank? && period_end.blank? || will_start?
end
......
......@@ -16,6 +16,7 @@ class Volunteer < ApplicationRecord
REJECTIONS = [:us, :her, :other].freeze
AVAILABILITY = [:flexible, :morning, :afternoon, :evening, :workday, :weekend].freeze
SALUTATIONS = [:mrs, :mr].freeze
SALUTATION_GENDER_MAP = { mrs: :female, mr: :male }.freeze
HOW_HAVE_YOU_HEARD_OF_AOZS = [:internet_research, :friends, :announcment, :flyer].freeze
enum acceptance: { undecided: 0, invited: 1, accepted: 2, rejected: 3, resigned: 4 }
......@@ -385,6 +386,10 @@ class Volunteer < ApplicationRecord
active_assignments? || active_groups?
end
def active_inactive_key
active? ? :active : :inactive
end
def active_assignments?
accepted? && assignments.active.any?
end
......@@ -544,6 +549,14 @@ class Volunteer < ApplicationRecord
end
end
def gender
SALUTATION_GENDER_MAP[salutation.to_sym]
end
def gender_t
I18n.t("activerecord.attributes.volunteer.genders.#{gender}")
end
def to_s
contact.full_name
end
......
......@@ -19,6 +19,11 @@ default_locals = {
format_code: 'hh:mm',
width: :auto_fit
),
date_time_format: wb.styles.add_style(
alignment: { horizontal: :left, vertical: :top },
format_code: 'dd.mm.yyyy hh:mm',
width: :auto_fit
),
header_style: wb.styles.add_style(
bg_color: 'FFDFDEDF',
b: true,
......@@ -29,7 +34,7 @@ default_locals = {
wrapped_style: wb.styles.add_style(
alignment: { wrap_text: true, horizontal: :left, vertical: :top }
),
render_time: Time.zone.now,
zeit: Time.zone.now,
col_alpha_indexes: ('A'..'Z').to_a + ('A'..'Z').to_a.map { |letter| "A#{letter}" }
}
......@@ -47,8 +52,6 @@ render partial: 'coplaners/sheets/assignments',
locals: default_locals.merge(assignments: @assignments)
render partial: 'coplaners/sheets/group_offers',
locals: default_locals.merge(group_offers: @group_offers)
# render partial: 'coplaners/sheets/group_assignments',
# locals: default_locals.merge(group_assignments: @group_assignments)
render partial: 'coplaners/sheets/matching_ga_fw',
locals: default_locals.merge(group_assignments: @group_assignments)
render partial: 'coplaners/sheets/stundenerfassung',
......@@ -59,3 +62,6 @@ render partial: 'coplaners/sheets/weiterbildung',
locals: default_locals.merge(events: @events, event_volunteers: @event_volunteers)
render partial: 'coplaners/sheets/departments',
locals: default_locals.merge(departments: @departments)
# render partial: 'coplaners/sheets/group_assignments',
# locals: default_locals.merge(group_assignments: @group_assignments)
wb.add_worksheet(name: 'Begleitungen') do |sheet|
columns = [
'ID',
'ID Status',
'Status',
'ID Freiwillige/r',
'Freiwillige/r',
'ID Klient/in',
'Klient/in',
'Region',
'Einsatzbeginn',
'Einsatzende',
'Einsatzbeginn (in Monaten)',
......@@ -18,53 +18,53 @@ wb.add_worksheet(name: 'Begleitungen') do |sheet|
sheet.add_row(columns, style: header_style, height: 25)
assignments.each do |assignment|
data = [
assignment.id, # 'ID'
assignment.active? ? 'Aktiv' : 'Inaktiv', # 'Status'
assignment.volunteer_id, # 'ID Freiwillige/r'
assignment.volunteer.full_name, # 'Freiwillige/r'
assignment.client_id, # 'ID Klient/in'
assignment.client.contact.full_name, # 'Klient/in'
'abklaeren. Was?', # 'Region'
assignment.period_start, # 'Einsatzbeginn'
assignment.period_end, # 'Einsatzende'
'', # 'Einsatzbeginn (in Monaten)'
'', # 'Einsatzende (in Monaten)'
'', # 'Laufzeit (in Mte.)'
assignment.probation_period&.to_date || '', # 'Probezeit (nach 1 Mt.)'
'was fuer eine zeit ist verlangt?' # 'Zeit'
assignment.id, # 'ID'
assignment.active_inactive_key, # 'ID Status'
t("state.#{assignment.active_inactive_key}"), # 'Status'
assignment.volunteer_id, # 'ID Freiwillige/r'
assignment.volunteer.full_name, # 'Freiwillige/r'
assignment.client_id, # 'ID Klient/in'
assignment.client.contact.full_name, # 'Klient/in'
assignment.period_start, # 'Einsatzbeginn'
assignment.period_end, # 'Einsatzende'
'', # 'Einsatzbeginn (in Monaten)'
'', # 'Einsatzende (in Monaten)'
'', # 'Laufzeit (in Mte.)'
assignment.probation_period, # 'Probezeit (nach 1 Mt.)'
zeit # 'Zeit'
]
types = [
:integer, # 'ID'
nil, # 'ID Status'
nil, # 'Status'
:integer, # 'ID Freiwillige/r'
nil, # 'Freiwillige/r'
:integer, # 'ID Klient/in'
nil, # 'Klient/in'
nil, # 'Region'
nil, # 'Einsatzbeginn'
nil, # 'Einsatzende'
nil, # 'Einsatzbeginn (in Monaten)'
nil, # 'Einsatzende (in Monaten)'
nil, # 'Laufzeit (in Mte.)'
nil, # 'Probezeit (nach 1 Mt.)'
nil # 'Zeit'
:time, # 'Probezeit (nach 1 Mt.)'
:time # 'Zeit'
]
style = [
standard_format, # 'ID'
standard_format, # 'ID Status'
standard_format, # 'Status'
standard_format, # 'ID Freiwillige/r'
standard_format, # 'Freiwillige/r'
standard_format, # 'ID'
standard_format, # 'Klient/in'
standard_format, # 'Region'
date_format, # 'Einsatzbeginn'
date_format, # 'Einsatzende'
standard_format, # 'Einsatzbeginn (in Monaten)'
standard_format, # 'Einsatzende (in Monaten)'
standard_format, # 'Laufzeit (in Mte.)'
date_format, # 'Probezeit (nach 1 Mt.)'
standard_format # 'Zeit'
date_time_format, # 'Probezeit (nach 1 Mt.)'
date_time_format # 'Zeit'
]
sheet.add_row(data, types: types, style: style)
end
......
......@@ -2,28 +2,32 @@ wb.add_worksheet(name: 'Spesenabrechnungen') do |sheet|
columns = [
'ID',
'Betrag',
'Datum',
'ID Freiwillige/r'
'Erstellt am',
'ID Freiwillige/r',
'Zeit' # report creation time
]
sheet.add_row(columns, style: header_style, height: 25)
billing_expenses.each do |billing_expense|
data = [
billing_expense.id, # 'ID'
billing_expense.amount, # 'Betrag'
billing_expense.created_at.to_date, # 'Datum'
billing_expense.volunteer_id # 'ID Freiwillige/r'
billing_expense.id, # 'ID'
billing_expense.amount, # 'Betrag'
billing_expense.created_at, # 'Erstellt am'
billing_expense.volunteer_id, # 'ID Freiwillige/r'
zeit # 'Zeit'
]
types = [
:integer, # 'ID'
nil, # 'Betrag'
nil, # 'Datum'
:integer # 'ID Freiwillige/r'
:time, # 'Erstellt am'
:integer, # 'ID Freiwillige/r'
:time # 'Zeit'
]
style = [
standard_format, # 'ID'
standard_format, # 'Betrag'
standard_format, # 'Datum'
standard_format # 'ID Freiwillige/r'
date_time_format, # 'Erstellt am'
standard_format, # 'ID Freiwillige/r'
date_time_format # 'Zeit'
]
sheet.add_row(data, types: types, style: style)
end
......
wb.add_worksheet(name: 'Klienten') do |sheet|
columns = [
'AOZ Klienten ID',
'id',
'AOZ Klienten ID', # field to be left empty, according to Sven Marti (AOZ)
'ID',
'ID Anrede',
'Anrede',
'ID Geschlecht',
'Geschlecht', # will add transformed salutation here, because gender isn't in the model
'Nachname',
'Vorname',
'PLZ',
'Ort',
'Geschlecht',
'Geburtsdatum',
'Alter',
'Nationalität ISO Alpha2',
......@@ -16,12 +17,17 @@ wb.add_worksheet(name: 'Klienten') do |sheet|
'ID Prozess',
'Prozess',
'Erstellt am',
'Akzeptiert am',
'Beendet am',
'Abgelehnt am',
'Fallführend',
'ID Kostenträger',
'Kostenträger',
'Einsatz',
'Einsatz', # field to be left empty, according to Sven Marti (AOZ)
'ID Status',
'Status',
'Zeit (von Anmeldung bis Vermittlung in Tagen)',
'Zeit'
'Zeit' # report creation time
]
sheet.add_row(columns, style: header_style, height: 25)
clients.each do |client|
......@@ -30,77 +36,95 @@ wb.add_worksheet(name: 'Klienten') do |sheet|
(client.accepted_at.to_date - client.created_at.to_date)
end
data = [
'Was ist hier gemeint?', # 'AOZ Klienten ID',
client.id, # 'id',
client.salutation, # 'ID Anrede',
t("salutation.#{client.salutation}"), # 'Anrede',
client.contact.last_name, # 'Nachname',
client.contact.first_name, # 'Vorname',
client.contact.postal_code, # 'PLZ',
client.contact.city, # 'Ort',
'', # 'Geschlecht',
client.birth_year, # 'Geburtsdatum',
alter, # 'Alter',
client.nationality, # 'Nationalität ISO Alpha2',
nationality_name(client.nationality), # 'Nationalität',
Client.acceptances[client.acceptance], # 'ID Prozess'
client.acceptance_t, # 'Prozess',
client.created_at.to_date, # 'Erstellt am',
'', # 'Fallführend',
Client.cost_units[client.cost_unit], # 'ID Kostenträger',
client.cost_unit_t, # 'Kostenträger',
'Was ist hier gemeint?', # 'Einsatz',
zeit_anmeldung_vermittlung, # 'Zeit (von Anmeldung bis Vermittlung)',
'was für eine Zeit?' # 'Zeit'
'', # 'AOZ Klienten ID',
client.id, # 'ID',
client.salutation, # 'ID Anrede',
t("salutation.#{client.salutation}"), # 'Anrede',
client.gender, # 'ID Geschlecht',
client.gender_t, # 'Geschlecht',
client.contact.last_name, # 'Nachname',
client.contact.first_name, # 'Vorname',
client.contact.postal_code, # 'PLZ',
client.contact.city, # 'Ort',
client.birth_year, # 'Geburtsdatum',
alter, # 'Alter',
client.nationality, # 'Nationalität ISO Alpha2',
nationality_name(client.nationality), # 'Nationalität',
Client.acceptances[client.acceptance], # 'ID Prozess'
client.acceptance_t, # 'Prozess',
client.created_at, # 'Erstellt am',
client.accepted_at, # 'Akzeptiert am',
client.resigned_at, # 'Beendet am',
client.rejected_at, # 'Abgelehnt am',
client.competent_authority, # 'Fallführend',
Client.cost_units[client.cost_unit], # 'ID Kostenträger',
client.cost_unit.present? ? client.cost_unit_t : '', # 'Kostenträger',
'', # 'Einsatz'
client.active_inactive_key, # 'ID Status'
t("state.#{client.active_inactive_key}"), # 'Status',
zeit_anmeldung_vermittlung, # 'Zeit (von Anmeldung bis Vermittlung)',
zeit # 'Zeit'
]
types = [
nil, # 'AOZ Klienten ID',
:integer, # 'id',
nil, # 'ID Anrede',
nil, # 'Anrede',
nil, # 'Nachname',
nil, # 'Vorname',
nil, # 'PLZ',
nil, # 'Ort',
nil, # 'Geschlecht',
nil, # 'Geburtsdatum',
:integer, # 'Alter',
nil, # 'Nationalität ISO Alpha2',
nil, # 'Nationalität',
:integer, # 'ID Prozess'
nil, # 'Prozess',
nil, # 'Erstellt am',
nil, # 'Fallführend',
:integer, # 'ID Kostenträger',
nil, # 'Kostenträger',
nil, # 'Einsatz',
:integer, # 'Zeit (von Anmeldung bis Vermittlung)',
nil # 'Zeit'
nil, # 'AOZ Klienten ID',
:integer, # 'id',
nil, # 'ID Anrede',
nil, # 'Anrede',
nil, # 'ID Geschlecht',
nil, # 'Geschlecht',
nil, # 'Nachname',
nil, # 'Vorname',
nil, # 'PLZ',
nil, # 'Ort',
nil, # 'Geburtsdatum',
:integer, # 'Alter',
nil, # 'Nationalität ISO Alpha2',
nil, # 'Nationalität',
:integer, # 'ID Prozess'
nil, # 'Prozess',
:time, # 'Erstellt am',
:time, # 'Akzeptiert am',
:time, # 'Beendet am',
:time, # 'Abgelehnt am',
nil, # 'Fallführend',
:integer, # 'ID Kostenträger',
nil, # 'Kostenträger',
nil, # 'Einsatz',
nil, # 'ID Status'
nil, # 'Status',
:integer, # 'Zeit (von Anmeldung bis Vermittlung)',
:time # 'Zeit'
]
style = [
standard_format, # 'AOZ Klienten ID',
standard_format, # 'id',
standard_format, # 'ID Anrede',
standard_format, # 'Anrede',
standard_format, # 'Nachname',
standard_format, # 'Vorname',
standard_format, # 'PLZ',
standard_format, # 'Ort',
standard_format, # 'Geschlecht',
date_format, # 'Geburtsdatum',
standard_format, # 'Alter',
standard_format, # 'Nationalität ISO Alpha2',
standard_format, # 'Nationalität',
standard_format, # 'ID Prozess'
standard_format, # 'Prozess',
date_format, # 'Erstellt am',
standard_format, # 'Fallführend',
standard_format, # 'ID Kostenträger',
standard_format, # 'Kostenträger',
standard_format, # 'Einsatz',
standard_format, # 'Zeit (von Anmeldung bis Vermittlung)',
standard_format # 'Zeit'
standard_format, # 'AOZ Klienten ID',
standard_format, # 'id',
standard_format, # 'ID Anrede',
standard_format, # 'Anrede',
standard_format, # 'ID Geschlecht',
standard_format, # 'Geschlecht',
standard_format, # 'Nachname',
standard_format, # 'Vorname',
standard_format, # 'PLZ',
standard_format, # 'Ort',
date_format, # 'Geburtsdatum',
standard_format, # 'Alter',
standard_format, # 'Nationalität ISO Alpha2',
standard_format, # 'Nationalität',
standard_format, # 'ID Prozess'
standard_format, # 'Prozess',
date_time_format, # 'Erstellt am',
date_time_format, # 'Akzeptiert am',
date_time_format, # 'Beendet am',
date_time_format, # 'Abgelehnt am',
standard_format, # 'Fallführend',
standard_format, # 'ID Kostenträger',
standard_format, # 'Kostenträger',
standard_format, # 'Einsatz',
standard_format, # 'ID Status'
standard_format, # 'Status',
standard_format, # 'Zeit (von Anmeldung bis Vermittlung)',
date_time_format # 'Zeit'
]
sheet.add_row(data, types: types, style: style)
end
......
......@@ -3,28 +3,31 @@ wb.add_worksheet(name: 'Standorte') do |sheet|
'ID',
'Name',
'Strasse',
'PLZ'
'PLZ',
'Zeit'
]
sheet.add_row(columns, style: header_style, height: 25)
departments.each do |department|
data = [
department.id, # ID'
department.contact.last_name, # 'Name'
department.contact.street, # 'Strasse'
department.contact.postal_code # 'PLZ'
department.id, # ID'
department.contact.last_name, # 'Name'
department.contact.street, # 'Strasse'
department.contact.postal_code, # 'PLZ'
zeit # 'Zeit'
]
types = [
:integer, # ID'
nil, # 'Name'
nil, # 'Strasse'
nil # 'PLZ'
nil, # 'PLZ'
:time # 'Zeit'
]
style = [
standard_format, # ID'
standard_format, # 'Name'
standard_format, # 'Strasse'
standard_format # 'PLZ'
standard_format, # 'PLZ'
date_time_format # 'Zeit'
]
sheet.add_row(data, types: types, style: style)
end
......
......@@ -16,32 +16,32 @@ wb.add_worksheet(name: 'Gruppenangebote') do |sheet|
sheet.add_row(columns, style: header_style, height: 25)
group_assignments.each do |group_assignment|
data = [
group_assignment.id, # 'ID'
'', # 'Status'
'', # 'Bezeichnung'
'', # 'Kategorie'
'', # 'Internes oder externes Gruppenangebot'
'', # 'Standort'
group_assignment.created_at&.to_date, # 'Erstellt am'
group_assignment.period_start.presence || '', # 'Startdatum'
group_assignment.period_end.presence || '', # 'Angebotsenddatum'
'', # 'Dauer in Monaten'
'', # 'Einsatz'
'' # 'Zeit'
group_assignment.id, # 'ID'
'', # 'Status'
'', # 'Bezeichnung'
'', # 'Kategorie'
'', # 'Internes oder externes Gruppenangebot'
'', # 'Standort'
group_assignment.created_at, # 'Erstellt am'
group_assignment.period_start, # 'Startdatum'
group_assignment.period_end, # 'Angebotsenddatum'
'', # 'Dauer in Monaten'
'', # 'Einsatz'
zeit # 'Zeit'
]
types = [
:integer, # 'ID'
nil, # 'Status'
nil, # 'Bezeichnung'
nil, # 'Kategorie'
nil, # 'Internes oder externes Gruppenangebot'
nil, # 'Standort'
:date, # 'Erstellt am'
:date, # 'Startdatum'
:date, # 'Angebotsenddatum'
nil, # 'Dauer in Monaten'
nil, # 'Einsatz'
nil # 'Zeit'
:integer, # 'ID'
nil, # 'Status'
nil, # 'Bezeichnung'
nil, # 'Kategorie'
nil, # 'Internes oder externes Gruppenangebot'
nil, # 'Standort'
:time, # 'Erstellt am'
:date, # 'Startdatum'
:date, # 'Angebotsenddatum'
nil, # 'Dauer in Monaten'
nil, # 'Einsatz'
:time # 'Zeit'
]
style = [
......@@ -51,12 +51,12 @@ wb.add_worksheet(name: 'Gruppenangebote') do |sheet|
standard_format, # 'Kategorie'
standard_format, # 'Internes oder externes Gruppenangebot'
standard_format, # 'Standort'
date_format, # 'Erstellt am'
date_time_format, # 'Erstellt am'
date_format, # 'Startdatum'
date_format, # 'Angebotsenddatum'
standard_format, # 'Dauer in Monaten'
standard_format, # 'Einsatz'
standard_format # 'Zeit'
date_time_format # 'Zeit'
]
sheet.add_row(data, types: types, style: style)
end
......
......@@ -29,13 +29,13 @@ wb.add_worksheet(name: 'Gruppenangebote') do |sheet|
t("offer_type.#{group_offer.offer_type}"), # 'Internes oder externes Gruppenangebot'
group_offer.department.id, # 'ID Standort'
group_offer.department&.contact&.last_name, # 'Standort'
group_offer.created_at.to_date, # 'Erstellt am'
group_offer.created_at, # 'Erstellt am'
group_offer.period_start, # 'Startdatum'
group_offer.period_end, # 'Angebotsenddatum'
group_offer.terminated?, # 'Beendet'
'', # 'Dauer in Monaten'
'', # 'Einsatz'
'' # 'Zeit'
zeit # 'Zeit'
]
types = [
:integer, # 'ID'
......@@ -47,12 +47,12 @@ wb.add_worksheet(name: 'Gruppenangebote') do |sheet|
nil, # 'Internes oder externes Gruppenangebot'
:integer, # 'ID Standort'
nil, # 'Standort'
nil, # 'Erstellt am'
:time, # 'Erstellt am'
nil, # 'Startdatum'
nil, # 'Angebotsenddatum'
nil, # 'Dauer in Monaten'
nil, # 'Einsatz'
nil # 'Zeit'
:time # 'Zeit'
]
style = [
......@@ -65,12 +65,12 @@ wb.add_worksheet(name: 'Gruppenangebote') do |sheet|
standard_format, # 'Internes oder externes Gruppenangebot'
standard_format, # 'ID Standort'
standard_format, # 'Standort'
date_format, # 'Erstellt am'
date_time_format, # 'Erstellt am'
date_format, # 'Startdatum'
date_format, # 'Angebotsenddatum'
standard_format, # 'Dauer in Monaten'
standard_format, # 'Einsatz'
standard_format # 'Zeit'
date_time_format # 'Zeit'
]
sheet.add_row(data, types: types, style: style)
end
......
wb.add_worksheet(name: 'Matching GA und FW') do |sheet|
wb.add_worksheet(name: 'Gruppeneinsatz') do |sheet|
columns = [
'ID',
'ID Gruppenangebot',
......@@ -6,6 +6,7 @@ wb.add_worksheet(name: 'Matching GA und FW') do |sheet|
'Erstellt am',
'Startdatum',
'Enddatum',
'ID Status',
'Status',
'Zeit'
]
......@@ -15,31 +16,34 @@ wb.add_worksheet(name: 'Matching GA und FW') do |sheet|
group_assignment.id, # ID
group_assignment.group_offer.id, # 'ID Gruppenangebot'
group_assignment.volunteer.id, # 'ID Freiwillige/r'
group_assignment.created_at.to_date, # 'Erstellt am'
group_assignment.created_at, # 'Erstellt am'
group_assignment.period_start, # 'Startdatum'