Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2018-01-17 12:06:29 +06:30
30 changed files with 450 additions and 247 deletions

View File

@@ -36,23 +36,54 @@ java -jar ~/Documents/Jade.jar http://192.168.1.88:3002
Person and Extra Time
category_code = SPL... //for menu categories
Extra Time
instance_code = Extim30, Extim60 //for morning menu
instance_code = Extie30, Extie60 //for evening menu
For Extra Time
item_instance_code
* must start with 'Ext'[a..z]'_'[1..100]
* note : don't add character after '_'
Order Item & Order Summary Slim
For Order Item & Order Summary Slim
*** change OrderItemPdf to OrderItemSlimPdf and OrderSummaryPdf to OrderSummarySlimPdf
1) settings/print_settings
2) app/controllers/oqs/edit_controller.rb
3) app/controllers/oqs/print_controller.rb
4) app/models/order_queue_station.rb
5) app/models/printer/order_queue_printer.rb
6) app/models/printer/receipt_printer.rb
2) settings/lookups => { type:order_slim_pdf, name:OrderSlimPdf, value:1 }
* no need to change these page
{ app/controllers/oqs/edit_controller.rb
app/controllers/oqs/print_controller.rb
app/models/order_queue_station.rb
app/models/printer/order_queue_printer.rb
app/models/printer/receipt_printer.rb
}
For Bank Integration setting
1) rake db:migrate for card_sale_trans, card_settle_trans
2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 }
For checkout time and checkout alert time
1) checkout time => { type: checkout_time, name: 9:00AM - 12:00 PM, value: 120 }
2) checkout alert time => { type: checkout_alert_time, name: 8:00AM - 12:00 PM, value: 60 }
* you can add multiple record for checkout time and checkout alert time
* type must be 'checkout_time' and 'checkout_alert_time'
* you can change name and value
* name must be time range [8:30 AM - 1:45 PM]
* value must be minutes[60]
For call waiter pdf
* Backend > Printer > Print Settings > New
i) Name : Calling Waiter
ii) Unique Code: CallWaiterPdf
iii)Template: ...
iv) Font: Zawgyi-One
v) Printer: #printer name
Membership Actions SQL
* update membership_actions set additional_parameter='{\"campaign_type_id\":5}' where id=10;
SQL Update after rake clear:data runned
* update seed_generators
i) TableBooking, Order, OrderItem, sale, SaleOrder, SaleItem, SaleTax, SalePayment, SaleAudit, AssignedOrderItem => { current:0, next:0 }
** Note :: do not update Customer
* ToDo list
1. Cloud Sync

View File

@@ -217,29 +217,31 @@ $(document).on('turbolinks:load', function() {
});
// Print Order Item
// $(document).on('click', '#print_order_item', function(event){
// var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
// var options = $('.selected-item').children('.card-block').find('.item-options').text();
// var params = { 'options':options };
$(document).on('click', '#print_order_item', function(event){
var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text();
var options = $('.selected-item').children('.card-block').find('.item-options').text();
var params = { 'options':options };
// $.ajax({
// type: 'GET',
// url: '/oqs/print/print/'+assigned_item_id,
// success: function(data){ }
// });
// });
$.ajax({
type: 'POST',
url: '/oqs/print/print/'+assigned_item_id,
data: params,
success: function(data){ }
});
});
// Print Order Summary
// $(document).on('click', '#print_order_summary', function(event){
// var orderNo = $('.selected-item').attr('data-order-no');
// var table_name=$('.selected-item').children().children().children('.order-zone').text().trim();
// var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
// var params = { 'table_name':table_name };
// $.ajax({
// type: 'GET',
// url: '/oqs/print/print_order_summary/'+assigned_item_id,
// data: params,
// success: function(data){ }
// });
// });
// Print Order Summary
// $('#print_order_summary').on('click',function(){
$(document).on('click', '#print_order_summary', function(event){
var orderNo = $('.selected-item').attr('data-order-no');
var table_name=$('.selected-item').children().children().children('.order-zone').text().trim();
var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text();
var params = { 'table_name':table_name };
$.ajax({
type: 'GET',
url: '/oqs/print/print_order_summary/'+assigned_item_id,
data: params,
success: function(data){ }
});
});
});

