From 8dc9ab0fbe6388fcbf78c25482b335294fa000c2 Mon Sep 17 00:00:00 2001 From: nandar Date: Thu, 28 Jun 2018 17:43:58 +0630 Subject: [PATCH] add migration --- .../api/batch_line_items_controller.rb | 16 ++++++++++++++-- db/migrate/20180627041112_add_generated_qty.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20180627041112_add_generated_qty.rb diff --git a/app/controllers/api/batch_line_items_controller.rb b/app/controllers/api/batch_line_items_controller.rb index ce2da50..947fd35 100644 --- a/app/controllers/api/batch_line_items_controller.rb +++ b/app/controllers/api/batch_line_items_controller.rb @@ -81,7 +81,9 @@ class Api::BatchLineItemsController < ApplicationController client_id="" qty = params[:qty] total_count=0 - + puts batch_id + puts 'ello' + puts params[:id] # check_member= Member.authenticate_session_token(session_token) # if !check_member.nil? encrypt_key="" @@ -89,6 +91,8 @@ class Api::BatchLineItemsController < ApplicationController find_batch = Batch.find_by_id(batch_id) if !find_batch.nil? + find_batch.generated_qty = qty + find_batch.save 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) @@ -141,9 +145,17 @@ class Api::BatchLineItemsController < ApplicationController 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 + + # update batch + batch = Batch.find_by_id(batch_line_item.batch_id) + card_qty=batch.qty_processing.to_i + success_qty=batch.qty_success + + batch.qty_processing=card_qty+1 + batch.qty_success=success_qty+1 + batch.save @out = true,"success" else diff --git a/db/migrate/20180627041112_add_generated_qty.rb b/db/migrate/20180627041112_add_generated_qty.rb new file mode 100644 index 0000000..effdc2f --- /dev/null +++ b/db/migrate/20180627041112_add_generated_qty.rb @@ -0,0 +1,5 @@ +class AddGeneratedQty < ActiveRecord::Migration[5.0] + def change + add_column :batches, :generated_qty, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index f80e7ec..cb190b5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180226100816) do +ActiveRecord::Schema.define(version: 20180627041112) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -49,6 +49,7 @@ ActiveRecord::Schema.define(version: 20180226100816) do t.datetime "updated_at", null: false t.string "adult_or_child", default: "CHILD" t.integer "product_category_id" + t.integer "generated_qty" t.index ["client_id"], name: "index_batches_on_client_id", using: :btree t.index ["product_category_id"], name: "index_batches_on_product_category_id", using: :btree t.index ["user_id"], name: "index_batches_on_user_id", using: :btree