Skip to content

Commit

Permalink
Merge pull request #265 from diegosteiner/develop
Browse files Browse the repository at this point in the history
2023.11.1
  • Loading branch information
diegosteiner committed Nov 5, 2023
2 parents d4e7a2f + 3e39135 commit e3825df
Show file tree
Hide file tree
Showing 150 changed files with 683 additions and 487 deletions.
5 changes: 4 additions & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ require:

AllCops:
NewCops: enable
TargetRubyVersion: 3.0
TargetRubyVersion: 3.2
Exclude:
- "bin/*"
- "script/**/*"
Expand Down Expand Up @@ -75,6 +75,9 @@ Style/GlobalVars:
Style/SymbolProc:
Enabled: false

# RSpec/MultipleExpectations:
# Max: 3

# TODO: bug with false positives
Lint/UnusedMethodArgument:
Enabled: false
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

## Version 23.11.1

- Bugfixes

## Version 23.10.2

- Improvement: Recognize payment duplicates more accurately
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
V23.10.2
V23.11.1
4 changes: 2 additions & 2 deletions app/concerns/template_renderable.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

module TemplateRenderable
def to_partial_path(*template)
File.join('renderables', self.class.to_s.underscore, *template)
def to_partial_path(*)
File.join('renderables', self.class.to_s.underscore, *)
end
end
4 changes: 2 additions & 2 deletions app/concerns/translatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ def translatable_scope

def translate(key = :label, **options)
scope = translatable_scope + Array.wrap(options.delete(:scope))
Rails.logger.debug({ key: key, scope: scope, options: options }) if options.delete(:debug)
I18n.t(key, **options.reverse_merge(scope: scope, default: nil))
Rails.logger.debug({ key:, scope:, options: }) if options.delete(:debug)
I18n.t(key, **options.reverse_merge(scope:, default: nil))
end
alias t translate
end
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def current_ability

def responder_flash_messages(resource_name, scope: :update)
{
notice: t(:notice, scope: %i[flash actions] + [scope], resource_name: resource_name),
error: t(:alert, scope: %i[flash actions] + [scope], resource_name: resource_name)
notice: t(:notice, scope: %i[flash actions] + [scope], resource_name:),
error: t(:alert, scope: %i[flash actions] + [scope], resource_name:)
}
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/manage/bookings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def import!
home = organisation.homes.find(home_id)
headers = self.headers.presence&.split(/[,;]/) || true

::Import::Csv::BookingImporter.new(home, initial_state: initial_state, csv: { headers: headers })
::Import::Csv::BookingImporter.new(home, initial_state:, csv: { headers: })
.parse_file(file)
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/manage/organisation_users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def create
else
email = params.dig(:organisation_user, :email)
onboarding = OnboardingService.new(current_organisation)
@organisation_user = onboarding.add_or_invite_user!(email: email, role: organisation_user_params[:role],
@organisation_user = onboarding.add_or_invite_user!(email:, role: organisation_user_params[:role],
invited_by: current_user)
end
respond_with :manage, @organisation_user, location: manage_organisation_users_path
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/public/calendars_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def private_ical_feed
respond_to do |format|
format.ics do
render plain: IcalService.new.occupancies_to_ical(@calendar.occupancies,
include_tenant_details: include_tenant_details)
include_tenant_details:)
end
end
end
Expand All @@ -33,15 +33,15 @@ def at
date = parse_date(params[:date])
occupancies = Occupancy.accessible_by(current_ability).merge(@occupiable.occupancies)
manage = current_organisation_user.present? || current_user&.role_admin.presence
redirect_to OccupancyAtService.new(@occupiable, occupancies).redirect_to(date, manage: manage)
redirect_to OccupancyAtService.new(@occupiable, occupancies).redirect_to(date, manage:)
end

private

def parse_date(value, format: nil)
return if value.blank?

Date.parse(value, format: format)
Date.parse(value, format:)
rescue Date::Error, TypeError
nil
end
Expand All @@ -50,7 +50,7 @@ def set_calendar
window_from = current_organisation_user.present? ? 2.months.ago : Time.zone.now.beginning_of_day

@calendar = OccupancyCalendar.new(organisation: current_organisation, occupiables: @occupiable,
window_from: window_from)
window_from:)
end
end
end
2 changes: 1 addition & 1 deletion app/controllers/public/occupancies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def set_calendar
window_from = current_organisation_user.present? ? 2.months.ago : Time.zone.now.beginning_of_day

@calendar = OccupancyCalendar.new(organisation: current_organisation, occupiables: @home.occupiables,
window_from: window_from)
window_from:)
end
end
end
2 changes: 1 addition & 1 deletion app/domain/booking_actions/manage/accept.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module BookingActions
module Manage
class Accept < BookingActions::Base
def call!
Result.new ok: booking.update(transition_to: transition_to)
Result.new ok: booking.update(transition_to:)
end

def allowed?
Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_actions/manage/cancel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def call!
elsif booking.can_transition_to?(:cancelation_pending)
:cancelation_pending
end
Result.new ok: booking.update(transition_to: transition_to)
Result.new ok: booking.update(transition_to:)
end

def allowed?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def prepare_attachments

def prepare_notification
booking.notifications.new(template: :awaiting_contract_notification, to: booking.tenant,
template_context: { contract: contract, invoices: invoices }).tap do |notification|
template_context: { contract:, invoices: }).tap do |notification|
notification.bcc = operator.email if operator&.email.present?
notification.attach(prepare_attachments)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def prepare_attachments(booking, contract)

