check duplicate batch no

This commit is contained in:
Sunandar
2017-02-24 14:19:25 +06:30
parent 93085271a9
commit c784057d1b
2 changed files with 23 additions and 15 deletions

View File

@@ -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!"