add close cashier print setting
This commit is contained in:
71
README.md
71
README.md
@@ -17,7 +17,7 @@ Osaka =>
|
||||
Campaign Id => {"campaign_type_id": 5}
|
||||
|
||||
BITP
|
||||
Auth Token => pZBHXEFbGNj/G => New => V3
|
||||
Auth Token => pZBHXEFbGNj/G => New => V3
|
||||
iua0SjUHzRaQw
|
||||
=> rj0MJ0XI5GsKZehE => Old => V2
|
||||
=> code2lab => Old
|
||||
@@ -34,11 +34,11 @@ Person and Extra Time
|
||||
2) must create Adult and Child in settings/item_attributes
|
||||
3) must be PSA_[a-z/0-9] for Adult and PSC_[a-z/0-9] for Child in settings/menu_categories/[cat_id]/simple_menu_items
|
||||
3) must be PSAI_[a-z/0-9] for Adult and PSCI_[a-z/0-9] for Child in settings/simple_menu_items/[item_id]/menu_item_instances
|
||||
|
||||
For Extra Time
|
||||
item_instance_code
|
||||
|
||||
For Extra Time
|
||||
item_instance_code
|
||||
* must start with 'Ext'[a..z]'_'[1..100]
|
||||
* note : don't add character after '_'
|
||||
* note : don't add character after '_'
|
||||
|
||||
For Order Printing
|
||||
1)) ********* Order Pdf *********
|
||||
@@ -50,18 +50,18 @@ For Order Printing
|
||||
1) settings/print_settings
|
||||
(a) Unique Code => OrderSetItemPdf & OrderSummarySetPdf
|
||||
(b) Font is present => {Header font size:11, Item Font Size:9}
|
||||
Font is blank => {Header font size:12, Item Font Size:10}
|
||||
Font is blank => {Header font size:12, Item Font Size:10}
|
||||
3)) ********* Order Slim Pdf *********
|
||||
1) settings/print_settings
|
||||
(a) Unique Code => OrderItemSlimPdf & OrderSummarySlimPdf
|
||||
(b) Font is present => {Header font size:11, Item Font Size:9}
|
||||
Font is blank => {Header font size:12, Item Font Size:10}
|
||||
4)) ********* Order Customise PDF *********
|
||||
1) settings/print_settings
|
||||
1) settings/print_settings
|
||||
(a) Unique Code => OrderItemCustomisePdf & OrderSummaryCustomisePdf
|
||||
(b) Can change Header font size and Item Font Size as you like
|
||||
(b) Can change Header font size and Item Font Size as you like
|
||||
5)) ********* Order Set Pdf *********
|
||||
1) settings/print_settings
|
||||
1) settings/print_settings
|
||||
(a) Unique Code => OrderSetItemCustomisePdf & OrderSummarySetCustomisePdf
|
||||
(b) Can change Header font size and Item Font Size as you like
|
||||
6)) ********* Order Slim Customise PDF
|
||||
@@ -100,20 +100,20 @@ For call waiter pdf
|
||||
i) Name : Calling Waiter
|
||||
ii) Unique Code: CallWaiterPdf
|
||||
iii)Template: ...
|
||||
iv) Font: Zawgyi-One
|
||||
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
|
||||
* update seed_generators
|
||||
i) TableBooking, Order, OrderItem, sale, SaleOrder, SaleItem, SaleTax, SalePayment, SaleAudit, AssignedOrderItem => { current:0, next:0 }
|
||||
** Note :: do not update Customer
|
||||
** Note :: do not update Customer
|
||||
|
||||
Change type in mysql
|
||||
*run if you got font error for Myanmar, Chinese, etc...
|
||||
=> ALTER TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for table
|
||||
=> ALTER TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for table
|
||||
=> ALTER DATABASE [database_name] CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database
|
||||
|
||||
For split bill
|
||||
@@ -124,9 +124,9 @@ For Sidekiq
|
||||
=> Create New Lookups => lookup_type = sidekiq, Name = sidekiq , Value = 1 or 0
|
||||
|
||||
For Clear Menu
|
||||
1) rake clear:menu # menu,menu item,menu category,menu item instance,account,item option,item attribute,item set
|
||||
|
||||
For Check CUp status
|
||||
1) rake clear:menu # menu,menu item,menu category,menu item instance,account,item option,item attribute,item set
|
||||
|
||||
For Check CUp status
|
||||
###please open
|
||||
sudo cat /etc/sudoers
|
||||
### cope and parse
|
||||
@@ -177,16 +177,16 @@ For CloseCashierCustomisePdf in lookups
|
||||
1) settings/print_settings
|
||||
2) settings/lookups => { type:print_settings, name: CloseCashierCustomisePdf, value:1 }
|
||||
|
||||
<---- Extra Fields Script ----->
|
||||
For MoveTablePdf in lookups
|
||||
<---- Extra Fields Script ----->
|
||||
For MoveTablePdf in lookups
|
||||
*** Both Table and Room Moving ***
|
||||
1) settings/lookups => { type:print_settings, name: MoveTablePdf, value:1 }
|
||||
|
||||
For MoveTablePdf in print settings
|
||||
* Backend > Printer > Print Settings > New
|
||||
i) Name : Move Table
|
||||
ii) Unique Code: MoveTablePdf
|
||||
iii)Template: ...
|
||||
For MoveTablePdf in print settings
|
||||
* Backend > Printer > Print Settings > New
|
||||
i) Name : Move Table
|
||||
ii) Unique Code: MoveTablePdf
|
||||
iii)Template: ...
|
||||
iv) Font: Zawgyi-One v) Printer: #printer name
|
||||
|
||||
/* Tax Profile Group Types in lookups */
|
||||
@@ -200,7 +200,7 @@ For MoveTablePdf in print settings
|
||||
1) settings/lookups => { type:ReceiptPdfView, name: Receipt Pdf View, value:1 or 0 }
|
||||
=> 1 is active and 0 is in-active
|
||||
|
||||
Add Kitchen Role of Employee
|
||||
Add Kitchen Role of Employee
|
||||
=> 1) settings/lookups => { type:employee_roles, name: Kitchen, value:kitchen }
|
||||
|
||||
Add Base URL for DOEMAL
|
||||
@@ -235,12 +235,12 @@ For Login expiry time
|
||||
|
||||
Menu Image (Import guideline)
|
||||
|
||||
=> First, check shop_code, is there in shops table and prefix shop_code in image name?
|
||||
=> First, check shop_code, is there in shops table and prefix shop_code in image name?
|
||||
=> You all must do this step
|
||||
* If there is shop_code in shops table (mark in one place/ note and set NULL for this record for a while) and prefix shop_code for image name (like (121_ABC.png)), and copy and paste images into Application/[sxrestaurant]/public/image/menu_images.
|
||||
* If there is shop_code/ no shop_code in shops table but no prefix in image name (* skip set NULL step) , copy and paste images into Application/…./image/menu_images.
|
||||
=> Second, import [menu].xlsx file in /settings/menus and then checked image is uploaded into Application/[sxrestaurant]/public/image/menu_images and insert into menu_items table in database.
|
||||
=> Last, if shop has shop_code, update marked/noted shop_code into shops table again.
|
||||
=> Last, if shop has shop_code, update marked/noted shop_code into shops table again.
|
||||
|
||||
For Edit Order Open & Close
|
||||
1) settings/lookups => {type:edit_order, name:EditOrderOrigami, value: {1 or 0}}
|
||||
@@ -273,13 +273,16 @@ For Online Order Receipt Setting
|
||||
1) settings/lookups => { type:order_reservation, name:ReceiptBill, value: {0 or 1} }
|
||||
2) settings/print_settings => {name: ReceiptBillOrder, unique_code: ReceiptBillOrderPdf, ....}
|
||||
|
||||
For Close Cashier Print Settings
|
||||
settings/lookups => {type:close_cashier_print, name:CloseCashierPrint, value: {0 or 1} }
|
||||
|
||||
* ToDo list
|
||||
|
||||
1. Migration
|
||||
2. Quick Service
|
||||
3. Order & Reservation
|
||||
|
||||
|
||||
|
||||
* System Dependencies
|
||||
|
||||
* Configuration
|
||||
@@ -299,7 +302,7 @@ For Online Order Receipt Setting
|
||||
|
||||
1. OQS
|
||||
|
||||
1. Filter
|
||||
1. Filter
|
||||
2. Order Item to each Stations
|
||||
3. Edit Order Item
|
||||
|
||||
@@ -313,12 +316,12 @@ For Online Order Receipt Setting
|
||||
|
||||
3. CRM
|
||||
|
||||
1. Customer Management
|
||||
1. Customer Management
|
||||
|
||||
2. Queue Management
|
||||
|
||||
|
||||
4. Backend
|
||||
|
||||
|
||||
1. Dining Setup
|
||||
|
||||
2. Queue Station Setup
|
||||
@@ -355,19 +358,17 @@ For Online Order Receipt Setting
|
||||
1. 2-Column => Main Content - col-9, Information - col-3
|
||||
2. 3-Column => Sub Lint - col-2, Main Content - col-7, Information - col-3
|
||||
|
||||
> Pixel
|
||||
> Pixel
|
||||
|
||||
Main Header Bar - height => 50 px
|
||||
Side Navigation - Weight => 230 px
|
||||
Main Content Padding => 15 px
|
||||
|
||||
2. Color
|
||||
|
||||
|
||||
> BUTTON
|
||||
|
||||
1. Submit/Add/Edit/Confirm buttons => btn-primary (theme color)
|
||||
2. Show/Detail Buttons => btn-info
|
||||
3. Delete => btn-delete
|
||||
4. Cancel/Back => btn-default
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
cashier_terminal = CashierTerminal.find(cashier_terminal_param)
|
||||
if cashier_terminal.is_currently_login
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_order_queue_stations_url, notice: 'Cashier Terminal already signin!' }
|
||||
format.html { redirect_to settings_order_queue_stations_url, notice: 'Cashier Terminal already signin!' }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,17 +38,19 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
@shift_sale.create(opening_balance,cashier_terminal_param, current_user)
|
||||
end
|
||||
|
||||
|
||||
|
||||
def update_shift
|
||||
closing_balance = params[:closing_balance]
|
||||
shift_id = params[:shift_id]
|
||||
@shift = ShiftSale.find_by_id(shift_id)
|
||||
if @shift
|
||||
@shift.shift_closed_at = DateTime.now.utc
|
||||
@shift.closing_balance = closing_balance.to_f
|
||||
@shift.closing_balance = closing_balance.to_f
|
||||
@shift.save
|
||||
|
||||
# Multiple Cashier
|
||||
cashier_terminal = @shift.cashier_terminal
|
||||
cashier_terminal = @shift.cashier_terminal
|
||||
cashier_terminal.is_currently_login = 0
|
||||
cashier_terminal.save
|
||||
|
||||
@@ -56,7 +58,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
bank_integration = Lookup.find_by_lookup_type('bank_integration')
|
||||
if !bank_integration.nil?
|
||||
card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL'])
|
||||
|
||||
|
||||
card_settle_trans.each do |data|
|
||||
card_sett_trans = CardSettleTran.find(data.id)
|
||||
card_sett_trans.shift_sale_id = @shift.id
|
||||
@@ -66,12 +68,17 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
|
||||
|
||||
|
||||
# if !close_cashier_print[0].nil?
|
||||
# @close_cashier_print = close_cashier_print[0][1]
|
||||
# end
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
close_cashier_pdf.each do |close_cashier|
|
||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||
if close_cashier[1] == '1'
|
||||
unique_code="CloseCashierCustomisePdf"
|
||||
else
|
||||
@@ -101,12 +108,21 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
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,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
|
||||
# print close cashier setting
|
||||
close_cashier_print = Lookup.collection_of('close_cashier_print')
|
||||
if close_cashier_print.empty?
|
||||
@settings_lookup = Lookup.new(lookup_type: "close_cashier_print", name: "CloseCashierPrint", value: "1")
|
||||
@settings_lookup.save
|
||||
end
|
||||
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
|
||||
if find_close_cashier_print[0][1].to_i > 0
|
||||
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,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
end
|
||||
end
|
||||
end
|
||||
Employee.logout(session[:session_token])
|
||||
session[:session_token] = nil
|
||||
session[:session_token] = nil
|
||||
end
|
||||
|
||||
def edit
|
||||
@@ -128,7 +144,7 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Reports::ShiftsaleController < BaseReportController
|
||||
authorize_resource :class => false
|
||||
|
||||
|
||||
def index
|
||||
|
||||
from, to = get_date_range_from_params
|
||||
@@ -8,7 +8,7 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
if params[:shift_name].to_i != 0
|
||||
@shift = ShiftSale.find(params[:shift_name])
|
||||
end
|
||||
@sale_data = Sale.get_by_shiftsales(from,to,@shift)
|
||||
@sale_data = Sale.get_by_shiftsales(from,to,@shift)
|
||||
@from = from
|
||||
@to = to
|
||||
if @shift.present?
|
||||
@@ -24,7 +24,7 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@@ -42,11 +42,69 @@ class Reports::ShiftsaleController < BaseReportController
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
def print_close_receipt
|
||||
shift_id = params[:id]
|
||||
@shift = ShiftSale.find_by_id(shift_id)
|
||||
shift_obj = ShiftSale.where('id =?',shift_id)
|
||||
puts "shift obj!!!!!"
|
||||
puts shift_obj.to_json
|
||||
|
||||
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
|
||||
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings")
|
||||
puts "close !!!!"
|
||||
puts close_cashier_pdf
|
||||
|
||||
unique_code = "CloseCashierPdf"
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
close_cashier_pdf.each do |close_cashier|
|
||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||
if close_cashier[1] == '1'
|
||||
unique_code="CloseCashierCustomisePdf"
|
||||
else
|
||||
unique_code="CloseCashierPdf"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
shop_details = shop_detail
|
||||
cashier_terminal = @shift.cashier_terminal
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
@total_waste = Sale.get_total_waste(shift_id).sum(:grand_total)
|
||||
@total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total)
|
||||
#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)
|
||||
@total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount
|
||||
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
|
||||
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
|
||||
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
|
||||
|
||||
# get printer info
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
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,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'}
|
||||
format
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
pdf = CashierStationOpening.new
|
||||
pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf"
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print("tmp/cashier_station_#{order_id}_closing_#{time}.pdf")
|
||||
end
|
||||
end
|
||||
@@ -33,11 +33,11 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
# shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
|
||||
|
||||
# pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges)
|
||||
# filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||
# filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||
# pdf.render_file filename
|
||||
# self.print(filename, cashier_terminal.printer_name)
|
||||
# end
|
||||
|
||||
|
||||
def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
|
||||
#Use CUPS service
|
||||
@@ -48,7 +48,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
|
||||
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
|
||||
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
|
||||
|
||||
|
||||
if !close_cashier_pdf.empty?
|
||||
close_cashier_pdf.each do |close_cashier|
|
||||
if close_cashier[0] == 'CloseCashierCustomisePdf'
|
||||
@@ -63,7 +63,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
|
||||
pdf.render_file filename
|
||||
|
||||
#no print in cloud server
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
if ENV["SERVER_MODE"] != "cloud"
|
||||
self.print(filename, cashier_terminal.printer_name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,7 +49,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
# dining charges
|
||||
charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take
|
||||
if !charges.nil?
|
||||
if !charges.nil?
|
||||
block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at)
|
||||
if charges.charge_type =='hr'
|
||||
dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s
|
||||
@@ -84,7 +84,7 @@ class Sale < ApplicationRecord
|
||||
# current cashier login
|
||||
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
|
||||
current_shift = ShiftSale.current_shift
|
||||
# shift with terminal zone
|
||||
# shift with terminal zone
|
||||
|
||||
# set cashier
|
||||
if order_source.downcase == "emenu"
|
||||
@@ -112,7 +112,7 @@ class Sale < ApplicationRecord
|
||||
self.cashier_name = cashier.name
|
||||
self.shift_sale_id = shift.id
|
||||
else
|
||||
if open_cashier.count>0 # if we have two open cashier
|
||||
if open_cashier.count>0 # if we have two open cashier
|
||||
# table and terminal in multiple shift
|
||||
self.cashier_id = open_cashier[0].id
|
||||
self.cashier_name = open_cashier[0].name
|
||||
@@ -171,9 +171,9 @@ class Sale < ApplicationRecord
|
||||
else
|
||||
booking.checkout_at = Time.now.utc.getlocal
|
||||
end
|
||||
|
||||
|
||||
booking.checkout_by = requested_by.name
|
||||
booking.save
|
||||
booking.save
|
||||
|
||||
# InventoryJob.perform_now(self.id)
|
||||
saleObj = Sale.find(self.id)
|
||||
@@ -195,7 +195,7 @@ class Sale < ApplicationRecord
|
||||
order_id = order.order_id # order_id
|
||||
bk_order = BookingOrder.find_by_order_id(order_id)
|
||||
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
|
||||
|
||||
|
||||
if check_booking.sale_id.nil?
|
||||
# Create Sale if it doesn't exist
|
||||
# puts "current_login_employee"
|
||||
@@ -234,7 +234,7 @@ class Sale < ApplicationRecord
|
||||
if !item.set_menu_items.nil?
|
||||
add_sub_item(item.set_menu_items)
|
||||
end
|
||||
|
||||
|
||||
#this will result in multiple orders belonging in multiple invoices - because of spilt invoices.
|
||||
link_order_sale(item.order_id, taxable)
|
||||
end
|
||||
@@ -253,7 +253,7 @@ class Sale < ApplicationRecord
|
||||
|
||||
#save sale_audit
|
||||
sale_item = SaleItem.new
|
||||
|
||||
|
||||
#pull
|
||||
if !menu_category.nil?
|
||||
sale_item.menu_category_code = menu_category.code
|
||||
@@ -326,7 +326,7 @@ class Sale < ApplicationRecord
|
||||
sale_item.price = diningprice
|
||||
sale_item.save
|
||||
|
||||
# Re-calc
|
||||
# Re-calc
|
||||
sale = Sale.find(self.id)
|
||||
self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source)
|
||||
end
|
||||
@@ -481,7 +481,7 @@ class Sale < ApplicationRecord
|
||||
if order_source.to_s == "emenu"
|
||||
order_source = "cashier"
|
||||
end
|
||||
|
||||
|
||||
if sale.payment_status != 'foc'
|
||||
tax_profiles.each do |tax|
|
||||
if tax.group_type.to_s == order_source.to_s
|
||||
@@ -548,7 +548,7 @@ class Sale < ApplicationRecord
|
||||
# Tax Calculate
|
||||
def apply_tax(total_taxable, order_source = nil, tax_type = nil)
|
||||
shop = Shop.first
|
||||
|
||||
|
||||
#if tax is not apply create new record
|
||||
# SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
|
||||
# #delete existing and create new
|
||||
@@ -669,7 +669,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
|
||||
def adjust_rounding
|
||||
shop_details = Shop.first
|
||||
shop_details = Shop.first
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = self.grand_total % 25 # Modulus
|
||||
@@ -685,11 +685,11 @@ class Sale < ApplicationRecord
|
||||
else
|
||||
self.rounding_adjustment = 0.00
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def compute_adjust_rounding(grand_total)
|
||||
shop_details = Shop.first
|
||||
shop_details = Shop.first
|
||||
# rounding adjustment
|
||||
if shop_details.is_rounding_adj
|
||||
a = grand_total % 25 # Modulus
|
||||
@@ -786,7 +786,7 @@ class Sale < ApplicationRecord
|
||||
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
|
||||
.joins(" JOIN orders ON orders.order_id=booking_orders.order_id")
|
||||
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and (CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount)
|
||||
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}", from,to)
|
||||
FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}", from,to)
|
||||
else
|
||||
sale = Sale.select("sales.*,#{order_source_query} as source").joins(" JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||
.joins(" JOIN bookings ON bookings.sale_id=sales.sale_id")
|
||||
@@ -922,7 +922,7 @@ def self.get_by_range_by_saleitems(from,to,status,report_type)
|
||||
.group('i.product_code')
|
||||
.order("sale_items.menu_category_code")
|
||||
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
|
||||
query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id
|
||||
JOIN employees ea ON ea.id = sales.cashier_id")
|
||||
|
||||
|
||||
@@ -944,13 +944,14 @@ def self.get_by_shiftsales(from,to,shift)
|
||||
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
|
||||
.where("sales.shift_sale_id=? and sp.payment_method='foc'",shift_sale.id)
|
||||
.first()
|
||||
|
||||
|
||||
if !foc_data.foc_sales.nil? && foc_data.foc_sales > 0
|
||||
shift_sale.other_sales -= foc_data.foc_sales
|
||||
foc = foc_data.foc_sales
|
||||
end
|
||||
|
||||
shift_sale_data[shift_sale.id] = {
|
||||
:shift_id => shift_sale.id,
|
||||
:cashier_terminal_name => shift_sale.cashier_terminal.name,
|
||||
:employee_name => shift_sale.employee.name,
|
||||
:shift_started_at => shift_sale.shift_started_at,
|
||||
@@ -1037,7 +1038,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
end
|
||||
|
||||
query = self.get_item_query(type)
|
||||
|
||||
|
||||
discount_query = 0
|
||||
total_card_amount = 0
|
||||
total_cash_amount = 0
|
||||
@@ -1098,12 +1099,12 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
|
||||
|
||||
else
|
||||
query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to)
|
||||
|
||||
|
||||
if type.nil? || type == 'all' || type == "other"
|
||||
other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
end
|
||||
product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to)
|
||||
|
||||
|
||||
discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount)
|
||||
change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed)
|
||||
sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount,
|
||||
@@ -1138,17 +1139,17 @@ end
|
||||
|
||||
#product sale report query
|
||||
def self.get_menu_item_query(order_by)
|
||||
query = MenuItem.unscoped.select("acc.id as account_id,
|
||||
acc.title as account_name,
|
||||
query = MenuItem.unscoped.select("acc.id as account_id,
|
||||
acc.title as account_name,
|
||||
mii.item_instance_code as item_code, " +
|
||||
"(CASE WHEN si.qty IS NOT NULL THEN SUM(si.qty) ELSE 0 END) as total_item," +
|
||||
"(CASE WHEN si.unit_price != mii.price THEN si.unit_price ELSE mii.price END) as unit_price," +
|
||||
"(CASE WHEN si.qty IS NOT NULL THEN (SUM(si.qty) * si.unit_price) ELSE 0 END) as grand_total," +
|
||||
"mii.price as unit_price, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END) as product_name,
|
||||
"mii.price as unit_price, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END) as product_name,
|
||||
mc.name as" +
|
||||
" menu_category_name,mc.id as menu_category_id, si.status as status_type,
|
||||
" menu_category_name,mc.id as menu_category_id, si.status as status_type,
|
||||
si.price as price ")
|
||||
.joins(" LEFT JOIN menu_item_instances mii ON menu_items.id = mii.menu_item_id" +
|
||||
.joins(" LEFT JOIN menu_item_instances mii ON menu_items.id = mii.menu_item_id" +
|
||||
" LEFT JOIN menu_categories mc ON mc.id = menu_items.menu_category_id" +
|
||||
" LEFT JOIN accounts acc ON acc.id = menu_items.account_id" +
|
||||
" LEFT JOIN sale_items si ON si.item_instance_code = mii.item_instance_code" +
|
||||
@@ -1194,7 +1195,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
|
||||
query = Sale.select("sales.*,bookings.dining_facility_id as table_id")
|
||||
.where("sale_status= 'completed' and sale_payments.payment_amount != 0 #{payment_type}")
|
||||
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
|
||||
.joins("join bookings on bookings.sale_id = sales.sale_id")
|
||||
.joins("join bookings on bookings.sale_id = sales.sale_id")
|
||||
.group("sales.sale_id")
|
||||
if shift.present?
|
||||
query = query.where("sales.shift_sale_id in (?)", shift.to_a)
|
||||
@@ -1207,13 +1208,13 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
|
||||
end
|
||||
|
||||
def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source)
|
||||
sub_query = "SELECT (CASE WHEN SUM(payment_amount) > 0
|
||||
sub_query = "SELECT (CASE WHEN SUM(payment_amount) > 0
|
||||
THEN DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') ELSE '-' END)
|
||||
FROM `sale_payments`
|
||||
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
||||
WHERE sale_audits.sale_id = s.sale_id"
|
||||
|
||||
sub_query1 = "SELECT (CASE WHEN SUM(payment_amount) > 0 THEN SUM(payment_amount) -
|
||||
sub_query1 = "SELECT (CASE WHEN SUM(payment_amount) > 0 THEN SUM(payment_amount) -
|
||||
(SUM(payment_amount) - (SELECT SUM(payment_amount) FROM sale_payments WHERE payment_method='creditnote' AND sale_id=s.sale_id)) ELSE 0 END)
|
||||
FROM `sale_payments`
|
||||
INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
||||
@@ -1244,7 +1245,7 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,
|
||||
WHERE sale_audits.sale_id = s.sale_id) = 0"
|
||||
end
|
||||
order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=s.sale_id GROUP BY so.sale_id)"
|
||||
|
||||
|
||||
if order_source.blank?
|
||||
source = ""
|
||||
else
|
||||
@@ -1336,7 +1337,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id
|
||||
INNER JOIN sales ON sa.sale_id = sales.sale_id
|
||||
WHERE sales.sale_status='completed' "
|
||||
|
||||
|
||||
if shift.present?
|
||||
shift_ids = shift.map(&:id).join(",")
|
||||
sub_query += " AND sales.shift_sale_id in (#{shift_ids})"
|
||||
@@ -1380,7 +1381,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
(CASE WHEN (SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end)) > 0 THEN (SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) - (#{sub_query})) ELSE 0 END) as credit_amount,
|
||||
SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount,
|
||||
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
|
||||
.joins("join sales on sales.sale_id = sale_payments.sale_id")
|
||||
.joins("join sales on sales.sale_id = sale_payments.sale_id")
|
||||
|
||||
if shift.present?
|
||||
|
||||
@@ -1388,7 +1389,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
# .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
|
||||
if payment_type.blank?
|
||||
sale_type = sale_payment.where(" s.sale_status = 'completed' and payment_amount != 0 and s.shift_sale_id in (?)",shift.to_a)
|
||||
.order("payment_method")
|
||||
.order("payment_method")
|
||||
else
|
||||
sale_type = sale_payment.where(" payment_method= '#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift.to_a)
|
||||
end
|
||||
@@ -1399,20 +1400,20 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type
|
||||
# .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
|
||||
if payment_type.blank?
|
||||
sale_type = sale_payment.where(" s.sale_status = 'completed' and payment_amount != 0 and s.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||
.order("payment_method")
|
||||
.order("payment_method")
|
||||
else
|
||||
sale_type = sale_payment.where(" payment_method='#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift_sale_range.to_a)
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
|
||||
all_total = payments_total.where("sales.receipt_date between ? and ? and sales.sale_status= 'completed' and sale_payments.payment_amount != 0", from,to)
|
||||
# .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')")
|
||||
if payment_type.blank?
|
||||
sale_type = sale_payment.where(" s.sale_status = 'completed' and payment_amount != 0 and s.receipt_date between ? and ? ",from,to)
|
||||
.order("payment_method")
|
||||
.order("payment_method")
|
||||
else
|
||||
sale_type = sale_payment.where(" payment_method='#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to)
|
||||
sale_type = sale_payment.where(" payment_method='#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1585,12 +1586,12 @@ end
|
||||
|
||||
def self.employee_sales(today,current_user,from,to,from_time,to_time)
|
||||
#sub query for credit payment
|
||||
outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END
|
||||
outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END
|
||||
FROM sale_payments
|
||||
JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
||||
JOIN sales ON sale_payments.sale_id = sales.sale_id
|
||||
WHERE sale_payments.outstanding_amount LIKE '%-%' AND sales.sale_status='completed'"
|
||||
|
||||
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
outstanding_query += " AND DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'"
|
||||
@@ -1756,12 +1757,12 @@ end
|
||||
end
|
||||
|
||||
def self.credit_payment(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)
|
||||
outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END
|
||||
outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END
|
||||
FROM sale_payments
|
||||
JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
||||
JOIN sales ON sale_payments.sale_id = sales.sale_id
|
||||
WHERE sale_payments.outstanding_amount LIKE '%-%' AND sales.sale_status='completed'"
|
||||
|
||||
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
outstanding_query += " AND DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'"
|
||||
@@ -1963,12 +1964,12 @@ end
|
||||
time_query = " and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'"
|
||||
end
|
||||
|
||||
outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END
|
||||
outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END
|
||||
FROM sale_payments
|
||||
JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id
|
||||
JOIN sales ON sale_payments.sale_id = sales.sale_id
|
||||
WHERE sale_payments.outstanding_amount LIKE '%-%' AND sales.sale_status='completed'"
|
||||
|
||||
|
||||
if (!from.nil? && !to.nil?) && (from != "" && to!="")
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
outstanding_query += " AND DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'"
|
||||
@@ -2153,7 +2154,7 @@ end
|
||||
if !shift.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id).first()
|
||||
else
|
||||
else
|
||||
query = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and sales.shift_sale_id=?',from,to,shift.id).first()
|
||||
end
|
||||
end
|
||||
@@ -2369,14 +2370,14 @@ end
|
||||
if current_user.nil?
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where("DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time)
|
||||
else
|
||||
else
|
||||
query = query.where("DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to)
|
||||
end
|
||||
else
|
||||
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
|
||||
if !from_time.nil? && !to_time.nil?
|
||||
query = query.where("DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time)
|
||||
else
|
||||
else
|
||||
query = query.where("DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to)
|
||||
end
|
||||
else
|
||||
@@ -2459,12 +2460,12 @@ end
|
||||
query = Sale.select("cst.res_date,cst.res_time,cst.trace,cst.pan,cst.batch_no,cst.exp_date,cst.app,cst.res_type,cst.ref_no,cst.terminal_id,cst.merchant_id,cst.app_code")
|
||||
.joins("JOIN card_sale_trans as cst on cst.sale_id = sales.sale_id")
|
||||
.where("sales.sale_id=? and status = 'Approved'",sale_id)
|
||||
|
||||
|
||||
return query
|
||||
end
|
||||
|
||||
def self.add_to_existing_pending_invoice(dining,sale_id,booking)
|
||||
|
||||
|
||||
existing_booking = Booking.find_by_sale_id(sale_id)
|
||||
if dining.to_i > 0
|
||||
table = DiningFacility.find(dining)
|
||||
@@ -2474,7 +2475,7 @@ end
|
||||
# end
|
||||
if booking.sale_id.nil?
|
||||
booking.booking_orders.each do |booking_order|
|
||||
|
||||
|
||||
booking.booking_status = 'moved'
|
||||
order = Order.find(booking_order.order_id)
|
||||
order.status = 'billed'
|
||||
@@ -2493,7 +2494,7 @@ end
|
||||
order.save
|
||||
booking.save
|
||||
end
|
||||
|
||||
|
||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||
booking_order.each do |bo|
|
||||
bo.booking_id = existing_booking.booking_id
|
||||
@@ -2504,7 +2505,7 @@ end
|
||||
else
|
||||
if booking.sale_id.nil?
|
||||
booking.booking_orders.each do |booking_order|
|
||||
|
||||
|
||||
booking.booking_status = 'moved'
|
||||
order = Order.find(booking_order.order_id)
|
||||
order.status = 'billed'
|
||||
@@ -2523,7 +2524,7 @@ end
|
||||
order.save
|
||||
booking.save
|
||||
end
|
||||
|
||||
|
||||
booking_order = BookingOrder.where('booking_id=?',booking)
|
||||
booking_order.each do |bo|
|
||||
bo.booking_id = existing_booking.booking_id
|
||||
@@ -2568,17 +2569,17 @@ end
|
||||
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='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_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_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(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,
|
||||
@@ -2588,7 +2589,7 @@ end
|
||||
.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("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-11-16 13:59:59 +0630')
|
||||
.group("sales.sale_id")
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<!-- <div class="row"> -->
|
||||
<div class="text-right">
|
||||
<a href="javascript:export_to('<%=reports_shiftsale_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- </div> -->
|
||||
<!-- </div> -->
|
||||
|
||||
@@ -33,33 +33,34 @@
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
|
||||
<th colspan="7"> <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %>
|
||||
- <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
|
||||
|
||||
</th>
|
||||
</tr>
|
||||
<% if @shift_from %>
|
||||
<tr>
|
||||
<% if @shift_data.employee %>
|
||||
<% if @shift_data.employee %>
|
||||
<% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<th colspan="7"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.cashier_station") %></th>
|
||||
<th><%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
||||
<th><%= t("views.right_panel.detail.shift_name") %></th>
|
||||
<th><%= t("views.right_panel.detail.shift_name") %></th>
|
||||
<!-- <th>Void Amount</th> -->
|
||||
<th><%= t("views.right_panel.detail.cash_payment") %></th>
|
||||
<!-- <th>Credit Charges</th> -->
|
||||
<th><%= t("views.right_panel.detail.credit_payment") %></th>
|
||||
<th><%= t("views.btn.other_payment") %></th>
|
||||
<th><%= t("views.btn.foc") %> <%= t :payment %></th>
|
||||
<!-- <th>Grand Total
|
||||
<br/>Rounding Adj</th> -->
|
||||
<!-- <th>Grand Total
|
||||
<br/>Rounding Adj</th> -->
|
||||
<!-- <th>Rounding Adj</th> -->
|
||||
<th><%= t("views.right_panel.detail.grand_total") %></th>
|
||||
<th><%= t("views.right_panel.detail.grand_total") %></th>
|
||||
<th>Print</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -74,27 +75,27 @@
|
||||
else
|
||||
delimiter = ""
|
||||
end
|
||||
%>
|
||||
<% void = 0%>
|
||||
<% cash = 0%>
|
||||
<% credit = 0%>
|
||||
<% accept_credit = 0%>
|
||||
<% foc = 0%>
|
||||
%>
|
||||
<% void = 0%>
|
||||
<% cash = 0%>
|
||||
<% credit = 0%>
|
||||
<% accept_credit = 0%>
|
||||
<% foc = 0%>
|
||||
<% card = 0%>
|
||||
<% total = 0%>
|
||||
<% rounding_adj = 0%>
|
||||
<% total = 0%>
|
||||
<% rounding_adj = 0%>
|
||||
<% g_total = 0 %>
|
||||
|
||||
<% @sale_data.each do |result|%>
|
||||
|
||||
|
||||
<tr>
|
||||
<td>
|
||||
<%= result[:cashier_terminal_name] rescue '-'%>
|
||||
<%= result[:cashier_terminal_name] rescue '-'%> <%= result[:shift_id].to_i %>
|
||||
</td>
|
||||
<td>
|
||||
<%= result[:employee_name] rescue '-'%>
|
||||
</td>
|
||||
<td><%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> -
|
||||
<td><%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> -
|
||||
<%= result[:shift_closed_at] ? result[:shift_closed_at].strftime("%e %b %I:%M%p") : '-' %>
|
||||
</td>
|
||||
<!-- <td style='color:red;'>(<%= sprintf "%.2f",result.void_amount.to_f.to_d rescue '-'%>)</td> -->
|
||||
@@ -102,23 +103,25 @@
|
||||
<td><%= number_with_precision(result[:credit_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<!-- <td><%= sprintf "%.2f",result.accept_credit_amount.to_f.to_d rescue '-'%></td> -->
|
||||
<!-- <td><%= sprintf "%.2f",result.foc_amount.to_f.to_d rescue '-'%></td>
|
||||
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
|
||||
<td><%= number_with_precision(result[:other_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%></td> -->
|
||||
<td><%= number_with_precision(result[:other_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td>
|
||||
<%= number_with_precision(result[:foc_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
|
||||
</td>
|
||||
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
|
||||
</td>
|
||||
<td><%= number_with_precision(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%></td>
|
||||
<td>
|
||||
<%= link_to "Print", reports_get_shift_id_path(result[:shift_id].to_i), class:"btn btn-info wave-effects" %>
|
||||
</td>
|
||||
<!-- <td><%= sprintf "%.2f",result[:rounding_adj].to_f.to_d rescue '-'%></td> -->
|
||||
<% grand_total = result[:grand_total].to_f %>
|
||||
<!-- <td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td> -->
|
||||
<% grand_total = result[:grand_total].to_f %>
|
||||
<!-- <td><%= sprintf "%.2f",grand_tota.to_f.to_d rescue '-'%></td> -->
|
||||
</tr>
|
||||
<% cash += result[:cash_sales].to_f %>
|
||||
<% credit += result[:credit_sales].to_f %>
|
||||
<% card += result[:other_sales].to_f %>
|
||||
<% foc += result[:foc_sales].to_f %>
|
||||
<% card += result[:other_sales].to_f %>
|
||||
<% foc += result[:foc_sales].to_f %>
|
||||
|
||||
<% total += result[:grand_total].to_f %>
|
||||
<% total += result[:grand_total].to_f %>
|
||||
<% g_total += grand_total.to_f %>
|
||||
|
||||
<% end %>
|
||||
@@ -133,8 +136,8 @@
|
||||
<td><b><%= number_with_precision(card, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<td><b><%= number_with_precision(foc, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<!-- <td><b><%= sprintf("%.2f",total) rescue '-'%></b></td> -->
|
||||
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
|
||||
<td><b><%= number_with_precision(g_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
<!-- <td><b><%= sprintf("%.2f",rounding_adj) rescue '-'%></b></td> -->
|
||||
<td><b><%= number_with_precision(g_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%></b></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -142,25 +145,32 @@
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
$(document).ready(function(){
|
||||
$('#close_cashier').on('click',function(){
|
||||
window.location.href = '/origami/shift/close';
|
||||
})
|
||||
})
|
||||
|
||||
$(function(){
|
||||
|
||||
var check_arr = [];
|
||||
search_by_period();
|
||||
$('#sel_period').change(function(){
|
||||
|
||||
|
||||
search_by_period();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
function search_by_period(){
|
||||
var period = $('#sel_period').val();
|
||||
var period_type = 0;
|
||||
var from = "";
|
||||
var to = "";
|
||||
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
|
||||
// OK button is clicked
|
||||
$('#from').bootstrapMaterialDatePicker().on('beforeChange', function(e, date){
|
||||
new_date = new Date(date) ;
|
||||
@@ -175,32 +185,32 @@
|
||||
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
|
||||
$('#to').val(to)
|
||||
search_by_date();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function search_by_date(){
|
||||
|
||||
from = $("#from").val();
|
||||
to = $("#to").val();
|
||||
to = $("#to").val();
|
||||
|
||||
var period = 0;
|
||||
var period_type = 1;
|
||||
var period_type = 1;
|
||||
|
||||
if(to != '' && from != ''){
|
||||
shift_name = from + ',' + to;
|
||||
|
||||
check_arr.push(to);
|
||||
|
||||
|
||||
console.log(check_arr.length)
|
||||
if(check_arr.length == 1){
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
show_shift_name(period,period_type,from,to,'shift_item');
|
||||
}
|
||||
if(check_arr.length == 3){
|
||||
check_arr = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
function show_shift_name(period,period_type,from,to,shift_item){
|
||||
var shift = $('#shift_name');
|
||||
if (from == '' && to == '') {
|
||||
@@ -208,18 +218,18 @@
|
||||
to = $("#to").val();
|
||||
}
|
||||
shift.empty();
|
||||
|
||||
|
||||
var str = '';
|
||||
var param_shift = '';
|
||||
var param_shift = '';
|
||||
var param_shift = '<%= params[:shift_name] rescue '-'%>';
|
||||
|
||||
url = '<%= reports_get_shift_by_date_path %>';
|
||||
|
||||
|
||||
$.get(url, {period :period, period_type :period_type, from :from, to :to, report_type :shift_item} , function(data){
|
||||
|
||||
str = '<option value="0">--- All Shift ---</option>';
|
||||
$(data.message).each(function(index){
|
||||
|
||||
$(data.message).each(function(index){
|
||||
|
||||
var local_date = data.message[index].local_opening_date + ' - ' + data.message[index].local_closing_date;
|
||||
var sh_date = data.message[index].opening_date + ' - ' + data.message[index].closing_date;
|
||||
var shift_id = data.message[index].shift_id ;
|
||||
@@ -228,20 +238,18 @@
|
||||
selected = 'selected = "selected"';
|
||||
}
|
||||
else{
|
||||
selected = '';
|
||||
}
|
||||
selected = '';
|
||||
}
|
||||
}else{
|
||||
selected = '';
|
||||
}
|
||||
selected = '';
|
||||
}
|
||||
str += '<option value="'+ shift_id +'" '+ selected +'>' + local_date + '</option>';
|
||||
|
||||
|
||||
// console.log(sh_date)
|
||||
})
|
||||
})
|
||||
shift.append(str);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
# if ENV["SERVER_MODE"] != "cloud"
|
||||
mount ActionCable.server => "/cable"
|
||||
# end
|
||||
|
||||
|
||||
|
||||
#--------- SmartSales Activation ------------#
|
||||
get 'activate' => 'install#index'
|
||||
@@ -92,7 +92,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post "callback/:id" => "order_reservation#update_status"
|
||||
get "get_tax_profile" => "order_reservation#get_tax_profile"
|
||||
end
|
||||
|
||||
|
||||
post "sound_effect" => "sound_effect#sound_effect"
|
||||
|
||||
#API for cashier app
|
||||
@@ -105,16 +105,16 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
end
|
||||
|
||||
#--------- Cashier ------------#
|
||||
namespace :origami do
|
||||
namespace :origami do
|
||||
root "home#index"
|
||||
|
||||
post '/check_emp_access_code/:code' => 'home#check_emp_access_code', :defaults => { :format => 'json' }
|
||||
|
||||
get "dashboard" => "dashboard#index"
|
||||
get "get_all_menu" => "dashboard#get_all_menu"
|
||||
get "dashboard" => "dashboard#index"
|
||||
get "get_all_menu" => "dashboard#get_all_menu"
|
||||
|
||||
get "quick_service" => "quick_service#index"
|
||||
|
||||
|
||||
get ":type/pending_order" => "pending_order#index"
|
||||
get ":type/pending_order/:sale_id" => "pending_order#show"
|
||||
get ":type/completed_sale/:sale_id" => "pending_order#completed_sale"
|
||||
@@ -122,7 +122,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
get "quick_service/modify_order/:id/:sale_id" => "quick_service#modify_order"
|
||||
get "quick_service/modify_order/:sale_id" => "quick_service#modify_order"
|
||||
post 'quick_service/update_modify_order' => "quick_service#update_modify_order", :defaults => { :format => 'json' }
|
||||
|
||||
|
||||
get ":type/cash_ins" => "pending_order#cash_ins"
|
||||
get ":type/cash_outs" => "pending_order#cash_outs"
|
||||
|
||||
@@ -135,7 +135,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
|
||||
resources :cash_ins, only: [:new, :create]
|
||||
resources :cash_outs, only: [:new, :create]
|
||||
|
||||
|
||||
get "table/:dining_id" => "home#show" do #origami/:booking_id will show
|
||||
# resources :discounts, only: [:index,:new, :create ] #add discount type
|
||||
resources :customers #add customer type
|
||||
@@ -268,10 +268,10 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
|
||||
get '/:addorders/:id' => "addorders#detail"
|
||||
post '/:addorders/create' => "addorders#create",:as => "addorder_create", :defaults => { :format => 'json' }
|
||||
|
||||
|
||||
|
||||
get '/addorders/get_item_instance/:id' => "addorders#get_item_instance",:as => "get_item_instance", :defaults => { :format => 'json' }
|
||||
|
||||
|
||||
resources :commissions
|
||||
resources :commissioners
|
||||
|
||||
@@ -341,7 +341,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
get 'sale/:sale_id/:type/credit_payment/others_payment/Alipay' => "alipay#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/DINGA' => "dinga#index"
|
||||
# get 'sale/:sale_id/:type/credit_payment/others_payment/GiftVoucher' => "gift_voucher#index"
|
||||
|
||||
|
||||
#------------- Start Reservation -------------------#
|
||||
resources :reservation
|
||||
#------------- End Reservation -------------------#
|
||||
@@ -402,8 +402,8 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
collection do
|
||||
post :import
|
||||
end
|
||||
resources :menu_categories, only: [:new, :create, :edit, :delete]
|
||||
end
|
||||
resources :menu_categories, only: [:new, :create, :edit, :delete]
|
||||
end
|
||||
|
||||
get '/menus/:id/export' => 'menus#export'
|
||||
|
||||
@@ -524,6 +524,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date"
|
||||
get "order_reservation/get_shift_by_date", to: "order_reservation#show", as: "get_shift_by_order_reservation"
|
||||
get "induty/get_shift_by_date", to: "induty#show", as: "get_shift_by_induty"
|
||||
get "shiftsale_print/:id" , to: "shiftsale#print_close_receipt", as: "get_shift_id"
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user