From aae117e1d2effa937c78118748593d9c35975d6c Mon Sep 17 00:00:00 2001 From: Keang Date: Tue, 11 Oct 2016 18:15:01 +0800 Subject: [PATCH 1/3] Return 0 if no min_stay rule is present Sometimes there is no MIN_STAY field in the pricintSetup response, as seen here: https://concierge-web.roomorama.com/errors/569727 --- lib/concierge/suppliers/kigo/mappers/pricing_setup.rb | 1 + lib/concierge/suppliers/kigo/mappers/property.rb | 1 - spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb | 5 ++--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/concierge/suppliers/kigo/mappers/pricing_setup.rb b/lib/concierge/suppliers/kigo/mappers/pricing_setup.rb index a701497a9..fe19f2e72 100644 --- a/lib/concierge/suppliers/kigo/mappers/pricing_setup.rb +++ b/lib/concierge/suppliers/kigo/mappers/pricing_setup.rb @@ -43,6 +43,7 @@ def currency end def minimum_stay + return 0 unless min_stay_valid? rules = periodical_rate.get('MIN_STAY.MIN_STAY_RULES') rules.collect do |rule| before_to = rule['DATE_TO'].nil? || DateTime.parse(rule['DATE_TO']) < DateTime.now diff --git a/lib/concierge/suppliers/kigo/mappers/property.rb b/lib/concierge/suppliers/kigo/mappers/property.rb index 9751eed06..27687ece1 100644 --- a/lib/concierge/suppliers/kigo/mappers/property.rb +++ b/lib/concierge/suppliers/kigo/mappers/property.rb @@ -36,7 +36,6 @@ def prepare(property_data, pricing_data) pricing_mapper = PricingSetup.new(payload['PROP_RATE'], pricing) return Result.error(:no_prices_provided) unless pricing_mapper.valid? - return Result.error(:invalid_min_stay, pricing) unless pricing_mapper.min_stay_valid? set_price(pricing_mapper) set_images diff --git a/spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb b/spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb index df114210e..ecfb0ee61 100644 --- a/spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb +++ b/spec/lib/concierge/suppliers/kigo/mappers/property_spec.rb @@ -54,9 +54,8 @@ context 'pricing_setup does not have MIN_STAY' do it 'returns an error Result' do pricing['MIN_STAY'] = nil - result = subject.prepare(property_data, pricing) - expect(result).to_not be_success - expect(result.error.code).to eq(:invalid_min_stay) + property = subject.prepare(property_data, pricing).value + expect(property.minimum_stay).to eq 7 # according to property data end end From 308dcedbea20c9cdfc21983126607168cae3e106 Mon Sep 17 00:00:00 2001 From: Keang Date: Tue, 11 Oct 2016 18:17:48 +0800 Subject: [PATCH 2/3] Add changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec762bdcc..4e6560f18 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. +## Unreleased +### Fixed +- Fix crash when kigo pricing does not return MIN_STAY rules #430 + ## [0.12.4] - 2016-10-11 ### Fixed - uninitialized constant `API::Controllers::InternalError` for ubuntu 16.04 From c7674bfffa8c5efcfcb6cf7a94e10afd197224e8 Mon Sep 17 00:00:00 2001 From: Keang Date: Tue, 11 Oct 2016 18:36:29 +0800 Subject: [PATCH 3/3] Bump version 0.12.5 Nil kigo min_stay rule --- CHANGELOG.md | 2 +- lib/concierge/version.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e6560f18..647053dcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ 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. -## Unreleased +## [0.12.5] - 2016-10-11 ### Fixed - Fix crash when kigo pricing does not return MIN_STAY rules #430 diff --git a/lib/concierge/version.rb b/lib/concierge/version.rb index 5122710bd..b8fdb48ff 100644 --- a/lib/concierge/version.rb +++ b/lib/concierge/version.rb @@ -1,3 +1,3 @@ module Concierge - VERSION = "0.12.4" + VERSION = "0.12.5" end