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

@@ -6,10 +6,13 @@ class Api::BatchesController < ApplicationController
if !check_member.nil?
date = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
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_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)
@@ -27,6 +30,9 @@ class Api::BatchesController < ApplicationController
end
else
@out = false, "Client does not exist!"
end
else
@out=false,order_ref.to_s+ " is already taken!"
end
else
@out = false, "Sorry!Unauthorized user!"

View File

@@ -26,9 +26,11 @@ namespace :setup do
task :set_product_category, [:name,:product_type] => :environment do |t, args|
find_product_type=ProductType.find_by_id(args.product_type)
if !find_product_type.nil?
find_product_category=ProductCategory.find_by_name(args.name)
if find_product_category.nil?
product_category=ProductCategory.new
product_category.name=args.name
product_category.product_type_id=args.product_type