Skip to content

Commit

Permalink
feature: booking without invoice
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosteiner committed Dec 31, 2023
1 parent 40521fe commit 8975530
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 81 deletions.
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 @@ -29,7 +29,7 @@ def self.to_sym
end

infer_transition(to: :upcoming) do |booking|
booking.contracts.sent.none? && booking.tenant&.allow_bookings_without_contract
booking.contracts.sent.none? && booking.tenant&.bookings_without_contract
end

infer_transition(to: :awaiting_contract) do |booking|
Expand Down
4 changes: 4 additions & 0 deletions app/domain/booking_states/past.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ def self.to_sym
invoices.any?(&:sent?) || (invoices.any? && invoices.none?(&:unsettled?))
end

infer_transition(to: :completed) do |booking|
booking.tenant.bookings_without_invoice
end

def relevant_time
booking.ends_at
end
Expand Down
46 changes: 23 additions & 23 deletions app/models/tenant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
#
# Table name: tenants
#
# id :bigint not null, primary key
# address_addon :string
# allow_bookings_without_contract :boolean default(FALSE)
# birth_date :date
# city :string
# country_code :string default("CH")
# email :string
# email_verified :boolean default(FALSE)
# first_name :string
# iban :string
# import_data :jsonb
# last_name :string
# locale :string default("de"), not null
# nickname :string
# phone :text
# remarks :text
# reservations_allowed :boolean default(TRUE)
# search_cache :text not null
# street_address :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
# organisation_id :bigint not null
# id :bigint not null, primary key
# address_addon :string
# birth_date :date
# bookings_without_contract :boolean default(FALSE)
# bookings_without_invoice :boolean default(FALSE)
# city :string
# country_code :string default("CH")
# email :string
# email_verified :boolean default(FALSE)
# first_name :string
# import_data :jsonb
# last_name :string
# locale :string default("de"), not null
# nickname :string
# phone :text
# remarks :text
# reservations_allowed :boolean default(TRUE)
# search_cache :text not null
# street_address :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
# organisation_id :bigint not null
#
# Indexes
#
Expand Down
2 changes: 1 addition & 1 deletion app/params/manage/tenant_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Manage
class TenantParams < Public::TenantParams
def self.permitted_keys
super + %i[reservations_allowed remarks allow_bookings_without_contract]
super + %i[reservations_allowed remarks bookings_without_contract bookings_without_invoice]
end
end
end
2 changes: 1 addition & 1 deletion app/params/public/tenant_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Public
class TenantParams < ApplicationParams
def self.permitted_keys
%i[first_name last_name street_address zipcode city email birth_date country_code nickname phone
address_addon iban locale]
address_addon locale]
end
end
end
4 changes: 2 additions & 2 deletions app/views/manage/tenants/_form.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

= f.text_field :phone
= f.date_select :birth_date, use_two_digit_numbers: true, start_year: Time.zone.today.year - 75, end_year: Time.zone.today.year - 17, include_blank: true
= f.text_field :iban
= f.text_area :remarks
= f.collection_select :locale, Tenant.locales, :first, :first
= f.check_box :allow_bookings_without_contract
= f.check_box :bookings_without_contract
= f.check_box :bookings_without_invoice

