class Skr::Handlers::SequentialIds
Constants
- TYPES
Attributes
data[R]
model[R]
params[R]
user[R]
Public Class Methods
new(model, authentication, params, data)
click to toggle source
# File lib/skr/handlers/sequential_ids.rb, line 12 def initialize(model, authentication, params, data) @data = data end
Public Instance Methods
show()
click to toggle source
# File lib/skr/handlers/sequential_ids.rb, line 16 def show ids = {} Skr::SequentialId.pluck(:name, :current_value).map do |name, count| ids[name.demodulize] = count end list = TYPES.map do | t | {id: t, name: t.titleize, count: ids[t] || 0} end Skr::BankAccount.find_each do |ba| id = Payment::SEQUENTIAL_ID_PREFIX + ba.id.to_s list.push({id: id, name: "#{ba.name} Check", count: ids[id] || 0}) end std_api_reply(:retrieve, {id: 'all', ids: list}, success: true) end
update()
click to toggle source
# File lib/skr/handlers/sequential_ids.rb, line 31 def update data['ids'].each do | si | Lanes.logger.warn "#{si['id']}" id = if 0 == si['id'].index(Payment::SEQUENTIAL_ID_PREFIX) si['id'] else "Skr::#{si['id']}" end Skr::SequentialId.set_next(id, si['count']) end std_api_reply(:create, {ids: data['ids']}, success: true ) end