View File

@@ -15,12 +15,16 @@ class Api::CheckInProcessController < Api::ApiController
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
alert_time_min = 0
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'min'
alert_time_min = (lookup_checkout_time[0][1]).to_i
else
alert_time_min = 15
end
if !lookup_checkout_time.empty?
now = Time.now.utc
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= now && now <= end_time
alert_time_min = checkout_time[1].to_i
end
end
end
render :json => { :status => true, :check_in_time => check_in_time, :check_out_time => check_out_time, :alert_time_min => alert_time_min, :extra_minutes => extra_minutes }
@@ -39,11 +43,12 @@ class Api::CheckInProcessController < Api::ApiController
if !lookup_checkout_time.empty?
checkout_at = Time.now.utc
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'hr'
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
else
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= checkout_at && checkout_at <= end_time
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
end
end

View File

@@ -54,22 +54,13 @@ class Api::OrdersController < Api::ApiController
extra_time = ''
params[:order_items].each { |i|
if i["item_instance_code"] == 'Extim60' || i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extim45' || i["item_instance_code"] == 'Extim15' || i["item_instance_code"] == 'Extie60' || i["item_instance_code"] == 'Extie30' || i["item_instance_code"] == 'Extie45' || i["item_instance_code"] == 'Extie15'
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
if i["item_instance_code"].include? "ext"
is_extra_time = true
if i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie30'
t = Time.now
time = 30*60*i["quantity"].to_i
extra_time = Time.at(time)
elsif i["item_instance_code"] == 'Extim15' || i["item_instance_code"] == 'Extie15'
time = 15*60*i["quantity"].to_i
extra_time = Time.at(time)
elsif i["item_instance_code"] == 'Extim45' || i["item_instance_code"] == 'Extie45'
time = 45*60*i["quantity"].to_i
extra_time = Time.at(time)
else
t = Time.now
time = 60*60*i["quantity"].to_i
extra_time = Time.at(time)
arr_exts = i["item_instance_code"].split("_")
if arr_exts[1].match(/^(\d)+$/)
time = arr_exts[1].to_i*60*i["quantity"].to_i
extra_time = Time.at(time)
end
end
}

View File

@@ -16,15 +16,24 @@ class Oqs::EditController < BaseOqsController
order_item.remark = remarks
order_item.save
# print
# assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
# # order queue stations
# oqs = assigned_item.order_queue_station
# unique_code="OrderItemPdf"
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# print
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
# order queue stations
oqs = assigned_item.order_queue_station
# print_settings=PrintSetting.find_by_unique_code(unique_code)
# order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
# order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Updated)" )
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
unique_code="OrderItemPdf"
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
unique_code="OrderItemSlimPdf"
end
end
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Updated)" )
end
end
end

View File

@@ -1,61 +1,80 @@
class Oqs::PrintController < ApplicationController
# Print Order Item
def print
# unique_code="OrderItemPdf"
# assigned_item_id = params[:id]
# options = params[:options]
# assigned_item = AssignedOrderItem.find(assigned_item_id)
# assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
unique_code="OrderItemPdf"
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
unique_code="OrderItemSlimPdf"
end
end
assigned_item_id = params[:id]
options = params[:options]
assigned_item = AssignedOrderItem.find(assigned_item_id)
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# # order queue stations
# oqs = assigned_item.order_queue_station
# order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
# order queue stations
oqs = assigned_item.order_queue_station
order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
# # Check Printed
# print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
# Check Printed
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
# # 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(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, options )
# # update print status for completed same order items
# assigned_items.each do |ai|
# ai.print_status=true
# ai.save
# end
# 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(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, options )
# update print status for completed same order items
assigned_items.each do |ai|
ai.print_status=true
ai.save
end
end
end
# Print Order Details with booking id
def print_order_summary
# unique_code="OrderSummaryPdf"
# assigned_item_id = params[:id]
# table_name = params[:table_name]
# assigned_item = AssignedOrderItem.find(assigned_item_id)
# assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
unique_code="OrderSummaryPdf"
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
unique_code="OrderSummarySlimPdf"
end
end
# # order queue stations
# oqs = assigned_item.order_queue_station
assigned_item_id = params[:id]
table_name = params[:table_name]
assigned_item = AssignedOrderItem.find(assigned_item_id)
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# # Check Printed
# print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
# order queue stations
oqs = assigned_item.order_queue_station
# # get dining
# # dining = DiningFacility.find_by_name(table_name);
# # booking = Booking.find_by_dining_facility_id(dining.id)
# Check Printed
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
# # Get Booking ID
# booking_id = BookingOrder.where("order_id='#{assigned_item.order_id}'").pluck(:booking_id)[0]
# # 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_booking_summary(print_settings,oqs, booking_id, print_status)
# get dining
# dining = DiningFacility.find_by_name(table_name);
# booking = Booking.find_by_dining_facility_id(dining.id)
# # update print status for completed same order items
# assigned_items.each do |ai|
# ai.print_status = true
# ai.save
# end
# Get Booking ID
booking_id = BookingOrder.where("order_id='#{assigned_item.order_id}'").pluck(:booking_id)[0]
# 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_booking_summary(print_settings,oqs, booking_id, print_status)
# update print status for completed same order items
assigned_items.each do |ai|
ai.print_status = true
ai.save
end
end
end
end
end