.form-actions.pt-4.mt-3
= f.submit
Expand Down
3 changes: 2 additions & 1 deletion config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,9 @@ de:
tenant:
address: Adresse
address_addon: Adresszusatz / Schule / Firma
allow_bookings_without_contract: Buchungen ohne Vertrag erlauben
birth_date: Geburtsdatum
bookings_without_contract: Buchungen ohne Vertrag
bookings_without_invoice: Buchungen ohne Rechnung
city: Ort
country_code: Land
email: Email
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ en:
tenant:
address: Adresse
address_addon: Addresszusatz
allow_bookings_without_contract: Buchungen ohne Vertrag erlauben
birth_date: Geburtsdatum
bookings_without_contract: Buchungen ohne Vertrag erlauben
city: Ort
country_code: Land
email: Email
Expand Down
2 changes: 1 addition & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ fr:
tenant:
address: Adresse
address_addon: Complément d'adresse / école / entreprise
allow_bookings_without_contract: Autoriser les réservations sans contrat
birth_date: Date de naissance
bookings_without_contract: Autoriser les réservations sans contrat
city: Lieu
country_code: Pays
email: Email
Expand Down
2 changes: 1 addition & 1 deletion config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ it:
tenant:
address: Indirizzo
address_addon: Suffisso indirizzo / scuola / azienda
allow_bookings_without_contract: Consentire prenotazioni senza contratto
birth_date: Data di nascita
bookings_without_contract: Consentire prenotazioni senza contratto
city: Località
country_code: Paese
email: E-mail
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddBookingsWithoutInvoicesToTenants < ActiveRecord::Migration[7.1]
def change
add_column :tenants, :bookings_without_invoice, :boolean, default: false
rename_column :tenants, :allow_bookings_without_contract, :bookings_without_contract
remove_column :tenants, :iban, :string, null: true
end
end
6 changes: 3 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2023_12_19_120149) do
ActiveRecord::Schema[7.1].define(version: 2023_12_31_113411) do
# These are extensions that must be enabled in order to support this database
enable_extension "pgcrypto"
enable_extension "plpgsql"
Expand Down Expand Up @@ -541,9 +541,9 @@
t.string "country_code", default: "CH"
t.string "nickname"
t.string "address_addon"
t.boolean "allow_bookings_without_contract", default: false
t.string "iban"
t.boolean "bookings_without_contract", default: false
t.string "locale", default: "de", null: false
t.boolean "bookings_without_invoice", default: false
t.index ["email", "organisation_id"], name: "index_tenants_on_email_and_organisation_id", unique: true
t.index ["email"], name: "index_tenants_on_email"
t.index ["organisation_id"], name: "index_tenants_on_organisation_id"
Expand Down
46 changes: 23 additions & 23 deletions spec/factories/tenants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
#
# Table name: tenants
#
# id :bigint not null, primary key
# address_addon :string
# allow_bookings_without_contract :boolean default(FALSE)
# birth_date :date
# city :string
# country_code :string default("CH")
# email :string
# email_verified :boolean default(FALSE)
# first_name :string
# iban :string
# import_data :jsonb
# last_name :string
# locale :string default("de"), not null
# nickname :string
# phone :text
# remarks :text
# reservations_allowed :boolean default(TRUE)
# search_cache :text not null
# street_address :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
# organisation_id :bigint not null
# id :bigint not null, primary key
# address_addon :string
# birth_date :date
# bookings_without_contract :boolean default(FALSE)
# bookings_without_invoice :boolean default(FALSE)
# city :string
# country_code :string default("CH")
# email :string
# email_verified :boolean default(FALSE)
# first_name :string
# import_data :jsonb
# last_name :string
# locale :string default("de"), not null
# nickname :string
# phone :text
# remarks :text
# reservations_allowed :boolean default(TRUE)
# search_cache :text not null
# street_address :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
# organisation_id :bigint not null
#
# Indexes
#
Expand Down
46 changes: 23 additions & 23 deletions spec/models/tenant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,29 @@
#
# Table name: tenants
#
# id :bigint not null, primary key
# address_addon :string
# allow_bookings_without_contract :boolean default(FALSE)
# birth_date :date
# city :string
# country_code :string default("CH")
# email :string
# email_verified :boolean default(FALSE)
# first_name :string
# iban :string
# import_data :jsonb
# last_name :string
# locale :string default("de"), not null
# nickname :string
# phone :text
# remarks :text
# reservations_allowed :boolean default(TRUE)
# search_cache :text not null
# street_address :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
# organisation_id :bigint not null
# id :bigint not null, primary key
# address_addon :string
# birth_date :date
# bookings_without_contract :boolean default(FALSE)
# bookings_without_invoice :boolean default(FALSE)
# city :string
# country_code :string default("CH")
# email :string
# email_verified :boolean default(FALSE)
# first_name :string
# import_data :jsonb
# last_name :string
# locale :string default("de"), not null
# nickname :string
# phone :text
# remarks :text
# reservations_allowed :boolean default(TRUE)
# search_cache :text not null
# street_address :string
# zipcode :string
# created_at :datetime not null
# updated_at :datetime not null
# organisation_id :bigint not null
#
# Indexes
#
Expand Down

0 comments on commit 8975530

Please sign in to comment.