update customer

This commit is contained in:
Aung Myo
2017-06-30 19:41:39 +06:30
12 changed files with 42 additions and 25 deletions

View File

@@ -82,7 +82,8 @@ class Crm::CustomersController < BaseCrmController
card_no = customer_params[:card_no]
member_group_id = params[:member_group_id]
if !member_group_id.nil?
if member_group_id.present?
puts "aaaaaaaaa"
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
merchant_uid = memberaction.merchant_account_id.to_s
@@ -101,6 +102,7 @@ class Crm::CustomersController < BaseCrmController
},
:timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
@@ -110,9 +112,7 @@ class Crm::CustomersController < BaseCrmController
rescue SocketError
response = { status: false}
end
if response["status"] == true
customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
@@ -125,11 +125,17 @@ class Crm::CustomersController < BaseCrmController
else
# @crm_customers.destroy
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. But '}
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. But ' }
end
end
else
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '}
else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' }
end
end
else
@@ -183,6 +189,8 @@ end
},
:timeout => 10
)
puts "hhhhhhhhh"
puts response.to_json
rescue Net::OpenTimeout
response = { status: false }
@@ -200,7 +208,7 @@ end
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
format.html { redirect_to crm_customers_path, notice: response["error"] }
end
else

View File

@@ -29,6 +29,7 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_item.sale_id = sale_id
sale_item.product_code = "Other Charges"
sale_item.product_name = di["name"]
sale_item.product_alt_name = ""
sale_item.remark = "Other Charges"
sale_item.qty = 1

View File

@@ -41,8 +41,8 @@ class Ability
can :add_customer, Customer
can :update_sale_by_customer, Customer
can :index, :other_charges
can :create, :other_charges
can :index, :other_charge
can :create, :other_charge
can :index, :discount
can :create, :discount
can :remove_discount_items, :discount
@@ -77,11 +77,14 @@ class Ability
can :add_customer, Customer
can :update_sale_by_customer, Customer
can :index, :other_charge
can :create, :other_charge
can :index, :discount
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
can :first_bill, :payment
can :show, :payment
can :create, :payment
can :reprint, :payment

View File

