diff --git a/.gitignore b/.gitignore
index eadc1489..66f5a09c 100755
--- a/.gitignore
+++ b/.gitignore
@@ -24,6 +24,7 @@ capybara-*.html
/public/image
/public/system/*
/public/assets/*
+/public/menus/*
/public/uploads/*
/public/swf/*
/public/receipts/
diff --git a/README.md b/README.md
index fcc35040..712d61a9 100755
--- a/README.md
+++ b/README.md
@@ -184,6 +184,9 @@ For MoveTablePdf in print settings
Add Kitchen Role of Employee
=> 1) settings/lookups => { type:employee_roles, name: Kitchen, value:kitchen }
+Add Base URL for DOEMAL
+ 1) settings/lookups => { type:order_reservation, name: BaseURL, value:'{doemal url}' }
+
* ToDo list
1. Migration
diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js
index 07511458..1044bc6f 100755
--- a/app/assets/javascripts/addorder.js
+++ b/app/assets/javascripts/addorder.js
@@ -268,21 +268,24 @@ $(function() {
value = item_sets[field]["instances"];
$(value).each(function(i){
if (type != -1 && modify_order != -1) {
- url = '../../../../api/restaurant/menu_item_instances/'+value[i]["id"];
+
+ url = '../../../addorders/get_item_instance/'+value[i]["id"];
console.log("ssssssss")
}
if(modify_order == -1 && type != -1){
- url = '../../api/restaurant/menu_item_instances/'+value[i]["id"] ;
+
+ url = 'addorders/get_item_instance/'+value[i]["id"] ;
console.log("aaaaaa")
}
if (type ==-1 && modify_order == -1){
- url = '../../api/restaurant/menu_item_instances/'+value[i]["id"];
+
+ url = '../addorders/get_item_instance/'+value[i]["id"];
console.log("cccccccccc")
}
$.ajax({
type: "GET",
url: url,
- data: {id:value[i]},
+ // data: {id:value[i]},
success:function(result){
row = '
'
diff --git a/app/assets/javascripts/channels/order_reservation.js b/app/assets/javascripts/channels/order_reservation.js
new file mode 100644
index 00000000..605afe16
--- /dev/null
+++ b/app/assets/javascripts/channels/order_reservation.js
@@ -0,0 +1,38 @@
+App.checkin = App.cable.subscriptions.create('OrderReservationChannel', {
+// App.messages = App.cable.subscriptions.create('MessagesChannel', {
+
+ connected: function() {},
+
+ disconnected: function() {},
+
+ received: function(data) {
+ var order = data.data;
+ var rowCount = $('.order_reserve_cable tbody tr').length+1;
+
+ var date = new Date(order.requested_time);
+ var requested_time = date.getHours()+ ':' + date.getMinutes()+ '-' + date.getMinutes();
+
+ var isPM = date.getHours() >= 12;
+ var isMidday = date.getHours() == 12;
+ var result = document.querySelector('#result');
+ var time = [date.getHours() - (isPM && !isMidday ? 12 : 0),
+ date.getMinutes() || '00'].join(':') +
+ (isPM ? ' PM' : 'AM');
+
+ row = '
'
+ +'| '+rowCount
+ +' | '
+ +''+time
+ +' | '
+ +''+order.grand_total
+ +' | '
+ +''
+ +''+ order.status +''
+ +' | '
+ +'
'
+
+ $('.order_reserve_cable tbody').append(row);
+
+ }
+});
+
diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js
index fdea26b8..9b7c3fbb 100644
--- a/app/assets/javascripts/order_reservation.js
+++ b/app/assets/javascripts/order_reservation.js
@@ -62,7 +62,6 @@ $(function() {
// console.log(data);
var delivery = data["delivery"];
var items = data["order_items"];
-
var item_list = $('.summary-items');
item_list.empty();
@@ -113,7 +112,12 @@ $(function() {
$("#order_remark").text(data.reservation_remark);
}
$("#sr_number").text("No."+sr_no);
- $("#contact_info").text();
+ if (data["receipt_no"]) {
+ $("#contact_info").text(data["receipt_no"]);
+ }else{
+ $("#contact_info").text(data["order_reservation_id"]);
+ }
+
}
}
}
@@ -153,7 +157,6 @@ $(function() {
data: {'order_id': order_id, 'status': status},
dataType: "json",
success: function(data) {
- console.log(data);
if (data.status) {
swal({
title: 'Information',
diff --git a/app/channels/order_reservation_channel.rb b/app/channels/order_reservation_channel.rb
new file mode 100644
index 00000000..a461615e
--- /dev/null
+++ b/app/channels/order_reservation_channel.rb
@@ -0,0 +1,10 @@
+class OrderReservationChannel < ApplicationCable::Channel
+ def subscribed
+ stream_from "order_reservation_channel"
+ end
+
+ def unsubscribed
+ stop_all_streams
+ # Any cleanup needed when channel is unsubscribed
+ end
+end
\ No newline at end of file
diff --git a/app/controllers/api/api_controller.rb b/app/controllers/api/api_controller.rb
index 2340abd4..2c3c0df1 100755
--- a/app/controllers/api/api_controller.rb
+++ b/app/controllers/api/api_controller.rb
@@ -41,6 +41,21 @@ class Api::ApiController < ActionController::API
end
end
+ def website_connection(license)
+ default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
+ :username => license.dbusername, :password => license.dbpassword)
+
+ end
+
+ def reconnect_default_db
+ ActiveRecord::Base.establish_connection(Rails.env)
+ end
+
+ # Regular database.yml configuration hash
+ def default_connection
+ @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
+ end
+
def cache_license(url, lookup)
@license = License.new(url, lookup)
diff --git a/app/controllers/api/order_reserve/order_reservation_controller.rb b/app/controllers/api/order_reserve/order_reservation_controller.rb
index 2dfc29aa..42768d58 100644
--- a/app/controllers/api/order_reserve/order_reservation_controller.rb
+++ b/app/controllers/api/order_reserve/order_reservation_controller.rb
@@ -57,6 +57,10 @@ class Api::OrderReserve::OrderReservationController < Api::ApiController
if status == true
order_reservation_id, flag = OrderReservation.addOrderReservationInfo(params)
+
+ order_reservation = OrderReservation.find(order_reservation_id)
+ ActionCable.server.broadcast "order_reservation_channel",data: order_reservation
+
if flag
render :json => { :status => true, :order_reservation_id => order_reservation_id, :message => "Order reservation is successfully created!" }
else
diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb
index 14b1e2e1..590fdcbc 100755
--- a/app/controllers/concerns/login_verification.rb
+++ b/app/controllers/concerns/login_verification.rb
@@ -53,16 +53,4 @@ module LoginVerification
def render_unauthorized
redirect_to root_path
end
-
- private
- def check_license
- License.check_license_file
- end
-
- def check_installation
- if current_company.nil?
- redirect_to install_path
- end
- end
-
end
diff --git a/app/controllers/concerns/token_verification.rb b/app/controllers/concerns/token_verification.rb
index f8602ded..85c9b858 100755
--- a/app/controllers/concerns/token_verification.rb
+++ b/app/controllers/concerns/token_verification.rb
@@ -13,8 +13,8 @@ module TokenVerification
authenticate_token || render_unauthorized
end
- def authenticate_token
- authenticate_with_http_token do |token, options|
+ def authenticate_token
+ authenticate_with_http_token do |token, options|
# Rails.logger.debug "token - " + token.to_s
if(options.length !=0 && options["from"] == "DOEMAL")
if(ENV["SERVER_MODE"] === "cloud")
@@ -24,7 +24,8 @@ module TokenVerification
end
end
- @user = Employee.authenticate_by_token(token)
+ @user = Employee.
+ (token)
if @user
return true
#Maybe log - login?
diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb
index 8e23d2c9..499c20a7 100755
--- a/app/controllers/origami/addorders_controller.rb
+++ b/app/controllers/origami/addorders_controller.rb
@@ -58,6 +58,10 @@ class Origami::AddordersController < BaseOrigamiController
end
end
+ def get_item_instance
+ @id = MenuItemInstance.find(params[:id])
+ end
+
def get_menu()
if (params[:id])
#Pull this menu
@@ -180,7 +184,11 @@ puts items_arr.to_json
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
# for second display
- ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale"
+ # if ENV["SERVER_MODE"] != 'cloud'
+
+ ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale"
+
+ # end
result = {:status=> @status, :data => @sale }
render :json => result.to_json
end
diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb
index 0d3899bd..8bbba963 100755
--- a/app/controllers/origami/discounts_controller.rb
+++ b/app/controllers/origami/discounts_controller.rb
@@ -285,10 +285,10 @@ class Origami::DiscountsController < BaseOrigamiController
'Accept' => 'application/json; version=3'
}, :timeout => 10)
rescue HTTParty::Error
- response = {"status": false, "message": "Can't open membership server " }
+ response = {"status": false, "message": "Http party error" }
rescue Net::OpenTimeout
- response = {"status": false, "message": "Can't open membership server " }
+ response = {"status": false, "message": "Connection TIme out " }
rescue OpenURI::HTTPError
response = {"status": false, "message": "Can't open membership server " }
diff --git a/app/controllers/origami/second_display_controller.rb b/app/controllers/origami/second_display_controller.rb
index a2bf34fd..611b49a9 100644
--- a/app/controllers/origami/second_display_controller.rb
+++ b/app/controllers/origami/second_display_controller.rb
@@ -13,8 +13,9 @@ class Origami::SecondDisplayController < BaseOrigamiController
else
tax_profiles = nil
end
-
- ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status]
+ if ENV["SERVER_MODE"] != 'cloud'
+ ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status]
+ end
end
#Shop Name in Navbor
helper_method :shop_detail
diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb
index c94b33bb..2b2d9c33 100755
--- a/app/controllers/origami/waste_spoile_controller.rb
+++ b/app/controllers/origami/waste_spoile_controller.rb
@@ -92,7 +92,8 @@ class Origami::WasteSpoileController < BaseOrigamiController
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
- current_balance = SaleAudit.paymal_search(sale_id)
+ # current_balance = SaleAudit.paymal_search(sale_id)
+ current_balance = 0
end
# get printer info
diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb
index bc92a959..f73226f4 100755
--- a/app/controllers/settings/menus_controller.rb
+++ b/app/controllers/settings/menus_controller.rb
@@ -99,11 +99,39 @@ class Settings::MenusController < ApplicationController
sheet.add_row ["Name",menu.name], :style=>title
sheet.add_row
- sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Instance Code", "Instance Name", "Price"], :style=>header_text
+ sheet.add_row ["Category Code", "Category Name", "Item Code", "Item Name", "Account", "Item AltName", "Taxable", "Attributes", "Options", "Instance Code", "Instance Name", "Price", "Is Default"], :style=>header_text
menu.menu_categories.each do |mc|
mc.menu_items.each do |mi|
+ attributes = ""
+ i=0
+ if mi.item_attributes.length > 0
+ mi.item_attributes.each do |mia|
+ attribute = MenuItemAttribute.find(mia)
+ if i == mi.item_attributes.length - 1
+ attributes = attributes + attribute.name
+ else
+ attributes = attributes + attribute.name + ","
+ end
+ i = i + 1
+ end
+ end
+
+ options = ""
+ i=0
+ if mi.item_options.length > 0
+ mi.item_options.each do |mia|
+ option = MenuItemOption.find(mia)
+ if i == mi.item_options.length - 1
+ options = options + option.name
+ else
+ options = options + option.name + ","
+ end
+ i = i + 1
+ end
+ end
+
mi.menu_item_instances.each do |mii|
- sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, mii.item_instance_code, mii.item_instance_name, mii.price], :style=>wrap_text
+ sheet.add_row [ mc.code, mc.name, mi.item_code, mi.name, mi.account.title, mi.alt_name, mi.taxable, attributes, options, mii.item_instance_code, mii.item_instance_name, mii.price, mii.is_default], :style=>wrap_text
end
end
end
diff --git a/app/models/ability.rb b/app/models/ability.rb
index e9509289..5eab518f 100755
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -40,6 +40,8 @@ class Ability
can :index, :shiftsale
can :index, :credit_payment
can :index, :void_sale
+ can :index, :waste_and_spoilage
+ can :index, :product_sale
can :show, :dailysale
can :show, :saleitem
@@ -47,6 +49,8 @@ class Ability
can :show, :shiftsale
can :show, :credit_payment
can :show, :void_sale
+ can :show, :waste_and_spoilage
+ can :show, :product_sale
can :get_customer, Customer
can :add_customer, Customer
@@ -114,6 +118,9 @@ class Ability
can :print, :print
can :print_order_summary, :print
+ can :read, ShiftSale
+ can :update, ShiftSale
+
elsif user.role == "cashier"
# can :overall_void, :void
@@ -185,12 +192,16 @@ class Ability
can :index, :shiftsale
can :index, :credit_payment
can :index, :void_sale
+ can :index, :waste_and_spoilage
+ can :index, :product_sale
can :show, :dailysale
can :show, :saleitem
can :show, :receipt_no
can :show, :shiftsale
can :show, :credit_payment
can :show, :void_sale
+ can :show, :waste_and_spoilage
+ can :show, :product_sale
elsif user.role == "supervisor"
diff --git a/app/models/menu.rb b/app/models/menu.rb
index 28b23c76..60200aeb 100755
--- a/app/models/menu.rb
+++ b/app/models/menu.rb
@@ -153,6 +153,28 @@ class Menu < ApplicationRecord
# status = status + "Category Code already exists."
end
+ # Menu Item Attributes
+ item_attrs = []
+ attributes = row["Attributes"].split(',')
+ attributes.each do |attr|
+ attribute = MenuItemAttribute.find_by_name(attr)
+ if attribute.nil?
+ attribute = MenuItemAttribute.create({ attribute_type:"any", name: attr.capitalize, value: attr.downcase })
+ end
+ item_attrs.push(attribute.id)
+ end
+
+ # Menu Item Options
+ item_opts = []
+ options = row["Options"].split(',')
+ options.each do |opt|
+ option = MenuItemOption.find_by_name(opt)
+ if option.nil?
+ option = MenuItemOption.create({ option_type:"any", name: opt.capitalize, value: opt.downcase })
+ end
+ item_opts.push(option.id)
+ end
+
menu_itm = MenuItem.find_by_item_code(row["Item Code"])
if !menu_itm
account = Account.find_by_title(row["Account"])
@@ -160,14 +182,14 @@ class Menu < ApplicationRecord
account = Account.create({title: row["Account"], account_type: "0"})
end
- menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: "[]", item_options: "[]", is_sub_item: 0, is_available: 1, created_by: created_by)
+ menu_itm = MenuItem.create(item_code: row["Item Code"], name: row["Item Name"], account_id: account.id, alt_name: row["Item AltName"], image_path: "", description: '', information: '', unit: '', type: "SimpleMenuItem", menu_category_id: menu_cat.id, item_attributes: item_attrs, item_options: item_opts, is_sub_item: 0, is_available: 1, created_by: created_by)
# else
# status = status + "Item Code already exists for " + row["Item Name"] + "."
end
menu_inst = MenuItemInstance.find_by_item_instance_code(row["Instance Code"])
if !menu_inst
- imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: "[]", price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: false)
+ imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"])
# else
# status = status + "Instance Code already exists for " + row["Instance Name"] + "."
end
diff --git a/app/models/my_aes_crypt.rb b/app/models/my_aes_crypt.rb
index 20f747c9..7c86b158 100644
--- a/app/models/my_aes_crypt.rb
+++ b/app/models/my_aes_crypt.rb
@@ -62,8 +62,9 @@ class MyAesCrypt
shop_json = JSON.parse(shop_data)
shop_json["data"].each do |j|
- if j["lookup"] == from
- if(j["value"]["key"] == token)
+ if j["lookup"] == from
+ # add [0...44] for production cloud for remove \n
+ if(j["value"]["key"][0...44] == token)
return true
end
end
diff --git a/app/models/order.rb b/app/models/order.rb
index fcc8b6c2..e4ab883b 100755
--- a/app/models/order.rb
+++ b/app/models/order.rb
@@ -285,28 +285,13 @@ class Order < ApplicationRecord
#Process order items and send to order queue
def process_order_queue
- #Send to background job for processing
- order = Order.find(self.id)
- cup_status = `#{"sudo service cups status"}`
- print_status = check_cup_status(cup_status)
- sidekiq = Lookup.find_by_lookup_type("sidekiq")
-
- if print_status
- if !sidekiq.nil?
- OrderQueueProcessorJob.perform_later(self.id, self.table_id)
- else
- if order
- oqs = OrderQueueStation.new
- oqs.process_order(order, self.table_id, self.source)
- end
- assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
- ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
- end
- else
- cup_start = `#{"sudo service cups start"}`
+ if ENV["SERVER_MODE"] != 'cloud'
+ #Send to background job for processing
+ order = Order.find(self.id)
cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status)
-
+ sidekiq = Lookup.find_by_lookup_type("sidekiq")
+
if print_status
if !sidekiq.nil?
OrderQueueProcessorJob.perform_later(self.id, self.table_id)
@@ -315,40 +300,61 @@ class Order < ApplicationRecord
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id, self.source)
end
- assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
- ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
+ # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
+ # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
else
- msg = ' Print Error ! Please contact to service'
- ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
+ cup_start = `#{"sudo service cups start"}`
+ cup_status = `#{"sudo service cups status"}`
+ print_status = check_cup_status(cup_status)
+
+ if print_status
if !sidekiq.nil?
- OrderQueueProcessorJob.perform_later(self.id, self.table_id)
+ OrderQueueProcessorJob.perform_later(self.id, self.table_id)
else
if order
oqs = OrderQueueStation.new
oqs.process_order(order, self.table_id, self.source)
end
- assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
- ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
+ # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
+ # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
+ else
+ msg = ' Print Error ! Please contact to service'
+ ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error'
+ if !sidekiq.nil?
+ OrderQueueProcessorJob.perform_later(self.id, self.table_id)
+ else
+ if order
+ oqs = OrderQueueStation.new
+ oqs.process_order(order, self.table_id, self.source)
+ end
+ # assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
+ # ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
+ end
+ end
end
+ assign_order = AssignedOrderItem.assigned_order_item_by_job(self.id)
+ ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
-
+
end
#Process order items and send to order queue
def self.pay_process_order_queue(id,table_id)
- sidekiq = Lookup.find_by_lookup_type("sidekiq")
- if !sidekiq.nil?
- OrderQueueProcessorJob.perform_later(id, table_id)
- else
- order = Order.find(id)
- if order
- oqs = OrderQueueStation.new
- oqs.process_order(order, table_id)
+ if ENV["SERVER_MODE"] != 'cloud'
+ sidekiq = Lookup.find_by_lookup_type("sidekiq")
+ if !sidekiq.nil?
+ OrderQueueProcessorJob.perform_later(id, table_id)
+ else
+ order = Order.find(id)
+ if order
+ oqs = OrderQueueStation.new
+ oqs.process_order(order, table_id)
+ end
+ assign_order = AssignedOrderItem.assigned_order_item_by_job(id)
+ ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
- assign_order = AssignedOrderItem.assigned_order_item_by_job(id)
- ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
end
diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb
index 2fa99cf4..2d931d36 100644
--- a/app/models/order_reservation.rb
+++ b/app/models/order_reservation.rb
@@ -219,7 +219,19 @@ class OrderReservation < ApplicationRecord
end
def self.send_status_to_ordering(url,ref_no,status)
- base_url = "http://192.168.1.186:3002"
+ base_url = 'https://api.doemal.com'
+ order_reservation = Lookup.collection_of("order_reservation")
+ if !order_reservation.empty?
+ order_reservation.each do |order_reserve|
+ if order_reserve[0] == 'BaseURL'
+ base_url = order_reserve[1]
+ end
+ end
+ else
+ Rails.logger.debug "Add order reservation BaseURL "
+ response = {status: false}
+ end
+ Rails.logger.debug "Doemal URL" + base_url
post_url = base_url + url
begin
diff --git a/app/models/sale.rb b/app/models/sale.rb
index 10b48a18..522fcd62 100644
--- a/app/models/sale.rb
+++ b/app/models/sale.rb
@@ -128,6 +128,9 @@ class Sale < ApplicationRecord
self.save!
#compute sales summary
+ if order_source.nil?
+ order_source = order.source
+ end
compute(order_source)
#Update the order items that is billed
@@ -2603,34 +2606,35 @@ end
end
def self.all_receipts
- query = Sale.select("sales.*, sale_payments.created_at as receipt_close_time,
- case when (sale_audits.action='SALEPAYMENT') then sale_audits.remark else 0 end as remark,
- case when (sale_taxes.tax_name='Service Charges') then sale_taxes.tax_payable_amount else 0 end as service_charges,
- SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
- SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
- SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
- SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
- SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
- SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
- SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
- SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
- SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
- SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
- SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount,
- SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc,
- SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount,
- SUM(sale_items.qty) as qty,
- sales.cashier_name as cashier_name,
- surveys.child as child,
- surveys.adult as adult")
+ query = Sale.select("sale_payments.created_at as receipt_close_time,
+ case when (sale_audits.action='SALEPAYMENT') then sale_audits.remark else 0 end as remark,
+ case when (sale_taxes.tax_name='Service Charges') then sale_taxes.tax_payable_amount else 0 end as service_charges,
+ SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount,
+ SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount,
+ SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount,
+ SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount,
+ SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount,
+ SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount,
+ SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount,
+ SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount,
+ SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount,
+ SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount,
+ SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount,
+ SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc,
+ SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount,
+ SUM(sale_items.qty) as qty,
+ sales.cashier_name as cashier_name,
+ surveys.child as child,
+ surveys.adult as adult")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.joins("join sale_taxes on sale_taxes.sale_id = sales.sale_id")
.joins("join sale_items on sale_items.sale_id = sales.sale_id")
.joins("join sale_audits on sale_audits.sale_id = sales.sale_id")
.joins("left join surveys on surveys.receipt_no = sales.receipt_no")
-
- query = query.where("sale_status != 'new' && sale_payments.payment_amount > 0")
- .group("sale_id")
+
+ query = query.where("sales.sale_status != 'new' && sale_payments.payment_amount > 0")
+ query = query.where("sales.created_at between ? and ?", '2017-11-01 00:00:00 +0630','2018-02-05 13:59:59 +0630')
+ .group("sales.sale_id")
return query
end
@@ -2640,7 +2644,8 @@ def self.all_receipt_details
.joins("join sale_payments on sale_payments.sale_id = sale_items.sale_id")
.joins("join sales on sales.sale_id = sale_items.sale_id")
.group("sale_items.sale_item_id")
- query = query.where("qty > 0 and sales.sale_status !='new'")
+ query = query.where("sale_itemsqty > 0 and sales.sale_status !='new'")
+ query = query.where("sale_items.created_at between ? and ?", '2017-11-01 00:00:00 +0630','2018-02-05 13:59:59 +0630')
return query
end
diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb
index a04cfcad..7ebe5997 100755
--- a/app/pdf/receipt_bill_pdf.rb
+++ b/app/pdf/receipt_bill_pdf.rb
@@ -84,7 +84,7 @@ class ReceiptBillPdf < Prawn::Document
#start for individual payment
if !sale_data.equal_persons.nil?
- individual_payment(sale_data, printer_settings.precision, delimiter)
+ individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter)
end
#end for individual payment
@@ -487,7 +487,8 @@ class ReceiptBillPdf < Prawn::Document
#individual payment per person
def individual_payment(sale_data, survey, precision, delimiter)
- per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
+ # per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
+ per_person = sale_data.grand_total.to_f / survey.to_i
stroke_horizontal_rule
move_down line_move
y_position = cursor
diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb
index 70523063..87f3cabd 100755
--- a/app/views/crm/customers/index.html.erb
+++ b/app/views/crm/customers/index.html.erb
@@ -142,7 +142,7 @@ $(function() {
});
// QR Code Reader
- $("#qr_code").on('sclick', function(e){
+ $("#qr_code").on('click', function(e){
var code = "";
setTimeout(function(){
code=getQRCode();
diff --git a/app/views/origami/addorders/get_item_instance.json.jbuilder b/app/views/origami/addorders/get_item_instance.json.jbuilder
new file mode 100644
index 00000000..69302b8e
--- /dev/null
+++ b/app/views/origami/addorders/get_item_instance.json.jbuilder
@@ -0,0 +1,39 @@
+if(@id)
+ menu_item = MenuItem.find(@id.menu_item_id)
+ # Format for option json
+ opt_format = []
+ # Format for attributes json
+ menu_item.item_options.each do|opt|
+ menu_opt = MenuItemOption.find(opt)
+ if opt_format.count == 0
+ opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
+ next
+ end
+
+ opt_format.each do |of|
+ if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
+ if menu_opt.option_type == of[:type]
+ of[:values].push(menu_opt.name)
+ end
+ else
+ new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
+ opt_format.push(new_opt)
+ break
+ end
+ end
+ end
+
+ json.success true
+ json.id @id.id
+ json.name @id.item_instance_name
+ json.code @id.item_instance_code
+
+ json.item_id @id.menu_item_id
+ json.attributes @id.item_attributes
+ json.price @id.price
+ json.is_default @id.is_default
+
+ json.options opt_format
+else
+ json.success false
+end
diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb
index e5de4885..afe36d39 100755
--- a/app/views/origami/customers/index.html.erb
+++ b/app/views/origami/customers/index.html.erb
@@ -358,7 +358,7 @@
}
// QR Code Reader
- $("#qr_code").on('click', function(e){
+ $("#qr_code").on('click', function(e){
var code = "";
var customer_id = '';
var customer_name = '';
@@ -368,35 +368,34 @@
setTimeout(function(){
code=getQRCode();
setQRCode(code);
+ }, 100);
- customer_mamber_card_no = $("#search").val();
-
- if(sale_id != 0 && customer_mamber_card_no != 0){
- $.ajax({
- type: "POST",
- url: "/origami/"+sale_id+"/get_customer" ,
- data: { filter : customer_mamber_card_no ,type :"card"},
- dataType: "json",
- success: function(data) {
- if (data[0].customer_id == false) {
- swal("Alert!", data[0].message, "error");
- // $.alert({
- // title: 'Alert!',
- // content: data[0].message,
- // type: 'red',
- // typeAnimated: true,
- // btnClass: 'btn-danger',
- // });
- }else{
- customer_id = data[0].customer_id;
- customer_name = data[0].name;
- update_sale(customer_id, customer_name,sale_id);
- }
-
+ customer_mamber_card_no = $("#search").val();
+
+ if(sale_id != 0 && customer_mamber_card_no != 0){
+ $.ajax({
+ type: "POST",
+ url: "/origami/"+sale_id+"/get_customer" ,
+ data: { filter : customer_mamber_card_no ,type :"card"},
+ dataType: "json",
+ success: function(data) {
+ if (data[0].customer_id == false) {
+ swal("Alert!", data[0].message, "error");
+ // $.alert({
+ // title: 'Alert!',
+ // content: data[0].message,
+ // type: 'red',
+ // typeAnimated: true,
+ // btnClass: 'btn-danger',
+ // });
+ }else{
+ customer_id = data[0].customer_id;
+ customer_name = data[0].name;
+ update_sale(customer_id, customer_name,sale_id);
}
- });
- }
- },100);
+ }
+ });
+ }
});
// Read qrcode from java
diff --git a/app/views/origami/dinga/index.html.erb b/app/views/origami/dinga/index.html.erb
index 1a7bd798..fd41a44d 100644
--- a/app/views/origami/dinga/index.html.erb
+++ b/app/views/origami/dinga/index.html.erb
@@ -106,6 +106,12 @@
+
+
Card Tap
+
+
+
+
@@ -341,7 +347,7 @@
$.ajax({
type: "POST",
- url: "<%=origami_payment_paymal_path%>",
+ url: "<%=origami_payment_dinga_path%>",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:code},
success: function(result){
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb
index 7c736299..9e6cb2f9 100755
--- a/app/views/origami/home/show.html.erb
+++ b/app/views/origami/home/show.html.erb
@@ -786,7 +786,6 @@
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
- alert(parseInt(jQuery.inArray("PAYMAL", type)));
var sale_id = $('#sale_id').val();
// type = $('.payment_method').val();
diff --git a/app/views/origami/order_reservation/get_order.json.jbuilder b/app/views/origami/order_reservation/get_order.json.jbuilder
index 5fdd5293..e5ecdfe6 100644
--- a/app/views/origami/order_reservation/get_order.json.jbuilder
+++ b/app/views/origami/order_reservation/get_order.json.jbuilder
@@ -4,7 +4,7 @@ if @order
:requested_time,:callback_url,:transaction_ref,:item_count,:total_customer,:payment_type,
:payment_status,:payment_ref,:total_amount,:total_tax,
:discount_amount,:grand_total,:status,:order_remark,
- :reservation_remark)
+ :reservation_remark,:sale_id)
@delivery = Delivery.find_by_order_reservation_id(@order.order_reservation_id)
if @delivery
json.delivery do |json|
@@ -22,4 +22,9 @@ if @order
json.customer_name @customer.name
json.phone @customer.contact_no
+ if @order.sale_id
+ @receipt_no = Sale.find(@order.sale_id).receipt_no
+ json.receipt_no @receipt_no
+ end
+
end
diff --git a/app/views/origami/order_reservation/index.html.erb b/app/views/origami/order_reservation/index.html.erb
index ba735a1f..15f173ce 100644
--- a/app/views/origami/order_reservation/index.html.erb
+++ b/app/views/origami/order_reservation/index.html.erb
@@ -22,7 +22,7 @@