added order report to back office

This commit is contained in:
Senad Uka
2015-08-09 10:17:52 +02:00
parent 69f6c86aee
commit 8b6a62b7e7
5 changed files with 114 additions and 1 deletions

View File

@@ -521,4 +521,13 @@ class Place < ActiveRecord::Base
return "<nepoznato mjesto>";
end
def self.by_code_or_default(code)
# removes garbage and converts whitespace prefixed codes correctly - like " 71000" -> 71000
valid_code = code.to_i.to_s
place = Place.where(postal_code: valid_code).first
place ||= Place.where("postal_code is null or postal_code = ''").first
return place
end
end