@@ -91,7 +91,7 @@ class Order < ApplicationRecord
# self.employee_name)
# end
OrderItem.processs_item(menu_item[:item_code], menu_item[:name], menu_item[:account_id],
OrderItem.processs_item(menu_item[:item_code], menu_item[:name], menu_item[:alt_name], menu_item[:account_id],
item[:quantity],menu_item[:price], item[:options], set_order_items, self.id,
self.employee_name)

View File

@@ -20,12 +20,13 @@ class OrderItem < ApplicationRecord
# option_values : [],
# sub_order_items : [],
# }
def self.processs_item (item_code, menu_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by)
def self.processs_item (item_code, menu_name, alt_name, account_id, qty,price, options, set_menu_items, order_id, item_order_by)
orderitem = OrderItem.create do |oitem|
oitem.order_id = order_id
oitem.item_code = item_code
oitem.item_name = menu_name
oitem.alt_name = alt_name
oitem.account_id = account_id
oitem.qty = qty
oitem.price = price

View File

@@ -59,11 +59,11 @@ class OrderQueueStation < ApplicationRecord
private
#Print order_items in 1 slip
def print_slip(oqs, order, order_items)
unique_code="OrderSummaryPdf"
unique_code="OrderSummaryPdf"
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(oqs,order.order_id, order_items, print_status="")
order_queue_printer.print_order_summary(print_settings, oqs,order.order_id, order_items, print_status="")
AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
# update print status for order items
@@ -80,7 +80,7 @@ class OrderQueueStation < ApplicationRecord
# print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(oqs,item.order_id, item.item_code, print_status="" )
order_queue_printer.print_order_item(print_settings, oqs,item.order_id, item.item_code, print_status="" )
# update print status for completed same order items
assigned_order_item.each do |ai|

View File

@@ -147,6 +147,7 @@ class Sale < ApplicationRecord
#pull
sale_item.product_code = item.item_code
sale_item.product_name = item.item_name
sale_item.product_alt_name = item.alt_name
sale_item.account_id = item.account_id
sale_item.remark = item.remark

View File

@@ -23,6 +23,7 @@ class ShiftSale < ApplicationRecord
puts today_date
shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take
return shift
#end
end

View File

@@ -7,6 +7,7 @@ class CreateOrderItems < ActiveRecord::Migration[5.1]
t.string :item_order_by #person who order this
t.string :item_code, :null => false
t.string :item_name, :null => false
t.string :alt_name, :null => false
t.integer :account_id, :limit => 8, :null => false, :default => 1
t.decimal :qty, :precision => 10, :scale => 2, :null => false, :default => 0.00
t.decimal :price, :precision => 10, :scale => 2, :null => false, :default => 0.00

View File

@@ -5,6 +5,7 @@ class CreateSaleItems < ActiveRecord::Migration[5.1]
t.string :sale_id, foreign_key: true, :limit => 16
t.string :product_code, :null => false
t.string :product_name, :null => false
t.string :product_alt_name, :null => false
t.integer :account_id, :limit => 8, :null => false, :default => 1
t.string :remark
t.decimal :qty, :precision => 10, :scale => 2, :null => false, :default => 0.00

View File

@@ -156,11 +156,11 @@ admin_employee = Employee.create({name: "Waiter", role: "waiter", password: "111
admin_employee = Employee.create({name: "Waiter 2", role: "waiter", password: "22222", emp_id:"222", created_by: "SYSTEM DEFAULT"})
admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "33333", emp_id:"333", created_by: "SYSTEM DEFAULT"})
order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "EPSON-TM-T82-S-A", precision: "0", delimiter: "0", heading_space: "5"})
order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"})
member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"})

View File

