This commit is contained in:
Sunandar
2017-01-26 16:28:54 +06:30
parent 3f35298e96
commit 735d899eef
5 changed files with 19 additions and 15 deletions

View File

@@ -32,7 +32,7 @@ class Api::BatchLineItemsController < ApplicationController
batchLineItem.serial_no=serial_no
batchLineItem.batch_id=batch_id
batchLineItem.manufacture_uid = manufacture_uid
batchLineItem.card_type = card_type
batchLineItem.card_type = card_type.upcase
if batchLineItem.save
lookup=Lookup.find_by_name('generate_serial_no')

View File

@@ -8,12 +8,14 @@ class Api::BatchesController < ApplicationController
created_by = params[:created_by]
order_ref = params[:order_ref]
card_qty = params[:card_qty]
adult_or_child=params[:adult_or_child]
user_id=check_member.user_id
batch = Batch.create_batch(created_by,date,order_ref,card_qty,user_id)
batch = Batch.create_batch(created_by,date,order_ref,card_qty,user_id,adult_or_child)
if !batch.nil?
@out=true,batch.id
@out=true,batch.id
else
@out=false,'Error occurs in creating batch!'
@out=false,'Error occurs in creating batch!'
end
else
@out = false, "Sorry!Unauthorized user!"

View File

@@ -1,7 +1,7 @@
class Batch < ApplicationRecord
has_many :batch_line_item
def self.create_batch(created_by,date,order_ref, card_qty,user_id)
def self.create_batch(created_by,date,order_ref, card_qty,user_id,adult_or_child)
batch = Batch.new
batch.created_by = created_by
batch.order_ref = order_ref
@@ -13,6 +13,7 @@ class Batch < ApplicationRecord
batch.qty_fail = 0
batch.user_id=user_id
batch.export_count=0
batch.adult_or_child=adult_or_child.upcase
if batch.save
return batch
else