View File

@@ -67,20 +67,13 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
items_arr = []
JSON.parse(params[:order_items]).each { |i|
if i["item_instance_code"] == 'Extim60' || i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extim45' || i["item_instance_code"] == 'Extim15' || i["item_instance_code"] == 'Extie60' || i["item_instance_code"] == 'Extie30' || i["item_instance_code"] == 'Extie45' || i["item_instance_code"] == 'Extie15'
i["item_instance_code"] = i["item_instance_code"].downcase.to_s
if i["item_instance_code"].include? "ext"
is_extra_time = true
if i["item_instance_code"] == 'Extim30' || i["item_instance_code"] == 'Extie30'
time = 30*60*i["quantity"].to_i
extra_time = Time.at(time)
elsif i["item_instance_code"] == 'Extim15' || i["item_instance_code"] == 'Extie15'
time = 15*60*i["quantity"].to_i
extra_time = Time.at(time)
elsif i["item_instance_code"] == 'Extim45' || i["item_instance_code"] == 'Extie45'
time = 45*60*i["quantity"].to_i
extra_time = Time.at(time)
else
time = 60*60*i["quantity"].to_i
extra_time = Time.at(time)
arr_exts = i["item_instance_code"].split("_")
if arr_exts[1].match(/^(\d)+$/)
time = arr_exts[1].to_i*60*i["quantity"].to_i
extra_time = Time.at(time)
end
end
items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]}

View File

@@ -3,12 +3,14 @@ class Origami::CheckInProcessController < BaseOrigamiController
def check_in_process
lookup_checkout_time = Lookup.collection_of("checkout_time")
checkout_at = Time.now.utc
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'hr'
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.hour
else
checkout_at = checkout_at + (lookup_checkout_time[0][1]).to_i.minutes
if !lookup_checkout_time.empty?
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= checkout_at && checkout_at <= end_time
checkout_at = checkout_at + (checkout_time[1]).to_i.minutes
end
end
end
@dining_facility = DiningFacility.find(params[:dining_id])

View File

@@ -1,4 +1,5 @@
class Origami::HomeController < BaseOrigamiController
authorize_resource :class => false
before_action :set_dining, only: [:show]
def index

View File

@@ -21,8 +21,6 @@ class Origami::PaymentsController < BaseOrigamiController
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
Rails.logger.debug ENV["SERVER_MODE"]
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf"

View File

@@ -54,27 +54,26 @@ class Origami::ShiftsController < BaseOrigamiController
card_sett_trans.save()
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
unique_code = "CloseCashierPdf"
shop_details = Shop.find(1)
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
#other payment details for mpu or visa like card
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# unique_code = "CloseCashierPdf"
# shop_details = Shop.find(1)
# #get tax
# shift_obj = ShiftSale.where('id =?',@shift.id)
# @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
# #other payment details for mpu or visa like card
# @other_payment = ShiftSale.get_by_shift_other_payment(@shift)
# Calculate price_by_accounts
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
# # Calculate price_by_accounts
# @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
# @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
# @total_member_discount = ShiftSale.get_total_member_discount(@shift)
# # get printer info
# print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
# printer = Printer::CashierStationPrinter.new(print_settings)
# printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
end
end
Employee.logout(session[:session_token])
session[:session_token] = nil