@@ -9,7 +9,7 @@ beverage = Account.create({title: "Beverage", account_type: "1"})
menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base", alt_name: "Soup_base", order_by: 1,created_by: "SYSTEM DEFAULT"})
# single pot
menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Single Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food })
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Single Pot",item_instance_code:"II0011", menu_item: menu_category1_menu_item0, price:10.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Single Pot",item_instance_code:"II0011", menu_item: menu_category1_menu_item0, price:0.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0051", menu_item: menu_category1_menu_item0, price:15800.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Spicy Nourishing Broth ",item_instance_code:"II0061", menu_item: menu_category1_menu_item0, price:15800.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Herbal Drunken Chicken Broth",item_instance_code:"II0071", menu_item: menu_category1_menu_item0, price:17800.00, is_on_promotion:false}])
@@ -18,7 +18,7 @@ menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base"
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Vitamin C Tomato Sweet Corn Broth",item_instance_code:"II0101", menu_item: menu_category1_menu_item0, price:15800.00, is_on_promotion:false}])
# twin pot
menu_category1_menu_item1 = SimpleMenuItem.create({item_code:"01002", name: "Twin Pot", alt_name: "Twin Pot",menu_category: menu_category1 , min_selectable_item: 2, max_selectable_item:2, account: food })
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Twin Pot",item_instance_code:"II0021", menu_item: menu_category1_menu_item1, price:10.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Twin Pot",item_instance_code:"II0021", menu_item: menu_category1_menu_item1, price:0.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0052", menu_item: menu_category1_menu_item1, price:9800.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Spicy Nourishing Broth ",item_instance_code:"II0062", menu_item: menu_category1_menu_item1, price:9800.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Herbal Drunken Chicken Broth",item_instance_code:"II0072", menu_item: menu_category1_menu_item1, price:9800.00, is_on_promotion:false}])
@@ -27,7 +27,7 @@ menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base"
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Vitamin C Tomato Sweet Corn Broth",item_instance_code:"II0102", menu_item: menu_category1_menu_item1, price:11800.00, is_on_promotion:false}])
# vip room Individual pot
menu_category1_menu_item2 = SimpleMenuItem.create({item_code:"01003", name: "VIP Room Individual Pot", alt_name: "Single Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food })
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"VIP Room Individual Pot",item_instance_code:"II0031", menu_item: menu_category1_menu_item2, price:10.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"VIP Room Individual Pot",item_instance_code:"II0031", menu_item: menu_category1_menu_item2, price:0.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0053", menu_item: menu_category1_menu_item2, price:6000.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Spicy Nourishing Broth ",item_instance_code:"II0063", menu_item: menu_category1_menu_item2, price:6000.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Herbal Drunken Chicken Broth",item_instance_code:"II0073", menu_item: menu_category1_menu_item2, price:8000.00, is_on_promotion:false}])
@@ -36,7 +36,7 @@ menu_category1 = MenuCategory.create({menu: menu, code:"C001", name: "Soup Base"
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Vitamin C Tomato Sweet Corn Broth",item_instance_code:"II0103", menu_item: menu_category1_menu_item2, price:6000.00, is_on_promotion:false}])
# Quart pot
menu_category1_menu_item3 = SimpleMenuItem.create({item_code:"01004", name: "Quart Pot", alt_name: "Quart Pot",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food })
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Quart Pot",item_instance_code:"II0041", menu_item: menu_category1_menu_item3, price:10.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Quart Pot",item_instance_code:"II0041", menu_item: menu_category1_menu_item3, price:0.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Beauty Collagen Broth",item_instance_code:"II0054", menu_item: menu_category1_menu_item3, price:6000.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Spicy Nourishing Broth ",item_instance_code:"II0064", menu_item: menu_category1_menu_item3, price:6000.00, is_on_promotion:false}])
menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Herbal Drunken Chicken Broth",item_instance_code:"II0074", menu_item: menu_category1_menu_item3, price:8000.00, is_on_promotion:false}])
@@ -629,9 +629,9 @@ zone3 = Zone.create({id:3, name: "H3", is_active:true, created_by: "SYSTEM DEFAU
table = Table.create({name:"78", zone: zone3, status:"available", seater: 2 , order_by:1, created_by:"SYSTEM DEFAULT"})
#Default Order Queue stations
order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "kitchen_printer", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
order_queue_station2 = OrderQueueStation.create({station_name: "K2", is_active: true,printer_name: "drink_printer", processing_items: JSON.generate(['02005','02006','02007','02008']), print_copy:true, cut_per_item: true, use_alternate_name: true, created_by: "SYSTEM DEFAULT"})
zone_order_queue_station = OrderQueueStation.create({station_name: "K3", is_active: true, printer_name: "print_station", processing_items: JSON.generate(['01001','01002','01003','01004','02005','02006','02007','02008']), print_copy: true, cut_per_item: true, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
order_queue_station1 = OrderQueueStation.create({station_name: "K1", is_active: true,printer_name: "Cashier", processing_items: JSON.generate(['01001','01002','01003','01004']), print_copy:true, cut_per_item: false, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
order_queue_station2 = OrderQueueStation.create({station_name: "K2", is_active: true,printer_name: "Cashier", processing_items: JSON.generate(['02005','02006','02007','02008']), print_copy:true, cut_per_item: true, use_alternate_name: true, created_by: "SYSTEM DEFAULT"})
zone_order_queue_station = OrderQueueStation.create({station_name: "K3", is_active: true, printer_name: "Cashier", processing_items: JSON.generate(['01001','01002','01003','01004','02005','02006','02007','02008']), print_copy: true, cut_per_item: true, use_alternate_name: false, created_by: "SYSTEM DEFAULT"})
# QueueStationZone
zone_queue_station1 = OrderQueueProcessByZone.create({order_queue_station: order_queue_station1, zone: zone})