Browse Source

feat: add reset_voiddate method

pull/1078/head
Sam Seed 4 years ago
parent
commit
427b8df2de
  1. 12
      app/models/lettings_log.rb

12
app/models/lettings_log.rb

@ -17,6 +17,7 @@ end
class LettingsLog < Log
include Validations::SoftValidations
include DerivedVariables::LettingsLogVariables
include Validations::DateValidations
has_paper_trail
@ -25,6 +26,7 @@ class LettingsLog < Log
before_validation :reset_scheme_location!, if: :scheme_changed?, unless: :location_changed?
before_validation :process_postcode_changes!, if: :postcode_full_changed?
before_validation :process_previous_postcode_changes!, if: :ppostcode_full_changed?
before_validation :reset_voiddate, if: :startdate_changed?
before_validation :reset_invalidated_dependent_fields!
before_validation :reset_location_fields!, unless: :postcode_known?
before_validation :reset_previous_location_fields!, unless: :previous_postcode_known?
@ -538,6 +540,16 @@ private
end
end
def reset_voiddate
return unless startdate && voiddate
validate_property_void_date(self)
if errors[:voiddate].present?
self.voiddate = nil
errors.clear
end
end
def reset_scheme
return unless scheme && owning_organisation

Loading…
Cancel
Save