diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 601055e5..878571f1 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -39,5 +39,24 @@ class Origami::CustomersController < BaseOrigamiController end end + def update_sale_by_customer + + id = params[:sale_id][0,3] + if(id == "SAL") + sale = Sale.find(params[:sale_id]) + else + sale = Order.find(params[:sale_id]) + end + + status = sale.update_attributes(customer_id: params[:customer_id]) + + if status == true + render json: JSON.generate({:status => true}) + else + render json: JSON.generate({:status => false, :error_message => "Record not found"}) + + end + end + end diff --git a/config/routes.rb b/config/routes.rb index 7ec8b9e5..3b647fa9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -112,7 +112,7 @@ Rails.application.routes.draw do #resources :customers get '/:sale_id/customers', to: "customers#add_customer" get '/:customer_id/get_customer' => 'home#get_customer' - post '/:sale_id/update_sale' , to: "home#update_sale_by_customer"#update customer id in sale table + post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer"#update customer id in sale table end #--------- Waiter/Ordering Station ------------# diff --git a/db/seeds.rb b/db/seeds.rb index a646bdad..0e88e336 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -83,8 +83,8 @@ void_reason = Lookup.create([{lookup_type:'void_reason', name: 'Approve By Manag {lookup_type:'void_reason', name: 'Waiter Mistake', value: 'Waiter Mistake'}]) #WALK CUSTOMER - Default CUSTOMER (take key 1) -customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000"}) -customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111"}) +customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000"}) +customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111",card_no:"000"}) #Default ZOne # zone = Zone.create({id:1, name: "Normal Zone", is_active:true, created_by: "SYSTEM DEFAULT"})