Skip to content

Commit e26d7d6

Browse files
authored
Merge branch 'master' into feature/64444-export-invoicing-controlling
2 parents d2fe5bc + f6b0e0f commit e26d7d6

38 files changed

+236
-86
lines changed

.rubocop_todo.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This configuration was generated by
22
# `rubocop --auto-gen-config`
3-
# on 2025-12-03 15:37:34 UTC using RuboCop version 1.75.3.
3+
# on 2025-12-09 20:43:27 UTC using RuboCop version 1.75.3.
44
# The point is for the user to remove these configuration records
55
# one by one as the offenses are removed from the code base.
66
# Note that changes in the inspected code, or installation of new
@@ -61,18 +61,18 @@ Lint/UnreachableLoop:
6161
Exclude:
6262
- 'app/models/working_condition.rb'
6363

64-
# Offense count: 110
64+
# Offense count: 111
6565
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
6666
Metrics/AbcSize:
6767
Max: 282
6868

69-
# Offense count: 55
69+
# Offense count: 56
7070
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
7171
# AllowedMethods: refine
7272
Metrics/BlockLength:
7373
Max: 97
7474

75-
# Offense count: 38
75+
# Offense count: 39
7676
# Configuration parameters: CountComments, CountAsOne.
7777
Metrics/ClassLength:
7878
Max: 314
@@ -82,15 +82,15 @@ Metrics/ClassLength:
8282
Metrics/CyclomaticComplexity:
8383
Max: 13
8484

85-
# Offense count: 129
85+
# Offense count: 131
8686
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
8787
Metrics/MethodLength:
8888
Max: 312
8989

9090
# Offense count: 5
9191
# Configuration parameters: CountComments, CountAsOne.
9292
Metrics/ModuleLength:
93-
Max: 157
93+
Max: 162
9494

9595
# Offense count: 2
9696
# Configuration parameters: CountKeywordArgs.
@@ -177,13 +177,12 @@ Naming/PredicateName:
177177
- 'app/helpers/dry_crud/form/builder.rb'
178178
- 'app/models/concerns/belonging_to_work_item.rb'
179179

180-
# Offense count: 15
180+
# Offense count: 14
181181
# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
182182
# SupportedStyles: snake_case, normalcase, non_integer
183183
# AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
184184
Naming/VariableNumber:
185185
Exclude:
186-
- 'test/controllers/clients_controller_test.rb'
187186
- 'test/controllers/contacts_controller_test.rb'
188187
- 'test/controllers/invoices_controller_test.rb'
189188
- 'test/controllers/orders_controller_test.rb'
@@ -229,7 +228,7 @@ Rails/HasManyOrHasOneDependent:
229228
- 'app/models/service.rb'
230229
- 'app/models/work_item.rb'
231230

232-
# Offense count: 61
231+
# Offense count: 62
233232
# Configuration parameters: Include.
234233
# Include: app/helpers/**/*.rb
235234
Rails/HelperInstanceVariable:
@@ -316,7 +315,7 @@ Rails/ReversibleMigration:
316315
- 'db/migrate/20160919101807_add_daily_plannings.rb'
317316
- 'db/migrate/20161222162235_move_probation_period_end_date_to_employee.rb'
318317

319-
# Offense count: 45
318+
# Offense count: 46
320319
# Configuration parameters: ForbiddenMethods, AllowedMethods.
321320
# ForbiddenMethods: decrement!, decrement_counter, increment!, increment_counter, insert, insert!, insert_all, insert_all!, toggle!, touch, touch_all, update_all, update_attribute, update_column, update_columns, update_counters, upsert, upsert_all
322321
Rails/SkipsModelValidations:
@@ -386,7 +385,7 @@ Style/ConditionalAssignment:
386385
Exclude:
387386
- 'app/controllers/concerns/worktimes_report.rb'
388387

389-
# Offense count: 324
388+
# Offense count: 326
390389
# Configuration parameters: AllowedConstants.
391390
Style/Documentation:
392391
Enabled: false
@@ -429,7 +428,7 @@ Style/OpenStructUse:
429428
Style/OptionalBooleanParameter:
430429
Enabled: false
431430

