check duplicate record
This commit is contained in:
@@ -143,24 +143,29 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
barcode = params[:barcode]
|
barcode = params[:barcode]
|
||||||
manufacture_uid = params[:manufacture_uid]
|
manufacture_uid = params[:manufacture_uid]
|
||||||
batch_line_item = BatchLineItem.find_by_asset_identity(account_no)
|
batch_line_item = BatchLineItem.find_by_asset_identity(account_no)
|
||||||
if !batch_line_item.nil?
|
|
||||||
batch_line_item.manufacture_uid = manufacture_uid
|
|
||||||
batch_line_item.barcode = barcode
|
|
||||||
batch_line_item.save
|
|
||||||
|
|
||||||
# update batch
|
if !batch_line_item.nil?
|
||||||
batch = Batch.find_by_id(batch_line_item.batch_id)
|
if batch_line_item.manufacture_uid.nil?
|
||||||
card_qty=batch.qty_processing.to_i
|
batch_line_item.manufacture_uid = manufacture_uid
|
||||||
success_qty=batch.qty_success
|
batch_line_item.barcode = barcode
|
||||||
|
batch_line_item.save
|
||||||
|
|
||||||
batch.qty_processing=card_qty+1
|
# update batch
|
||||||
batch.qty_success=success_qty+1
|
batch = Batch.find_by_id(batch_line_item.batch_id)
|
||||||
batch.save
|
card_qty=batch.qty_processing.to_i
|
||||||
|
success_qty=batch.qty_success
|
||||||
|
|
||||||
@out = true,"success"
|
batch.qty_processing=card_qty+1
|
||||||
else
|
batch.qty_success=success_qty+1
|
||||||
@out = false,"error"
|
batch.save
|
||||||
end
|
|
||||||
|
@out = true,"success"
|
||||||
|
else
|
||||||
|
@out = false,"Duplicate Record"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@out = false,"error"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_item_by_batch
|
def get_item_by_batch
|
||||||
@@ -203,6 +208,24 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def update_barcode_and_account_no
|
||||||
|
session_token = params[:session_token]
|
||||||
|
barcode =params[:barcode]
|
||||||
|
user = Member.find_by_session_token(session_token)
|
||||||
|
if !user.nil?
|
||||||
|
user_id = user.user_id
|
||||||
|
find_barcode = BatchLineItem.find_by_barcode(barcode)
|
||||||
|
if !find_barcode.nil?
|
||||||
|
@out = true,find_barcode
|
||||||
|
else
|
||||||
|
@out = false,"Invalid"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@out = false, "Not Authorized"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# def check_ticket
|
# def check_ticket
|
||||||
# session_token = params[:session_token]
|
# session_token = params[:session_token]
|
||||||
# barcode =params[:barcode]
|
# barcode =params[:barcode]
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
if @out[0] == true
|
||||||
|
json.set! :status, @out[0]
|
||||||
|
json.set! :message, @out[1]
|
||||||
|
else
|
||||||
|
json.set! :status, @out[0]
|
||||||
|
json.set! :message, @out[1]
|
||||||
|
end
|
||||||
3
app/views/api/batches/get_ticket_settings.json.jbuilder
Normal file
3
app/views/api/batches/get_ticket_settings.json.jbuilder
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
|
||||||
|
json.set! :status, @out[0]
|
||||||
|
json.set! :message, @out[1]
|
||||||
@@ -53,6 +53,7 @@ Rails.application.routes.draw do
|
|||||||
#batch_line_items
|
#batch_line_items
|
||||||
post "generate_card_account_items" =>"batch_line_items#generate_card_account_items"
|
post "generate_card_account_items" =>"batch_line_items#generate_card_account_items"
|
||||||
post "update_manufacture_uid" => "batch_line_items#update_manufacture_uid"
|
post "update_manufacture_uid" => "batch_line_items#update_manufacture_uid"
|
||||||
|
post "update_barcode_and_account_no" => "batch_line_items#update_barcode_and_account_no"
|
||||||
post "code_activate" => "batch_line_items#code_activate"
|
post "code_activate" => "batch_line_items#code_activate"
|
||||||
get "activated_list" => "batch_line_items#activated_list"
|
get "activated_list" => "batch_line_items#activated_list"
|
||||||
get "seller_info" => "batch_line_items#seller_info"
|
get "seller_info" => "batch_line_items#seller_info"
|
||||||
|
|||||||
9
db/migrate/20180810041316_create_setting.rb
Normal file
9
db/migrate/20180810041316_create_setting.rb
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
class CreateSetting < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
create_table :settings do |t|
|
||||||
|
t.string :key
|
||||||
|
t.string :value
|
||||||
|
t.string :name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user