diff --git a/CHANGELOG.md b/CHANGELOG.md index edd16a5f4..8147a6b38 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ This file summarises the most important changes that went live on each release of Concierge. Please check the Wiki entry on the release process to understand how this file is formatted and how the process works. +## [0.11.3] - 2016-09-23 +### Fixed +- Kigo: set `minimum_stay` to `nil` instead of 1 for calendar entry when coming NUMBER is zero + ## [0.11.2] - 2016-09-22 ### Fixed - Atleisure config being paresed as boolean by YAML diff --git a/lib/concierge/suppliers/kigo/calendar.rb b/lib/concierge/suppliers/kigo/calendar.rb index b7c7cedf0..456dd452e 100644 --- a/lib/concierge/suppliers/kigo/calendar.rb +++ b/lib/concierge/suppliers/kigo/calendar.rb @@ -3,9 +3,14 @@ module Kigo # # represents days count according to +UNIT+ type # possible unit types NIGHT, MONTH, YEAR + # + # example: + # + # TimeInterval.new({"UNIT"=>"NIGHT", "NUMBER"=>3}) TimeInterval = Struct.new(:interval) do def days - return 1 if interval['NUMBER'].zero? + return nil if interval['NUMBER'].zero? + multiplier = { 'MONTH' => 30, 'YEAR' => 365 }.fetch(interval['UNIT'], 1) interval['NUMBER'].to_i * multiplier end @@ -104,4 +109,4 @@ def safe_access(hash) Concierge::SafeAccessHash.new(hash) end end -end \ No newline at end of file +end diff --git a/lib/concierge/suppliers/kigo/mappers/property.rb b/lib/concierge/suppliers/kigo/mappers/property.rb index 26a546a8d..5f055eb7b 100644 --- a/lib/concierge/suppliers/kigo/mappers/property.rb +++ b/lib/concierge/suppliers/kigo/mappers/property.rb @@ -93,8 +93,10 @@ def set_base_info end end + # Parse the minimum stay from the given interval, + # or use 1 to statisfy Roomorama's property validation def stay_length(interval) - Kigo::TimeInterval.new(interval).days + Kigo::TimeInterval.new(interval).days || 1 end def set_description diff --git a/lib/concierge/version.rb b/lib/concierge/version.rb index d2ba457b6..b0a1500a3 100644 --- a/lib/concierge/version.rb +++ b/lib/concierge/version.rb @@ -1,3 +1,3 @@ module Concierge - VERSION = "0.11.2" + VERSION = "0.11.3" end diff --git a/spec/lib/concierge/suppliers/kigo/calendar/period_spec.rb b/spec/lib/concierge/suppliers/kigo/calendar/period_spec.rb index bbe788f53..a197571be 100644 --- a/spec/lib/concierge/suppliers/kigo/calendar/period_spec.rb +++ b/spec/lib/concierge/suppliers/kigo/calendar/period_spec.rb @@ -81,6 +81,31 @@ expect(entry.checkin_allowed).to eq true expect(entry.checkout_allowed).to eq true end - end -end \ No newline at end of file + context 'unavailable minimum stay' do + let(:period) do + { + 'CHECK_IN' => start_date.to_s, + 'CHECK_OUT' => end_date.to_s, + 'NAME' => '', + 'STAY_MIN' => { 'UNIT' => 'NIGHT', 'NUMBER' => 0 }, + 'WEEKLY' => false, + 'NIGHTLY_AMOUNTS' => [ + { + 'GUESTS_FROM' => 1, + 'WEEK_NIGHTS' => [1, 2, 3, 4, 5, 6, 7], + 'STAY_FROM' => { 'UNIT' => 'NIGHT', 'NUMBER' => 7 }, + 'AMOUNT' => '36.26' + } + ] + } + end + + it 'returns entry with min stay set to nil if NUMBER value is zero' do + entry = subject.entries.first + + expect(entry.minimum_stay).to be_nil + end + end + end +end diff --git a/spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb b/spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb index dc95dc3a6..77db4028b 100644 --- a/spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb +++ b/spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb @@ -34,6 +34,20 @@ expect(property.minimum_stay).to eq 30 end end + context 'number is zero' do + let(:minimum_stay) { + { + 'UNIT' => 'MONTH', + 'NUMBER' => 0 + } + } + it 'sets default stay_length' do + property_data['PROP_INFO']['PROP_STAYTIME_MIN'] = minimum_stay + property = subject.prepare(property_data, pricing).value + + expect(property.minimum_stay).to eq 1 + end + end end context 'description' do