View File

@@ -63,6 +63,7 @@ class Origami::VoidController < BaseOrigamiController
member_info = nil
rebate_amount = nil
current_balance = nil
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
@@ -87,7 +88,9 @@ class Origami::VoidController < BaseOrigamiController
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
current_balance = SaleAudit.paymal_search(sale_id)
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total

View File

@@ -89,10 +89,14 @@ class Ability
can :manage, Inventory
can :index, :home
can :show, :home
elsif user.role == "cashier"
# can :overall_void, :void
can :index, :home
can :show, :home
can :read, Order
can :update, Order
can :menage, Booking
@@ -161,6 +165,7 @@ class Ability
can :create, :discount
can :remove_discount_items, :discount
can :remove_all_discount, :discount
can :member_discount, :discount
can :manage, Customer
can :manage, DiningQueue
@@ -176,6 +181,9 @@ class Ability
can :manage, Promotion
can :manage, Product
can :index, :home
can :show, :home
end
end
end

View File

@@ -80,11 +80,15 @@ class DiningFacility < ApplicationRecord
if booking
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'min'
free_time_min = (lookup_checkout_time[0][1]).to_i
else
free_time_min = 15
if !lookup_checkout_time.empty?
now = Time.now.utc
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= now && now <= end_time
free_time_min = checkout_time[1].to_i
end
end
end
@@ -115,11 +119,15 @@ class DiningFacility < ApplicationRecord
if bookings
lookup_checkout_time = Lookup.collection_of("checkout_alert_time")
free_time_min = 0
if !lookup_checkout_time.nil?
if lookup_checkout_time[0][0] == 'min'
free_time_min = (lookup_checkout_time[0][1]).to_i
else
free_time_min = 15
if !lookup_checkout_time.empty?
now = Time.now.utc
lookup_checkout_time.each do |checkout_time|
arr_time = checkout_time[0].split("-")
start_time = Time.parse(arr_time[0].strip).utc.strftime("%H:%M%p")
end_time = Time.parse(arr_time[1].strip).utc.strftime("%H:%M%p")
if start_time <= now && now <= end_time
free_time_min = checkout_time[1].to_i
end
end
end

View File

@@ -14,6 +14,7 @@ class OrderQueueStation < ApplicationRecord
validates_presence_of :station_name, :printer_name
def process_order (order, table_id)
oqs_stations = OrderQueueStation.active
dining=DiningFacility.find(table_id)
# oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
@@ -77,47 +78,70 @@ class OrderQueueStation < ApplicationRecord
end
end
end
# if oqs.auto_print
# if oqs_order_items.length > 0
# print_slip(oqs, order, oqs_order_items)
# is_auto_printed = true
# end
# end
end
if oqs.auto_print
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
# if oqs.id == oqpbz.order_queue_station_id
# # Auto Printing
# if oqs.auto_print
# if oqs_order_items.length > 0
# print_slip(oqs, order, oqs_order_items)
# is_auto_printed = true
# end
# end
# end
end
# end
end
private
#Print order_items in 1 slip
def print_slip(oqs, order, order_items)
# 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(print_settings, oqs,order.order_id, order_items, print_status="")
def print_slip(oqs, order, order_items)
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
unique_code="OrderSummaryPdf"
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
unique_code="OrderSummarySlimPdf"
end
end
# AssignedOrderItem.where("order_id = '#{ order.order_id }'").find_each do |ai|
# # update print status for order items
# ai.print_status=true
# ai.save
# end
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
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
ai.print_status=true
ai.save
end
end
#Print order_item in 1 slip per item
def print_slip_item(oqs, assigned_item)
# unique_code="OrderItemPdf"
# order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
# # 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(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" )
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
unique_code="OrderItemPdf"
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
unique_code="OrderItemSlimPdf"
end
end
order_item = OrderItem.where("order_id='#{assigned_item.order_id}' AND item_instance_code='#{assigned_item.instance_code}'").first()
# 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(print_settings, oqs,item.order_id, order_item.order_items_id, print_status="" )
# # update print status for completed same order items
# assigned_order_item.each do |ai|
# ai.print_status=true
# ai.save
# end
# update print status for completed same order items
assigned_order_item.each do |ai|
ai.print_status=true
ai.save
end
end
end

