-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #384 from diegosteiner/refactor/settings_model
feat: booking state editable as setting
- Loading branch information
Showing
41 changed files
with
257 additions
and
270 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
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
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
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
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
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 |
---|---|---|
@@ -1,20 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
module BookingStates | ||
def self.[](key) | ||
all[key&.to_sym] | ||
end | ||
|
||
def self.all | ||
@all ||= [ | ||
UnconfirmedRequest, OpenRequest, ProvisionalRequest, DefinitiveRequest, BookingAgentRequest, AwaitingTenant, | ||
AwaitingContract, Overdue, UpcomingSoon, Upcoming, Active, Past, PaymentDue, CancelationPending, Completed, | ||
CancelledRequest, DeclinedRequest, Cancelled, OverdueRequest, PaymentOverdue, Initial | ||
].index_by(&:to_sym) | ||
end | ||
|
||
def self.displayed_by_default | ||
all.values.filter_map { |state| state.to_sym unless state.hidden } | ||
end | ||
|
||
def self.occupied_occupancy_able | ||
@occupied_occupancy_able ||= [DefinitiveRequest, AwaitingTenant, AwaitingContract, | ||
Upcoming, UpcomingSoon].index_by(&:to_sym) | ||
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
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
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
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
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 |
---|---|---|
|
@@ -17,9 +17,5 @@ def self.to_sym | |
def self.hidden | ||
true | ||
end | ||
|
||
def editable | ||
true | ||
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 |
---|---|---|
|
@@ -14,10 +14,6 @@ def invoice_type | |
Invoices::Deposit | ||
end | ||
|
||
def editable | ||
true | ||
end | ||
|
||
def self.to_sym | ||
:open_request | ||
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
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
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
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
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
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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
class BookingStateSettings | ||
include StoreModel::Model | ||
extend ActiveModel::Naming | ||
extend ActiveModel::Translation | ||
|
||
attribute :default_manage_transition_to_state, :string, default: -> { BookingStates::ProvisionalRequest.to_s } | ||
attribute :occupied_occupancy_states, array: true, default: lambda { | ||
BookingFlows::Default.occupied_by_default.map(&:to_sym) | ||
} | ||
attribute :editable_occupancy_states, array: true, default: lambda { | ||
BookingFlows::Default.editable_by_default.map(&:to_sym) | ||
} | ||
|
||
def self.manage_transition_to_states(organisation) | ||
organisation.booking_flow_class.successors['initial'].map { BookingStates[_1.to_sym] }.compact_blank | ||
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,22 @@ | ||
# frozen_string_literal: true | ||
|
||
class DeadlineSettings | ||
include StoreModel::Model | ||
extend ActiveModel::Naming | ||
extend ActiveModel::Translation | ||
|
||
attribute :awaiting_contract_deadline, DurationType.new, default: -> { 10.days } | ||
attribute :awaiting_tenant_deadline, DurationType.new, default: -> { 10.days } | ||
attribute :overdue_request_deadline, DurationType.new, default: -> { 3.days } | ||
attribute :payment_overdue_deadline, DurationType.new, default: -> { 3.days } | ||
attribute :unconfirmed_request_deadline, DurationType.new, default: -> { 3.days } | ||
attribute :provisional_request_deadline, DurationType.new, default: -> { 10.days } | ||
attribute :invoice_payment_deadline, DurationType.new, default: -> { 30.days } | ||
attribute :deposit_payment_deadline, DurationType.new, default: -> { 10.days } | ||
attribute :deadline_postponable_for, DurationType.new, default: -> { 3.days } | ||
|
||
validates :awaiting_contract_deadline, :awaiting_tenant_deadline, :overdue_request_deadline, | ||
:payment_overdue_deadline, :unconfirmed_request_deadline, :provisional_request_deadline, | ||
:invoice_payment_deadline, :deposit_payment_deadline, :deadline_postponable_for, | ||
numericality: { less_than_or_equal: 5.years, greater_than_or_equal: 0 } | ||
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
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
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
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
Oops, something went wrong.