Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
596 B
3
Indexable
Never
 def test(wsn_id)
    create_display_id(wsn_id)
  end

  def create_display_id(wsn_id, prefix = nil, _suffix = nil)
    str = wsn_id.to_s.rjust(10, '0')
    # WSN Generation Logic WMS = "_" (underscore) and FBE = "-" hyphen
    display_id = ((str.to_i)/26).to_s(36).upcase.rjust(6, '0') + "#{WarehouseService.settings.wsn_delimiter}" +('A'..'Z').to_a[(str.to_i)%26]
    update_wsn_display(wsn_id, display_id)
  end

  def update_wsn_display(wsn_id, display_id)
    query = "UPDATE wh_serial_numbers SET display_id = '#{display_id}' where id = #{wsn_id}"
    sql_stream.execute_by_sql(query)
  end
Leave a Comment