View File

@@ -14,9 +14,19 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf"
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
# check for item not to show
# if order_item[0].price != 0
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
else
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
end
else
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name)
end
pdf.render_file filename
if oqs.print_copy
@@ -43,6 +53,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_settings.save!
end
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
order=print_query('order_summary', order_id)
# For Print Per Item
if oqs.cut_per_item
@@ -55,7 +67,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# check for item not to show
#if odi.price != 0
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
else
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
end
else
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name)
end
# pdf.render_file "tmp/order_item.pdf"
pdf.render_file filename
if oqs.print_copy
@@ -71,7 +91,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# For Print Order Summary
else
filename = "tmp/order_summary_#{order_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
else
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
end
else
pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name)
end
pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name)
@@ -94,6 +122,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_settings.save!
end
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
order=print_query('booking_summary', booking_id)
# For Print Per Item
if oqs.cut_per_item
@@ -104,7 +134,15 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
# check for item not to show
#if odi.price != 0
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
else
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
end
else
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name)
end
pdf.render_file filename
if oqs.print_copy
@@ -122,8 +160,16 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
end
# For Print Order Summary
else
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
filename = "tmp/booking_summary_#{booking_id}" + ".pdf"
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
else
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
end
else
pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name)
end
pdf.render_file filename
if oqs.print_copy
self.print(filename, oqs.printer_name)

View File

@@ -24,11 +24,11 @@ class Printer::PrinterWorker
end
end
def printers()
def self.printers()
Cups.show_destinations
end
def default_printer()
def self.default_printer()
Cups.default_printer
end

View File

@@ -4,7 +4,13 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
pdf = OrderItemPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderItemSlimPdf.new
end
end
pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf"
self.print("tmp/receipt.pdf")
end
@@ -14,7 +20,13 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Generate PDF
#Print
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)
@@ -24,8 +36,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)
@@ -35,8 +53,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)
@@ -46,8 +70,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)
@@ -57,8 +87,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
#Use CUPS service
#Generate PDF
#Print
order_slim_pdf = Lookup.collection_of("order_slim_pdf") #order_slim_pdf
filename = "tmp/order_summary_#{booking_id}" + ".pdf"
pdf = OrderSummaryPdf.new
if !order_slim_pdf.empty?
if order_slim_pdf[0][1] == '1'
pdf = OrderSummarySlimPdf.new
end
end
pdf.render_file filename
self.print(filename)

View File

@@ -665,7 +665,8 @@ def self.get_item_query()
# "JOIN employee_accesses ea ON ea.`employee_id` = sales.cashier_id ")
query = query.joins(" JOIN accounts acc ON acc.id = mi.account_id")
# query = query.where("i.item_instance_code IS NOT NULL")
query = query.group("acc.title,mi.account_id,i.product_name").order("acc.title desc, mi.account_id desc")
query = query.group("acc.title,mi.account_id,i.product_name")
.order("acc.title desc, mi.account_id desc, i.unit_price asc")
end
def self.get_other_charges()

View File

@@ -43,12 +43,14 @@
</a>
</li>
<% end %>
<% if can? :index, :home %>
<li>
<a href="<%= origami_root_path %>">
<i class="material-icons">monetization_on</i>
<span><%= t :origami %></span>
</a>
</li>
<% end %>
<% if can? :menage, Customer %>
<li>
<a href="javascript:void(0);" class="menu-toggle">
@@ -106,6 +108,7 @@
<% end %>
</ul>
</li>
<% if can? :index, :dailysale %>
<li>
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">assessment</i>
@@ -141,6 +144,7 @@
</li>
</ul>
</li>
<%end%>
<li class="header"><%= t :settings %></li>
<% if can? :menage, Zone %>
<li>

View File

