lib/masterfiles/repositories/location_repo.rb
# Given a scanned or entered value and the scan_field
# value from a form, return the valid location_id or nil.
#
# @param value [string,integer] the scanned or entered value
# @param scan_field [string] the type of scan (blank if the value was typed in)
# @return [intger,nil] the location_id or nil if input was invalid or not found
Given a scanned or entered value and the scan_field
value from a form, return the valid location_id or nil.
Given a scanned or entered value and the scan_field value from a form return the valid location_id or nil .
def resolve_location_id_from_scan(value, scan_field) 
      if scan_field == 'location_short_code'
        location_id_from_short_code(value)
      elsif value.is_a?(Numeric) || value =~ /\A\d+\Z/
        if value.to_i > AppConst::MAX_DB_INT
          nil
        else
          get_id(:locations, id: value)
        end
      elsif scan_field == 'location_id'
        nil
      else
        location_id_from_short_code(value)
      end
    end
def resolve_location_id_from_scan ( value , scan_field ) if scan_field == 'location_short_code' location_id_from_short_code ( value ) elsif value . is_a? ( Numeric ) || value =~ / \A \d + \Z / if value . to_i > AppConst :: MAX_DB_INT nil else get_id ( :locations , id : value ) end elsif scan_field == 'location_id' nil else location_id_from_short_code ( value ) end end
Given a scanned or entered value and the scan_field
value from a form, return the valid location_id or nil.
Given a scanned or entered value and the scan_field value from a form return the valid location_id or nil .
# rubocop:disable Metrics/PerceivedComplexity
the location_id or nil if input was invalid or not found
the location_id or nil if input was invalid or not found
intger,nil
value
the scanned or entered value
the scanned or entered value
scan_field
the type of scan (blank if the value was typed in)
the type of scan ( blank if the value was typed in )