edit api
This commit is contained in:
@@ -32,7 +32,7 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
batchLineItem.serial_no=serial_no
|
batchLineItem.serial_no=serial_no
|
||||||
batchLineItem.batch_id=batch_id
|
batchLineItem.batch_id=batch_id
|
||||||
batchLineItem.manufacture_uid = manufacture_uid
|
batchLineItem.manufacture_uid = manufacture_uid
|
||||||
batchLineItem.card_type = card_type
|
batchLineItem.card_type = card_type.upcase
|
||||||
|
|
||||||
if batchLineItem.save
|
if batchLineItem.save
|
||||||
lookup=Lookup.find_by_name('generate_serial_no')
|
lookup=Lookup.find_by_name('generate_serial_no')
|
||||||
|
|||||||
@@ -8,12 +8,14 @@ class Api::BatchesController < ApplicationController
|
|||||||
created_by = params[:created_by]
|
created_by = params[:created_by]
|
||||||
order_ref = params[:order_ref]
|
order_ref = params[:order_ref]
|
||||||
card_qty = params[:card_qty]
|
card_qty = params[:card_qty]
|
||||||
|
adult_or_child=params[:adult_or_child]
|
||||||
|
|
||||||
user_id=check_member.user_id
|
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?
|
if !batch.nil?
|
||||||
@out=true,batch.id
|
@out=true,batch.id
|
||||||
else
|
else
|
||||||
@out=false,'Error occurs in creating batch!'
|
@out=false,'Error occurs in creating batch!'
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out = false, "Sorry!Unauthorized user!"
|
@out = false, "Sorry!Unauthorized user!"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
class Batch < ApplicationRecord
|
class Batch < ApplicationRecord
|
||||||
has_many :batch_line_item
|
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 = Batch.new
|
||||||
batch.created_by = created_by
|
batch.created_by = created_by
|
||||||
batch.order_ref = order_ref
|
batch.order_ref = order_ref
|
||||||
@@ -13,6 +13,7 @@ class Batch < ApplicationRecord
|
|||||||
batch.qty_fail = 0
|
batch.qty_fail = 0
|
||||||
batch.user_id=user_id
|
batch.user_id=user_id
|
||||||
batch.export_count=0
|
batch.export_count=0
|
||||||
|
batch.adult_or_child=adult_or_child.upcase
|
||||||
if batch.save
|
if batch.save
|
||||||
return batch
|
return batch
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class CreateBatches < ActiveRecord::Migration[5.0]
|
|||||||
t.datetime :batch_start_time
|
t.datetime :batch_start_time
|
||||||
t.datetime :batch_end_time
|
t.datetime :batch_end_time
|
||||||
t.integer :export_count
|
t.integer :export_count
|
||||||
t.string :remark
|
t.string :remark
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
19
db/schema.rb
19
db/schema.rb
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170121092515) do
|
ActiveRecord::Schema.define(version: 20170126074122) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
@@ -27,21 +27,22 @@ ActiveRecord::Schema.define(version: 20170121092515) do
|
|||||||
end
|
end
|
||||||
|
|
||||||
create_table "batches", force: :cascade do |t|
|
create_table "batches", force: :cascade do |t|
|
||||||
t.datetime "date", null: false
|
t.datetime "date", null: false
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.string "order_ref", null: false
|
t.string "order_ref", null: false
|
||||||
t.boolean "batch_start"
|
t.boolean "batch_start"
|
||||||
t.boolean "batch_end"
|
t.boolean "batch_end"
|
||||||
t.string "created_by", null: false
|
t.string "created_by", null: false
|
||||||
t.integer "qty_processing", null: false
|
t.integer "qty_processing", null: false
|
||||||
t.integer "qty_success", null: false
|
t.integer "qty_success", null: false
|
||||||
t.integer "qty_fail", null: false
|
t.integer "qty_fail", null: false
|
||||||
t.datetime "batch_start_time"
|
t.datetime "batch_start_time"
|
||||||
t.datetime "batch_end_time"
|
t.datetime "batch_end_time"
|
||||||
t.integer "export_count"
|
t.integer "export_count"
|
||||||
t.string "remark"
|
t.string "remark"
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
|
t.string "adult_or_child", default: "CHILD"
|
||||||
t.index ["user_id"], name: "index_batches_on_user_id", using: :btree
|
t.index ["user_id"], name: "index_batches_on_user_id", using: :btree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user