added order report to back office
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user