@@ -168,8 +168,10 @@
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- OQS Buttons -->
<a href="<%= dashboard_path %>" class="btn btn-sm btn-block btn-default waves-effect" role="button" aria-haspopup="true"><i class="material-icons">reply</i> Back </a>
<!-- <button type="button" title="Print Order Item" id="print_order_item" class="btn bg-blue btn-block btn-lg waves-effect">Print</a>
<button type="button" class="btn bg-blue btn-block btn-lg waves-effect" id="print_order_summary">Print <br/>Order<br/>Summary</button> -->
<% if ENV["SERVER_MODE"] != "cloud" %>
<button type="button" title="Print Order Item" id="print_order_item" class="btn bg-blue btn-block btn-lg waves-effect">Print</a>
<button type="button" class="btn bg-blue btn-block btn-lg waves-effect" id="print_order_summary">Print <br/>Order<br/>Summary</button>
<%end%>
</div>
</div>

View File

@@ -576,7 +576,7 @@
swal ( "Oops" , "Please select an table!" , "warning" );
}
}else{
swal("Opps","You are not authorized for void","warning")
swal("Opps","You are not authorized for Discount","warning")
}
return false;
});
@@ -605,7 +605,7 @@
var sale_id = $('#sale_id').val();
type = $('.payment_method').val();
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) > 0 || parseInt(jQuery.inArray("VISA", type)) > 0 || parseInt(jQuery.inArray("JCB", type)) > 0 || parseInt(jQuery.inArray("Master", type)) > 0 || parseInt(jQuery.inArray("UNIONPAY", type)) > 0 || parseInt(jQuery.inArray("Redeem", type)) > 0) {
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1) {
calculate_member_discount(sale_id,"Card");
}else{

View File

@@ -94,11 +94,13 @@
<% else %>
<div id="save_order_id" data-order="">
<% end %>
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
<% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? %>
<span class="float-right"><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% else %>
<span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% if !@booking.nil? %>
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @dining.name rescue "" %>
<% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? %>
<span class="float-right"><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% else %>
<span class="float-right">Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% end %>
<% end %>
</div>
<% elsif @status_sale == 'sale' %>
@@ -149,10 +151,10 @@
<div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
<% if @status_sale == 'sale' %>
<% if @status_sale == 'sale' && !@sale_array.empty? %>
<p class="hidden customer-id"><%= @sale_array[0].customer_id rescue '' %></p>
&nbsp; Customer : <%= @sale_array[0].customer.name rescue '' %>
<% elsif @status_order == 'order'
<% elsif @status_order == 'order' && !@customer.nil?
%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
&nbsp; Customer : <%= @customer.name rescue "" %>

View File

@@ -312,18 +312,20 @@
receipt_no = ($("#receipt_no").html()).trim();
}
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
console.log(payment_type)
payment_type = '';
if ($("#server_mode").val() != "cloud") { // first bill not used in cloud
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
if (member_id && member_discount) {
if(parseInt(jQuery.inArray("Credit", payment_type)) == -1){
$("#credit_payment").hide();
} else{
$("#credit_payment").show();
}
if(parseInt(jQuery.inArray("MPU", payment_type)) > 0 || parseInt(jQuery.inArray("VISA", payment_type)) > 0 || parseInt(jQuery.inArray("JCB", payment_type)) > 0 || parseInt(jQuery.inArray("Master", payment_type)) > 0 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) > 0 || parseInt(jQuery.inArray("Redeem", payment_type)) > 0){
$("#card_payment").show();
if(parseInt(jQuery.inArray("MPU", payment_type)) !=-1 || parseInt(jQuery.inArray("VISA", payment_type)) !=-1 || parseInt(jQuery.inArray("JCB", payment_type)) !=-1 || parseInt(jQuery.inArray("Master", payment_type)) !=-1 || parseInt(jQuery.inArray("UNIONPAY", payment_type)) !=-1 || parseInt(jQuery.inArray("Redeem", payment_type)) !=-1){
$("#card_payment").show();
} else{
$("#card_payment").hide();
}
@@ -457,9 +459,9 @@
var credit = $('#credit').text();
var card = $('#card').text();
if (credit <= 0) {
calculate_member_discount(sale_id);
}
if (credit <= 0) {
calculate_member_discount(sale_id);
}
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",

View File

@@ -367,17 +367,21 @@
<!-- <button type="button" class="btn bg-blue btn-block" disabled>Add Order</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<button type="button" class="btn bg-blue btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn bg-blue btn-block" >Discount</button>
<button type="button" id="discount" class="btn bg-blue btn-block" active="<%= can? :index, :discount %>" >Discount</button>
<button type="button" id="other-charges" class="btn bg-blue btn-block" >Charges</button>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<!-- <button type="button" class="btn bg-blue btn-block" id='move' disabled="">Move</button> -->
<!-- <button type="button" id="request_bills" class="btn bg-blue btn-block" disabled> Req.Bill</button> -->
<!-- first bill not used in cloud -->
<% if ENV["SERVER_MODE"] != "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<% end %>
<% if ENV["SERVER_MODE"] == "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<% else %>
<%if @membership.discount && @obj_sale.customer.membership_id %>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">First Bill</button>
<%else%>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<%end%>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" id="void" class="btn bg-blue btn-block" > Void </button>
<% end %>
@@ -393,6 +397,7 @@
<div class="modal-body">
<select class="form-control show-tick payment_method" multiple="true" id="payment_method" >
<option value="Cash">Cash</option>
<option value="Credit">Credit</option>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
@@ -535,25 +540,29 @@ $(document).ready(function(){
return false;
});
// Discount for Payment
$('#discount').click(function() {
var sale = $('#sale_id').val();
if (sale!="") {
var sale_id = sale
$('#discount').click(function () {
if ($(this).attr('active')=== "true") {
var sale = $('#sale_id').val();
if (sale != "") {
var sale_id = sale
} else {
var sale_id = $('#save_order_id').attr('data-order');
}
if (sale_id != "") {
window.location.href = '/origami/' + sale_id + '/discount'
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
}
}else{
var sale_id = $('#save_order_id').attr('data-order');
swal("Opps","You are not authorized for Discount","warning")
}
if(sale_id!=""){
window.location.href = '/origami/' + sale_id + '/discount'
}
else {
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
});
// Discount for Payment
// Add Other Charges
$('#other-charges').click(function() {
@@ -595,11 +604,17 @@ $("#first_bill").on('click', function(){
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
type = $('.payment_method').val();
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1) {
calculate_member_discount(sale_id,"Card");
calculate_member_discount(sale_id,type);
}else{
calculate_member_discount(sale_id,"Cash");
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
@@ -609,7 +624,6 @@ $(".choose_payment").on('click', function () {
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
location.reload();
}
});

View File

@@ -11,7 +11,7 @@
<%= f.input :unique_code %>
<%= f.input :template %>
<%= f.input :font %>
<%= f.input :printer_name %>
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
<%= f.input :api_settings %>
<%= f.input :page_width %>
<%= f.input :page_height %>

View File

@@ -12,7 +12,7 @@
<%= f.input :auto_print_receipt %>
<%= f.label "Select Zones", :class => 'control-label' %>
<%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'checkbox form-group'%>
<%= f.input :printer_name %>
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
<%= f.input :font %>
<%= f.input :font_size %>
<%= f.input :show_tax %>

View File

@@ -16,7 +16,7 @@ div.form-inputs span{
<%= f.input :station_name %>
<%= f.input :is_active %>
<%= f.input :printer_name %>
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
<!-- <%= f.input :font_size %> -->
<%= f.input :print_copy %>
<%= f.hidden_field :processing_items %>

View File

@@ -7,7 +7,10 @@ scope "(:locale)", locale: /en|mm/ do
mount Sidekiq::Web => '/kiq'
# Action Cable Creation
mount ActionCable.server => "/cable"
# if ENV["SERVER_MODE"] != "cloud"
mount ActionCable.server => "/cable"
# end
#--------- SmartSales Activation ------------#
get 'activate' => 'install#index'

View File

@@ -25,7 +25,7 @@ test:
production:
secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22
sx_provision_url: connect.smartsales.asia/api #192.168.1.147:3002/api
server_mode: cloud
server_mode: application
cipher_type: AES-256-CBC
sx_key: Wh@t1$C2L