update customerbind in origami

This commit is contained in:
Aung Myo
2017-06-22 10:25:40 +06:30
parent 7785ac99ef
commit 54526230aa
3 changed files with 22 additions and 3 deletions

View File

@@ -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

View File

@@ -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 ------------#

View File

@@ -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"})