check duplicate batch no
This commit is contained in:
@@ -5,28 +5,34 @@ class Api::BatchesController < ApplicationController
|
||||
check_member= Member.authenticate_session_token(session_token)
|
||||
if !check_member.nil?
|
||||
date = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
|
||||
order_ref = params[:order_ref]
|
||||
order_ref = params[:order_ref]
|
||||
order_ref=order_ref.delete(' ')
|
||||
adult_or_child=params[:adult_or_child]
|
||||
client_id=params[:client_id]
|
||||
product_category_id=params[:product_category_id]
|
||||
|
||||
find_client=Client.find_by_id(client_id)
|
||||
if !find_client.nil?
|
||||
find_product_category=ProductCategory.find_by_id(product_category_id)
|
||||
if !find_product_category.nil?
|
||||
user_id=check_member.user_id
|
||||
find_batch=Batch.find_by_order_ref(order_ref)
|
||||
if find_batch.nil?
|
||||
find_client=Client.find_by_id(client_id)
|
||||
if !find_client.nil?
|
||||
find_product_category=ProductCategory.find_by_id(product_category_id)
|
||||
if !find_product_category.nil?
|
||||
user_id=check_member.user_id
|
||||
|
||||
batch = Batch.create_batch(date,order_ref,user_id,adult_or_child,client_id,product_category_id)
|
||||
if !batch.nil?
|
||||
@out=true,batch.id
|
||||
else
|
||||
@out=false,'Error occurs in creating batch!'
|
||||
end
|
||||
batch = Batch.create_batch(date,order_ref,user_id,adult_or_child,client_id,product_category_id)
|
||||
if !batch.nil?
|
||||
@out=true,batch.id
|
||||
else
|
||||
@out=false,'Error occurs in creating batch!'
|
||||
end
|
||||
else
|
||||
@out=false,'Product Category does not exists!'
|
||||
end
|
||||
else
|
||||
@out=false,'Product Category does not exists!'
|
||||
@out = false, "Client does not exist!"
|
||||
end
|
||||
else
|
||||
@out = false, "Client does not exist!"
|
||||
@out=false,order_ref.to_s+ " is already taken!"
|
||||
end
|
||||
else
|
||||
@out = false, "Sorry!Unauthorized user!"
|
||||
|
||||
Reference in New Issue
Block a user