From f03719f1b782bf142ef5b7f7ca75952ce701df4e Mon Sep 17 00:00:00 2001 From: nandar Date: Thu, 21 Jun 2018 14:56:07 +0630 Subject: [PATCH] commit by nda --- .../api/batch_line_items_controller.rb | 90 +++++++++++++++++- app/controllers/api/batches_controller.rb | 2 + .../batch_line_items_controller.rb | 4 +- app/views/api/.DS_Store | Bin 6148 -> 6148 bytes app/views/api/batch_line_items/.DS_Store | Bin 0 -> 6148 bytes .../generate_card_account_items.jbuilder | 3 + .../get_item_by_batch.json.jbuilder | 7 ++ .../update_manufacture_uid.jbuilder | 2 + app/views/api/batches/.DS_Store | Bin 0 -> 6148 bytes config/database.yml | 7 +- config/routes.rb | 5 + db/schema.rb | 1 + 12 files changed, 115 insertions(+), 6 deletions(-) create mode 100644 app/views/api/batch_line_items/.DS_Store create mode 100644 app/views/api/batch_line_items/generate_card_account_items.jbuilder create mode 100644 app/views/api/batch_line_items/get_item_by_batch.json.jbuilder create mode 100644 app/views/api/batch_line_items/update_manufacture_uid.jbuilder create mode 100644 app/views/api/batches/.DS_Store diff --git a/app/controllers/api/batch_line_items_controller.rb b/app/controllers/api/batch_line_items_controller.rb index 0fcf4d6..ce2da50 100644 --- a/app/controllers/api/batch_line_items_controller.rb +++ b/app/controllers/api/batch_line_items_controller.rb @@ -73,5 +73,93 @@ class Api::BatchLineItemsController < ApplicationController else @out=false,'Sorry!Unauthorized user!' end - end + end + + def generate_card_account_items + # Generate Code + batch_id=params[:id] + client_id="" + qty = params[:qty] + total_count=0 + + # check_member= Member.authenticate_session_token(session_token) + # if !check_member.nil? + encrypt_key="" + asset_identity="" + + find_batch = Batch.find_by_id(batch_id) + if !find_batch.nil? + card_type=find_batch.adult_or_child.upcase + product_category_id=find_batch.product_category_id + find_product_category=ProductCategory.find_by_id(product_category_id) + + if !find_product_category.nil? + product_type=find_product_category.product_type_id + + find_user=Client.find_by_id(find_batch.client_id) + if !find_user.nil? + encrypt_key=find_user.secrect_key + location_code=find_user.location_code + + client_id=find_user.id + + if !encrypt_key.nil? + arr = Array.new + # Generate with qty + qty.to_i.times do |i| + serial_no=BatchLineItem.generate_serial_no(client_id.to_s) + + asset_identity=BatchLineItem.generate_account_no(location_code) + security_code=BatchLineItem.generate_security_code + out=BatchLineItem.create_product(asset_identity,serial_no,batch_id,"","",security_code) + item = out[2] + total_count+=1 + arr.push(item) + end + @out =true,'Success',arr + # Generate with qty + + else + @out=false,'Invalid User!' + end + else + @out=false,"Client doesn't exist!" + end + else + @out=false,"Product Category doesn't exist!" + end + else + @out=false,"Batch doesn't exist!" + end + # else + # @out=false,'Sorry!Unauthorized user!' + # end + # Generate Code + end + def update_manufacture_uid + account_no = params[:account_no] + manufacture_uid = params[:manufacture_uid] + batch_line_item = BatchLineItem.find_by_asset_identity(account_no) + if !batch_line_item.nil? + puts 'he' + batch_line_item.manufacture_uid = manufacture_uid + batch_line_item.save + + @out = true,"success" + else + @out = false,"error" + end + end + + def get_item_by_batch + batch_id = params[:batch_id] + session_token = params[:session_token] + get_batch = BatchLineItem.where("batch_id=?",batch_id) + if !get_batch.nil? + @out = true,get_batch + else + @out = false,"no batch" + end + + end end \ No newline at end of file diff --git a/app/controllers/api/batches_controller.rb b/app/controllers/api/batches_controller.rb index 639436a..4270d3b 100644 --- a/app/controllers/api/batches_controller.rb +++ b/app/controllers/api/batches_controller.rb @@ -98,4 +98,6 @@ class Api::BatchesController < ApplicationController @out = false, "Sorry!Unauthorized user!" end end + + end \ No newline at end of file diff --git a/app/controllers/batch_line_items_controller.rb b/app/controllers/batch_line_items_controller.rb index a8253d2..06627ba 100644 --- a/app/controllers/batch_line_items_controller.rb +++ b/app/controllers/batch_line_items_controller.rb @@ -179,7 +179,7 @@ class BatchLineItemsController < ApplicationController # @out=false,'Sorry!Unauthorized user!' # end # Generate Code - - end + + end \ No newline at end of file diff --git a/app/views/api/.DS_Store b/app/views/api/.DS_Store index 0f8a739081fc172bec64af9c7f4807eeced82ac6..b9277d736bf91ff6fba726240e5c172e626484ca 100644 GIT binary patch literal 6148 zcmeHK-D(p-6h70&cGGQOFDevN*n4x4wAS1%vAq$&KuUUHW!>oxW?-ESyOV?x0tApr?zu(*F?+{Y64@iQptv>eea zr?|~;&{4)q*=l_vYwNXZ8=GEz%inJJjbPhv_>cR;eA<_Z9GBgsh=ZGbo-&#gCp?wI zVwwcShP5MSm6&+A@24t8g={nlPHY#+4e&2ZM~w3^|a z{k!wISNFVIx9<<=`HPpYUcY(!?)`_4pTB%H-;Ur>r)9_D5BP@0Z>gO03z6mGDf+5B zn+w#l%S?2qjYRKt4*nL=OT?w+Sw?Xwsc*3~w8XdvBPbw;6vnvVC6r6!D#H~KyO2Hq zip>qYCJ*u~2NHo}wrd0|Nsi1A_nqLk2@CLvc!Ra!ykI#6tDS1|lqz53@;c u{=>%2xLJXNon>Q#H`8Wz4t@@x=FNf}-JEI$YHg*YvTQXY3WU-6>`|BJ8h|Jy-6at54%f5kv( z_HX(O0QX`%R!fYRWNGw`Df FyaOVUUEcrz literal 0 HcmV?d00001 diff --git a/app/views/api/batch_line_items/generate_card_account_items.jbuilder b/app/views/api/batch_line_items/generate_card_account_items.jbuilder new file mode 100644 index 0000000..a0f504c --- /dev/null +++ b/app/views/api/batch_line_items/generate_card_account_items.jbuilder @@ -0,0 +1,3 @@ +json.set! :status, @out[0] +json.set! :message, @out[1] +json.set! :line_item, @out[2] diff --git a/app/views/api/batch_line_items/get_item_by_batch.json.jbuilder b/app/views/api/batch_line_items/get_item_by_batch.json.jbuilder new file mode 100644 index 0000000..6f02a87 --- /dev/null +++ b/app/views/api/batch_line_items/get_item_by_batch.json.jbuilder @@ -0,0 +1,7 @@ + if @out[0] == true + json.set! :status, @out[0] + json.set! :data, @out[1] + else + json.set! :status, @out[0] + json.set! :message,@out[1] + end \ No newline at end of file diff --git a/app/views/api/batch_line_items/update_manufacture_uid.jbuilder b/app/views/api/batch_line_items/update_manufacture_uid.jbuilder new file mode 100644 index 0000000..486ae15 --- /dev/null +++ b/app/views/api/batch_line_items/update_manufacture_uid.jbuilder @@ -0,0 +1,2 @@ +json.set! :status, @out[0] +json.set! :message, @out[1] diff --git a/app/views/api/batches/.DS_Store b/app/views/api/batches/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..409bac7430d62a15f0e92784766473cb05caed52 GIT binary patch literal 6148 zcmeHKK~BRk5S%SN6mjVR3B)PfI91{YQB{z*!UGCzBcKWtHRPTL@&JAlX6;qgG$7?v z0os*z$FaR*XB@>g02!ByOJE3KKv(P?GJIp&uHLeq)%1xHIG!*?hF2^wYW4Pt->87D z-3exRz&qyHUcV&@thkmVEZJV-89CQA!}=y)&1d;)#!UTeuIU$bFqVMx2HP9fWO-!F z$XD?D$jMZ2H0A9!!pF`C$DFD1>729fJaW6kb7r$D@j{;I*1S8)31slY*e9P0jm_4EC| zndDEdfGhB?6p;SpZZhU8+1}cEIo)d$`aNAu`&AJ)DJ+Don0<9CKBWg^eWC?oYFI^N Q4b2Y%K?V=5z+M&j0yTSC8vp "batches#batch_end" get "batches/resume_batch" =>"batches#resume_batch" get "batches/batch_progress_list" =>"batches#batch_progress_list" + get "get_item_by_batch" =>"batch_line_items#get_item_by_batch" #client get "clients" => 'clients#index' #product get "products" => "products#index" + + #batch_line_items + post "generate_card_account_items" =>"batch_line_items#generate_card_account_items" + post "update_manufacture_uid" => "batch_line_items#update_manufacture_uid" end end \ No newline at end of file diff --git a/db/schema.rb b/db/schema.rb index 4ddc3a3..f80e7ec 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -14,6 +14,7 @@ ActiveRecord::Schema.define(version: 20180226100816) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + enable_extension "uuid-ossp" create_table "batch_line_items", force: :cascade do |t| t.integer "batch_id"