432-
# Offense count: 66
431+
# Offense count: 71
433432
# This cop supports safe autocorrection (--autocorrect).
434433
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
435434
# URISchemes: http, https

app/controllers/concerns/cockpit_csv.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@ def send_cockpit_csv(cockpit, filename)
1919

2020
def cockpit_csv(cockpit)
2121
CSV.generate do |csv|
22-
csv << ['Position', 'Budget', 'Geleistete Stunden', 'Nicht verrechenbar', 'Offenes Budget', 'Geplantes Budget']
22+
csv << ['Position', 'Name der Position', 'Budget', 'Geleistete Stunden', 'Nicht verrechenbar', 'Offenes Budget', 'Geplantes Budget']
2323
cockpit.rows.each do |row|
2424
csv << [row.respond_to?(:shortnames) ? row.shortnames : 'Total',
25+
row.respond_to?(:name) ? row.name : '',
2526
row.cells[:budget].hours,
2627
row.cells[:supplied_services].hours,
2728
row.cells[:not_billable].hours,

app/controllers/employee_master_data_controller.rb

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,24 @@ def show
4848
private
4949

5050
def list_entries
51-
list_entries_includes(
52-
Employee.select('employees.*, ' \
53-
'em.percent AS current_percent_value, ' \
54-
'departments.name, ' \
55-
'CONCAT(lastname, \' \', firstname) AS fullname')
51+
query =
52+
Employee
53+
.left_joins(:department, :member_coach)
5654
.employed_ones(Period.current_day)
57-
.joins('LEFT JOIN departments ON departments.id = employees.department_id')
58-
).list
55+
.select(
56+
employees: ['*'],
57+
departments: [:name],
58+
em: ['percent AS current_percent_value']
59+
)
60+
.select("CONCAT(employees.lastname, ' ', employees.firstname) AS fullname")
61+
.select("CONCAT(member_coaches_employees.lastname, ' ', member_coaches_employees.firstname) AS member_coach")
62+
63+
list_entries_includes(query).list
5964
end
6065

6166
def list_entries_includes(list)
6267
if can?(:manage, Employment)
63-
list.includes(:department, :employments, current_employment: {
68+
list.includes(:member_coach, :department, :employments, current_employment: {
6469
employment_roles_employments: %i[
6570
employment_role
6671
employment_role_level
@@ -124,6 +129,7 @@ def qr_code
124129
self.search_columns = ['lastname', 'firstname', 'shortname', 'departments.name']
125130
self.sort_mappings_with_indifferent_access = {
126131
department: 'departments.name',
132+
member_coach: 'member_coach',
127133
fullname: 'fullname',
128134
current_percent_value: 'current_percent_value'
129135
}.with_indifferent_access

app/controllers/employees_controller.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# https://github.com/puzzle/puzzletime.
77

88
class EmployeesController < ManageController
9-
self.permitted_attrs = [:firstname, :lastname, :shortname, :email, :ldapname,
10-
:department_id, :workplace_id, :crm_key, :probation_period_end_date,
9+
self.permitted_attrs = [:firstname, :lastname, :shortname, :email, :ldapname, :department_id,
10+
:member_coach_id, :workplace_id, :crm_key, :probation_period_end_date,
1111
:graduation, :management, :phone_office, :phone_private,
1212
:street, :postal_code, :city, :birthday, :emergency_contact_name,
1313
:emergency_contact_phone, :marital_status,
@@ -19,7 +19,7 @@ class EmployeesController < ManageController
1919

2020
self.search_columns = %i[firstname lastname shortname]
2121

22-
self.sort_mappings = { department_id: 'departments.name' }
22+
self.sort_mappings = { department_id: 'departments.name', member_coach: 'CONCAT(member_coaches_employees.lastname, member_coaches_employees.firstname)' }
2323

2424
def show
2525
return if Crm.instance.blank?
@@ -51,6 +51,6 @@ def update_settings
5151
private
5252

5353
def list_entries
54-
super.includes(:department).references(:department)
54+
super.includes(:department, :member_coach).references(:department)
5555
end
5656
end

app/controllers/evaluator_controller.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class EvaluatorController < ApplicationController
1313

1414
before_action :set_period
1515

16-
helper_method :search_conditions, :evaluation_type
16+
helper_method :worktime_search_conditions, :evaluation_type
1717

1818
def index
1919
overview
@@ -111,7 +111,7 @@ def set_default_evaluation
111111
params[:evaluation] = 'usersubworkitems'
112112
Evaluations::EmployeeSubWorkItemsEval.new(params[:category_id], @user.id)
113113
when 'userabsences' then Evaluations::EmployeeAbsencesEval.new(
114-
@user.id, **search_conditions
114+
@user.id, **worktime_search_conditions
115115
)
116116
when 'subworkitems' then Evaluations::SubWorkItemsEval.new(params[:category_id])
117117
when 'workitememployees' then Evaluations::WorkItemEmployeesEval.new(params[:category_id])
@@ -124,24 +124,25 @@ def set_default_params
124124
case params[:evaluation].downcase
125125
when 'employees'
126126
params[:department_id] = current_user.department_id unless params.key?(:department_id)
127+
params[:member_coach_id] = current_user.id unless params.key?(:member_coach_id)
127128
end
128129
end
129130

130131
def set_management_evaluation
131132
@evaluation =
132133
case params[:evaluation].downcase
133134
when 'clients' then Evaluations::ClientsEval.new
134-
when 'employees' then Evaluations::EmployeesEval.new(params[:department_id])
135+
when 'employees' then Evaluations::EmployeesEval.new(params.slice(:department_id, :member_coach_id))
135136
when 'departments' then Evaluations::DepartmentsEval.new
136137
when 'clientworkitems' then Evaluations::ClientWorkItemsEval.new(params[:category_id])
137138
when 'employeeworkitems' then Evaluations::EmployeeWorkItemsEval.new(params[:category_id])
138139
when /employeesubworkitems(\d+)/ then Evaluations::EmployeeSubWorkItemsEval.new(
139140
params[:category_id], Regexp.last_match[1]
140141
)
141142
when 'departmentorders' then Evaluations::DepartmentOrdersEval.new(params[:category_id])
142-
when 'absences' then Evaluations::AbsencesEval.new(**search_conditions)
143+
when 'absences' then Evaluations::AbsencesEval.new(params[:department_id], **worktime_search_conditions)
143144
when 'employeeabsences' then Evaluations::EmployeeAbsencesEval.new(
144-
params[:category_id], **search_conditions
145+
params[:category_id], **worktime_search_conditions
145146
)
146147
end
147148
end
@@ -223,7 +224,7 @@ def init_periods
223224
end
224225
end
225226

226-
def search_conditions
227+
def worktime_search_conditions
227228
return {} if params[:absence_id].blank?
228229

229230
{ absence_id: params[:absence_id] }

app/controllers/invoice_reports_controller.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,26 @@ def index
3131
end
3232
end
3333

34+
def sync
35+
if params['invoice_id'].blank?
36+
flash[:error] = 'Interner Puzzletime Fehler beim Sync der Rechnung' # rubocop:disable Rails/I18nLocaleTexts
37+
redirect_to reports_invoices_path(params.to_unsafe_h)
38+
return
39+
end
40+
41+
invoice = Invoice.find(params[:invoice_id])
42+
43+
if Invoicing.instance
44+
begin
45+
Invoicing.instance.sync_invoice(invoice)
46+
flash[:notice] = "Die Rechnung #{invoice} wurde aktualisiert."
47+
rescue Invoicing::Error => e
48+
flash[:error] = "Fehler im Invoicing Service: #{e.message}"
49+
end
50+
end
51+
redirect_to reports_invoices_path(params.to_unsafe_h)
52+
end
53+
3454
private
3555

3656
def set_filter_values

app/controllers/workload_report_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ def set_department
3434
@department = Department.where(id: params[:department_id]).first
3535
end
3636

37-
# rubocop:disable Naming/MemoizedInstanceVariableName
3837
def set_period
3938
super
4039
@period ||= default_period
40+
session[:period] = [@period.start_date.to_s, @period.end_date.to_s, @period.label]
4141
end
42-
# rubocop:enable Naming/MemoizedInstanceVariableName
4342

4443
def default_period
4544
month = Time.zone.today.last_month

app/domain/evaluations/absences_eval.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,19 @@ class AbsencesEval < Evaluations::Evaluation
1414
self.detail_columns = detail_columns.reject { |i| i == :billable }
1515
self.detail_labels = detail_labels.merge(account: 'Absenz')
1616

17-
def initialize(**search_conditions)
18-
super(Employee, **search_conditions)
17+
attr_reader :department_id
18+
19+
def initialize(department_id = nil, **worktime_search_conditions)
20+
super(Employee, **worktime_search_conditions)
21+
@department_id = department_id
1922
end
2023

2124
def divisions(period = nil)
22-
Employee.employed_ones(period || Period.current_year)
25+
scope = Employee.employed_ones(period || Period.current_year)
26+
27+
return scope if department_id.blank?
28+
29+
scope.where(department_id:)
2330
end
2431

2532
def employee_id

app/domain/evaluations/employee_absences_eval.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ class EmployeeAbsencesEval < Evaluations::Evaluation
1515
self.detail_columns = detail_columns.reject { |i| i == :billable }
1616
self.detail_labels = detail_labels.merge(account: 'Absenz')
1717

18-
def initialize(employee_id, **search_conditions)
19-
super(Employee.find(employee_id), **search_conditions)
18+
def initialize(employee_id, **worktime_search_conditions)
19+
super(Employee.find(employee_id), **worktime_search_conditions)
2020
end
2121

2222
def for?(user)

app/domain/evaluations/employees_eval.rb

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ class EmployeesEval < Evaluations::Evaluation
1212
self.label = 'Member Zeit'
1313
self.total_details = false
1414

15-
def initialize(department_id = 0)
16-
@department_id = department_id.to_i
15+
def initialize(emp_search_conditions = {})
16+
@department_id = emp_search_conditions[:department_id].to_i
17+
@member_coach_id = emp_search_conditions[:member_coach_id].to_i
1718
super(Employee)
1819
end
1920

@@ -23,30 +24,35 @@ def divisions(period = nil)
2324
else
2425
Employee.employed_ones(Period.current_year)
2526
end
27+
employees = employees.where(member_coach_id: @member_coach_id) unless @member_coach_id.zero?
28+
employees = employees.where(department_id: @department_id) unless @department_id.zero?
2629

27-
if @department_id.zero?
28-
employees
29-
else
30-
employees.where(department_id: @department_id)
31-
end
30+
employees
3231
end
3332

3433
def employee_id
3534
division&.id
3635
end
3736

3837
def sum_total_times(period = nil)
39-
query = if @department_id.zero?
38+
query = if @department_id.zero? && @member_coach_id.zero?
4039
Worktime.all
41-
else
40+
elsif @member_coach_id.zero?
4241
Department.find(@department_id).employee_worktimes
42+
elsif @department_id.zero?
43+
Worktime.joins(:employee)
44+
.where(employees: { member_coach_id: @member_coach_id })
45+
else
46+
Worktime.joins(:employee)
47+
.where(employees: { department_id: @department_id, member_coach_id: @member_coach_id })
4348
end
4449
query = query.where(type: worktime_type).in_period(period)
4550
query_time_sums(query)
4651
end
4752

4853
def division_supplement(_user)
4954
[[:overtime, 'Überstunden', 'right'],
55+
[:vacations, 'Ferien', 'right'],
5056
[:overtime_vacations_tooltip, '', 'left'],
5157
[:worktime_commits, 'Freigabe', 'left'],
5258
[:worktime_reviews, 'Kontrolle', 'left']]

0 commit comments

Comments
 (0)