def prepare_notification
booking.notifications.new(template: :awaiting_contract_notification, to: booking.tenant,
template_context: { contract: contract }).tap do |notification|
template_context: { contract: }).tap do |notification|
notification.attach(prepare_attachments(booking, contract))
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_actions/manage/email_invoices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def invoices

def prepare_notification
booking.notifications.new(template: :payment_due_notification, to: booking.tenant,
template_context: { invoices: invoices }) do |notification|
template_context: { invoices: }) do |notification|
notification.bcc = operator.email if operator&.email.present?
notification.attach(prepare_attachments)
end
Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_actions/public/cancel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def call!
elsif booking.can_transition_to?(:cancelation_pending)
:cancelation_pending
end
Result.new ok: booking.update(transition_to: transition_to)
Result.new ok: booking.update(transition_to:)
end

def allowed?
Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_flows/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def callbacks

def state(state_class, initial: false, to: [])
state_classes[state_class.to_sym] = state_class
super(state_class, initial: initial)
super(state_class, initial:)
successors[state_class.to_s] = [successors[state_class.to_s], to].flatten.compact.map(&:to_s)
state_class.callbacks.each do |callback_type, state_callbacks|
callbacks[callback_type] += state_callbacks
Expand Down
14 changes: 7 additions & 7 deletions app/domain/booking_states/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,31 +40,31 @@ def callbacks
def add_callback(callback_type: nil, callback_class: Statesman::Callback, from: nil, to: to_s, &block)
from = from&.to_s
to = Array(to).compact_blank.map(&:to_s)
callbacks[callback_type] << callback_class.new(from: from, to: to, callback: block)
callbacks[callback_type] << callback_class.new(from:, to:, callback: block)
end

def infer_transition(to: nil, &block)
add_callback(callback_type: :infer, from: to_sym, to: to, &block)
add_callback(callback_type: :infer, from: to_sym, to:, &block)
end

def before_transition(from: nil, &block)
add_callback(callback_type: :before, from: from, &block)
add_callback(callback_type: :before, from:, &block)
end

def after_transition(from: nil, &block)
add_callback(callback_type: :after, from: from, &block)
add_callback(callback_type: :after, from:, &block)
end

def after_transition_failure(from: nil, &block)
add_callback(callback_type: :after_transition_failure, from: from, &block)
add_callback(callback_type: :after_transition_failure, from:, &block)
end

def after_guard_failure(from: nil, &block)
add_callback(callback_type: :after_guard_failure, from: from, &block)
add_callback(callback_type: :after_guard_failure, from:, &block)
end

def guard_transition(from: nil, &block)
add_callback(callback_type: :guards, callback_class: Statesman::Guard, from: from, &block)
add_callback(callback_type: :guards, callback_class: Statesman::Guard, from:, &block)
end

def occupied_occupancy_state?(booking)
Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_states/booking_agent_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def self.to_sym
end

infer_transition(to: :awaiting_tenant) do |booking|
booking.agent_booking.valid? && booking.agent_booking.committed_request
booking.agent_booking.valid? && booking.committed_request
end

def relevant_time
Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_states/definitive_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def self.to_sym
booking.deadline&.clear
OperatorResponsibility.assign(booking, :home_handover, :home_return)
to = booking.responsibilities[:administration] || booking.organisation
booking.notifications.new(template: :manage_definitive_request_notification, to: to)&.deliver
booking.notifications.new(template: :manage_definitive_request_notification, to:)&.deliver
booking.notifications.new(template: :definitive_request_notification, to: booking.tenant).deliver
end

Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_states/open_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def self.to_sym
booking.deadline&.clear
OperatorResponsibility.assign(booking, :administration, :billing)
to = booking.responsibilities[:administration] || booking.organisation
booking.notifications.new(template: :manage_new_booking_notification, to: to)&.deliver
booking.notifications.new(template: :manage_new_booking_notification, to:)&.deliver
if booking.agent_booking.present?
# booking.notifications.new(template: :open_booking_agent_request_notification,
# to: booking.agent_booking.booking_agent).deliver
Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_states/overdue_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.to_sym
after_transition do |booking|
booking.deadline&.clear
length = booking.organisation.settings.overdue_request_deadline
booking.deadlines.create(length: length, remarks: booking.booking_state.t(:label)) unless length.negative?
booking.deadlines.create(length:, remarks: booking.booking_state.t(:label)) unless length.negative?
booking.notifications.new(template: :overdue_request_notification, to: booking.tenant)&.deliver
end

Expand Down
2 changes: 1 addition & 1 deletion app/domain/booking_states/payment_due.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def self.to_sym

payable_until = invoice.payable_until + booking.organisation.settings.payment_overdue_deadline
postponable_for = booking.organisation.settings.deadline_postponable_for
booking.deadlines.create(at: payable_until, postponable_for: postponable_for) unless booking.deadline
booking.deadlines.create(at: payable_until, postponable_for:) unless booking.deadline
end

infer_transition(to: :payment_overdue) do |booking|
Expand Down
4 changes: 1 addition & 3 deletions app/mailers/organisation_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ def booking_email(notification)
attach_active_storage_attachments(notification.attachments)
mail(to: notification.to, cc: notification.cc, bcc: notification.bcc, subject: notification.subject) do |format|
format.text { render plain: @notification.text }
# rubocop:disable Rails/OutputSafety
format.html { render html: @notification.body&.html_safe }
# rubocop:enable Rails/OutputSafety
format.html { render html: @notification.html }
end
end

Expand Down
Loading

0 comments on commit e3825df

Please sign in to comment.