|
|
|
|
@ -29,6 +29,7 @@ class SalesLog < Log
|
|
|
|
|
before_validation :process_previous_postcode_changes!, if: :ppostcode_full_changed? |
|
|
|
|
before_validation :reset_location_fields!, unless: :postcode_known? |
|
|
|
|
before_validation :reset_previous_location_fields!, unless: :previous_postcode_known? |
|
|
|
|
before_validation :set_mortgage_value_zero, if: :mortgage_not_used? |
|
|
|
|
|
|
|
|
|
scope :filter_by_year, ->(year) { where(saledate: Time.zone.local(year.to_i, 4, 1)...Time.zone.local(year.to_i + 1, 4, 1)) } |
|
|
|
|
scope :search_by, ->(param) { filter_by_id(param) } |
|
|
|
|
@ -186,6 +187,10 @@ class SalesLog < Log
|
|
|
|
|
mortgageused == 2 |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def set_mortgage_value_zero |
|
|
|
|
self.mortgage = 0 |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def process_postcode_changes! |
|
|
|
|
self.postcode_full = upcase_and_remove_whitespace(postcode_full) |
|
|
|
|
process_postcode(postcode_full, "pcodenk", "is_la_inferred", "la") |
|
|
|
|
|