This commit is contained in:
code2lab
2019-05-29 17:50:05 +06:30
38 changed files with 2824 additions and 440 deletions

View File

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

View File

@@ -119,9 +119,14 @@ i.logout_icon{
margin-right: 15px;
color:#fff !important;
# background-color: green !important;
}
}
.payment-btn-box {
width: 130px;
width: 130px;
height: 50px;
}
}
@media screen and (max-width: 785px) {
#setting{ display: none;}
.menu-up{ display: none;}
}

View File

@@ -22,7 +22,7 @@
display: block;
width: 100%;
text-align: center;
color: #000;
color: #000;
margin-top: -5px;
}
@@ -117,4 +117,10 @@
.box {
margin : 0 -60px 0 -60px;
}
}
@media screen and (max-width: 785px) {
.login_pwd{width: 90%;}
.login_ent{width: 10%;}
}

View File

@@ -47,8 +47,12 @@ class Api::OrdersController < Api::ApiController
# end
@shop = Shop.first
puts "Hello world"
puts @shop.to_json
return @shop.to_json
end
# Description
# This API allow new order creation
# Input Params

View File

@@ -122,6 +122,7 @@ class Crm::CustomersController < BaseCrmController
#get customer amount
@customer = Customer.find(params[:id])
@response = Customer.get_membership_transactions(@customer)
puts @response.to_json
Rails.logger.debug "get membership transactions response"
Rails.logger.debug @response.to_json

View File

@@ -35,13 +35,24 @@ class Origami::PaymentsController < BaseOrigamiController
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
# Print for First Bill to Customer
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
else
unique_code = "ReceiptBillPdf"
unique_code = unique_code#{}"ReceiptBillPdf"
end
end
end
@@ -169,13 +180,24 @@ class Origami::PaymentsController < BaseOrigamiController
# if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
else
unique_code = "ReceiptBillPdf"
# else
end
end
end
@@ -686,13 +708,23 @@ class Origami::PaymentsController < BaseOrigamiController
else
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
unique_code = "ReceiptBillPdf"
print_settings = PrintSetting.all
if !print_settings.nil?
print_settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
unique_code = "ReceiptBillPdf"
elsif setting.unique_code == 'ReceiptBillStarPdf'
unique_code = "ReceiptBillStarPdf"
end
end
end
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
unique_code = "ReceiptBillA5Pdf"
else
unique_code = "ReceiptBillPdf"
# else
# unique_code = "ReceiptBillPdf"
end
end
end

View File

@@ -11,6 +11,7 @@ class Origami::ShiftsController < BaseOrigamiController
if !bank_integration[0].nil?
@bank_integration = bank_integration[0][1]
end
end
def new
@@ -26,7 +27,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 +39,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 +59,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 +69,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
@@ -83,6 +91,11 @@ class Origami::ShiftsController < BaseOrigamiController
shop_details = shop_detail
#get tax
shift_obj = ShiftSale.where('id =?',@shift.id)
sale_items = ''
@lookup = Lookup.shift_sale_items_lookup_value
if @lookup.to_i == 1
@sale_items = Sale.get_shift_sale_items(@shift.id)
end
@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)
@@ -101,12 +114,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, @sale_items, 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 +150,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

View File

@@ -11,6 +11,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1
# GET /print_settings/1.json
def show
@lookup = Lookup.shift_sale_items_lookup_value
end
# GET /print_settings/new
@@ -21,6 +22,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1/edit
def edit
@lookup = Lookup.shift_sale_items_lookup_value
@server_mode = ENV["SERVER_MODE"]
end
@@ -45,6 +47,10 @@ class PrintSettingsController < ApplicationController
def update
respond_to do |format|
if @print_setting.update(print_setting_params)
if @print_setting.unique_code == 'CloseCashierPdf'
Lookup.save_shift_sale_items_settings(params[:shift_sale_items])
end
format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' }
format.json { render :show, status: :ok, location: @print_setting }
else

View File

@@ -31,10 +31,9 @@ class Reports::SaleitemController < BaseReportController
@sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil)
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
@sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1}
@@ -86,5 +85,77 @@ class Reports::SaleitemController < BaseReportController
format.json { render json: out }
end
end
def print_sale_items
type = params[:type]
account = params[:account]
from_date = to_date = '-'
if !params[:from].nil?
from_date = Date.parse(params[:from])
end
if !params[:to].nil?
to_date = Date.parse(params[:to])
end
shift = params[:shift_name]
shift_name = "All Shifts"
if shift.to_i > 0
shift_name = params[:shift_from].to_s+" - ".to_s+params[:shift_to].to_s
end
period_name = get_period_name(params[:period])
shop_details = shop_detail
# get printer info
print_settings = PrintSetting.find_by_unique_code('CloseCashierPdf') # SaleItemsPdf
printer = Printer::CashierStationPrinter.new(print_settings)
printer.print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, params[:sale_items], params[:menu_cate_count])
respond_to do |format|
format.html { redirect_to '/en/reports/saleitem/', notice: 'Printing Completed.'}
format
end
end
def get_period_name(period)
period_name = '-'
unless period.nil? or period.blank?
case period.to_i
when PERIOD["today"]
period_name = "Today"
when PERIOD["yesterday"]
period_name = "Yesterday"
when PERIOD["this_week"]
period_name = "This Week"
when PERIOD["last_week"]
period_name = "Last Week"
when PERIOD["last_7"]
period_name = "Last 7 days"
when PERIOD["this_month"]
period_name = "This Month"
when PERIOD["last_month"]
period_name = "Last Month"
when PERIOD["last_30"]
period_name = "Last 30 Days"
when PERIOD["this_year"]
period_name = "This Year"
when PERIOD["last_year"]
period_name = "Last Year"
end
end
return period_name
end
end

View File

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

View File

@@ -25,4 +25,31 @@ class Lookup < ApplicationRecord
Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] }
end
def self.create_shift_sale_lookup
@lookup = Lookup.new
@lookup.lookup_type = 'shift_sale_items'
@lookup.name = 'Shift Sale Items'
@lookup.value = 0
@lookup.save
return @lookup
end
def self.save_shift_sale_items_settings(val)
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup
end
@lookup.value = val
@lookup.save
end
def self.shift_sale_items_lookup_value
@lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last
if @lookup.nil?
@lookup = Lookup.create_shift_sale_lookup
end
return @lookup.value
end
end

View File

@@ -256,6 +256,8 @@ class OrderQueueStation < ApplicationRecord
printer.each do |printer_setting|
if printer_setting.unique_code == 'OrderItemPdf'
unique_code="OrderItemPdf"
elsif printer_setting.unique_code == 'OrderItemStarPdf'
unique_code="OrderItemStarPdf"
elsif printer_setting.unique_code == 'OrderItemSlimPdf'
unique_code="OrderItemSlimPdf"
elsif printer_setting.unique_code == 'OrderSetItemPdf'

View File

@@ -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,12 +33,25 @@ 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)
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
if !sale_items.blank? or !sale_items.nil?
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1}
@menu_cate_count = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|cate| @menu_cate_count[cate.menu_category_id] += 1}
@totalByAccount = Hash.new {|hash, key| hash[key] = 0}
sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total}
end
#Use CUPS service
#Generate PDF
@@ -46,16 +59,16 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
cashier = shift_sale.employee.name
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")
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)
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, @account_cate_count, @menu_cate_count, @totalByAccount, 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'
if close_cashier[1] == '1'
pdf = CloseCashierCustomisePdf.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)
else
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)
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments)
end
end
end
@@ -63,9 +76,22 @@ 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
def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, menu_cate_count)
filename = "tmp/reports_sale_items.pdf"
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, menu_cate_count, nil)
pdf.render_file filename
#no print in cloud server
if ENV["SERVER_MODE"] != "cloud"
self.print(filename, print_settings.printer_name)
end
end
#sqa
end

View File

@@ -21,6 +21,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting.each do |print_settings|
if print_settings.unique_code == 'OrderItemPdf'
pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
elsif print_settings.unique_code == 'OrderItemStarPdf'
pdf = OrderItemStarPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
elsif print_settings.unique_code == 'OrderItemSlimPdf'
pdf = OrderItemSlimPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
elsif print_settings.unique_code == 'OrderSetItemPdf'
@@ -100,6 +102,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting.each do |print_settings|
if print_settings.unique_code == 'OrderItemPdf'
pdf = OrderItemPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderItemStarPdf'
pdf = OrderItemStarPdfnew(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty)
elsif print_settings.unique_code == 'OrderItemSlimPdf'
pdf = OrderItemSlimPdf.new(print_settings,odi_item[0], print_status, options, oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderSetItemPdf'
@@ -207,6 +211,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker
print_setting.each do |print_settings|
if print_settings.unique_code == 'OrderItemPdf'
pdf = OrderItemPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderItemStarPdf'
pdf = OrderItemStarPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderItemSlimPdf'
pdf = OrderItemSlimPdf.new(print_settings,odi, print_status, options,oqs.use_alternate_name,before_updated_qty)
elsif print_settings.unique_code == 'OrderSetItemPdf'

View File

@@ -195,14 +195,25 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
if !printer_settings.nil?
if !printer_settings.unique_code.strip.downcase.include? ("receiptbillorder")
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
settings = PrintSetting.all
if !settings.nil?
settings.each do |setting|
if setting.unique_code == 'ReceiptBillPdf'
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
elsif setting.unique_code == 'ReceiptBillStarPdf'
pdf = ReceiptBillStarPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
end
end
end
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
else
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
# else
# pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,other_amount,latest_order_no,card_balance_amount)
end
end
end

View File

@@ -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")
@@ -879,6 +879,7 @@ def self.daily_sales_list(from,to)
total_sale.each do |sale|
grand_total = sale.grand_total
amount_received = sale.amount_received
old_grand_total = sale.old_grand_total
total_discount = sale.total_discount
void_amount = sale.void_amount
@@ -922,7 +923,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 +945,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 +1039,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 +1100,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,
@@ -1125,6 +1127,15 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou
return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount
end
def self.get_shift_sale_items(sh_id)
query = Sale.select("sales.shift_sale_id as shift_sale_id, i.account_id as account_id, acc.title as account_name, i.item_instance_code as item_code, i.menu_category_name, i.menu_category_code as menu_category_id, i.product_name as product_name, i.unit_price, i.price as price, i.qty as qty, SUM(i.qty) as total_item, SUM(i.qty * i.unit_price) as grand_total, i.status as status_type, i.remark as remark")
.joins("JOIN sale_items i on i.sale_id = sales.sale_id")
.joins("JOIN accounts acc on acc.id = i.account_id")
.where("sales.shift_sale_id=?", sh_id)
.group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price")
.order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.unit_price asc")
end
def self.get_product_sale()
query = Sale.select("i.account_id as account_id, " +
"SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," +
@@ -1138,17 +1149,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 +1205,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 +1218,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 +1255,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 +1347,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 +1391,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 +1399,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 +1410,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 +1596,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 +1767,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 +1974,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 +2164,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 +2380,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 +2470,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 +2485,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 +2504,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 +2515,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 +2534,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 +2579,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 +2599,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")

View File

@@ -2,7 +2,7 @@ class CloseCashierPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shift_sale,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)
def initialize(printer_settings, shift_sale, sale_items, acc_cate_count, menu_cate_count, total_by_acc, 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)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
@@ -55,6 +55,10 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
if !sale_items.nil? or !sale_items.blank?
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
end
end
def header (shop_details)
@@ -175,7 +179,7 @@ class CloseCashierPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
end
#start other payment details
if shift_sale.other_sales > 0
other_payment.each do |other|
@@ -395,9 +399,9 @@ class CloseCashierPdf < Prawn::Document
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
else
@overall = shift_sale.total_discounts
@overall = shift_sale.total_discounts
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Discount :", :size => self.item_font_size, :align => :right
@@ -497,6 +501,109 @@ class CloseCashierPdf < Prawn::Document
move_down 5
stroke_horizontal_rule
move_down 5
end
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
self.item_width = 73
self.price_width = 60
item_label_qty_front_width = (self.item_width+self.price_width) + 2
item_label_qty_end_width = 32
item_label_total_front_width = (self.item_width+self.price_width) + 2
item_label_total_end_width = 64
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "Sale Items Summary", :size => self.header_font_size, :align => :center
end
total_items = 0
total_amount = 0
total_qty = 0
sub_total = 0
arr = Array.new
unless sale_items.nil?
sale_items.each do |item|
if !arr.include?(item['menu_category_id'])
unless total_qty == 0 and sub_total == 0
total_details('Sub Total', total_qty, sub_total)
end
total_qty = 0
sub_total = 0
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
end
# write_stroke_dash
# dash(1, :space => 1, :phase => 1)
# stroke_horizontal_rule
# move_down 2
y_position = cursor
pad_top(15) {
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 2
stroke_horizontal_rule
end
move_down 3
y_position = cursor
pad_top(15) {
bounding_box([0,y_position], :width =>self.item_width) do
text "#{item['product_name']}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix
end
text_box "#{item['unit_price'].to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{item['total_item'].to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
if item['total_item'].to_i > 0
total_qty += item['total_item'].to_i
total_items += item['total_item'].to_i
end
sub_total += item['grand_total'].to_i
total_amount += item['grand_total'].to_i
arr.push(item['menu_category_id'])
end
# stroke_horizontal_rule
total_details('Sub Total', total_qty, sub_total)
move_down 5
total_details('Total Amount', total_items, total_amount)
move_down 10
end
end
def total_details(col_name, total_qty, sub_total)
self.item_width = 73
self.price_width = 60
item_label_qty_front_width = (self.item_width+self.price_width) + 2
item_label_qty_end_width = 32
item_label_total_front_width = (self.item_width+self.price_width) + 2
item_label_total_end_width = 64
move_down 5
stroke_horizontal_rule
y_position = cursor
pad_top(15) {
text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "#{total_qty.to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{sub_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
end
end

View File

@@ -0,0 +1,505 @@
class CloseCashierPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shift_sale, total_by_acc, 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)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
self.item_font_size = printer_settings.item_font_size.to_i
self.margin = 5
self.price_width = 60
self.qty_width = 20
self.total_width = 40
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.label_width = 100
self.text_width = (self.page_width - 80) - self.price_width / 3
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
# @double = @qty_width * 1.3
# @half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
#check delimiter
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header( shop_details)
stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
end
def header (shop_details)
move_down 7
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down 5
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down 5
stroke_horizontal_rule
end
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Cashier : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.employee.name}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Cashier Station : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.cashier_terminal.name}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Opening Date : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.shift_started_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Closing Date : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ shift_sale.shift_closed_at.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Opening Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ number_with_precision(shift_sale.opening_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Closing Float : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :left
# text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}"
end
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "Shift Sale Summary", :size => self.header_font_size, :align => :center
end
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Received Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash In:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash Out:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
move_down -5
stroke_horizontal_rule
move_down 7
@total_foc = 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.cash_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Credit Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right
end
#start other payment details
if shift_sale.other_sales > 0
other_payment.each do |other|
@total_foc = other.foc_amount.round(2)
if other.mpu_amount && other.mpu_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "MPU Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.visa_amount && other.visa_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "VISA Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.master_amount && other.master_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Master Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.jcb_amount && other.jcb_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "JCB Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.unionpay_amount && other.unionpay_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.alipay_amount && other.alipay_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Alipay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.junctionpay_amount && other.junctionpay_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.dinga_amount && other.dinga_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Dinga Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.paypar_amount && other.paypar_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Redeem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.paymal_amount && other.paymal_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Paymal Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.giftvoucher_amount && other.giftvoucher_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
end
else
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Other Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.other_sales, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Rounding Adjustments :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.total_rounding, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.grand_total, :precision => precision.to_i, :delimiter => delimiter)}", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
# end other payment details
move_down -5
stroke_horizontal_rule
move_down 7
#start service charges and commercial tax
sale_taxes.each do |tax|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "#{tax.tax_name} :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(tax.st_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Taxes :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(shift_sale.total_taxes, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Net Sales :", :style => :bold, :size => self.header_font_size - 1, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(shift_sale.nett_sales, :precision => precision.to_i, :delimiter => delimiter) }", :style => :bold , :size => self.header_font_size - 1, :align => :right
end
if total_credit_payments && total_credit_payments.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Credit Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(total_credit_payments, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
#end for service charges and commercial tax
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Total Sale :", :size => self.item_font_size, :align => :right
# end
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{shift_sale.total_revenue}", :size => self.item_font_size, :align => :right
# end
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
total_discount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Discount:", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
#end total amount by Account
if total_member_discount[0].member_discount.present?
@member_discount = total_member_discount[0].member_discount rescue 0.0
@overall = shift_sale.total_discounts - @member_discount
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Member Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
else
@overall = shift_sale.total_discounts
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Discount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_with_precision(@overall, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total FOC :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{ number_with_precision(@total_foc, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Void :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{shift_sale.total_void})", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Waste :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{ number_with_precision(total_waste, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Spoile :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "(#{ number_with_precision(total_spoile, :precision => precision.to_i, :delimiter => delimiter)})", :size => self.item_font_size, :align => :right
end
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Grand Total :", :size => self.item_font_size, :align => :right
# end
# bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
# text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right
# end
move_down -5
stroke_horizontal_rule
move_down 7
#start total amount by Account Like Food / Beverage /..
total_amount_by_account.each do |amount|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total #{amount.account_name} Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_with_precision(amount.total_price, :precision => precision.to_i, :delimiter => delimiter)} ", :size => self.item_font_size, :align => :right
end
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Other Amount :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{total_other_charges}", :size => self.item_font_size, :align => :right
end
#end total amount by Account
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Dine-in Count :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.dining_count}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Takeaway Count :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.takeaway_count}", :size => self.item_font_size, :align => :right
end
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Total Receipts :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{shift_sale.total_receipt}", :size => self.item_font_size, :align => :right
end
move_down 5
stroke_horizontal_rule
move_down 5
move_down 5
end
end

View File

@@ -0,0 +1,117 @@
class MoveTableStarPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(printer_settings,to,from,shop_detail,date,type,moved_by,order_items)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
self.item_font_size = printer_settings.item_font_size.to_i
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 40
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
header(printer_settings.name,type)
call_move_table(to,from,date,type,moved_by)
move_down 5
stroke_horizontal_rule
move_down 5
add_lining_item(order_items, printer_settings.precision)
move_down 5
stroke_horizontal_rule
move_down 5
end
def header (name,type)
text "Move #{type}", :left_margin => -10, :size => self.header_font_size.to_i + 3,:align => :center
# move_down self.item_height
move_down 5
stroke_horizontal_rule
move_down 5
end
def call_move_table (to,from,date,type,moved_by)
move_down 3
text "Date Time : #{date.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :left_margin => -10, :size => self.header_font_size
text "Change [#{from}] To [#{to}]", :left_margin => -10, :size => self.header_font_size
text "Moved By : #{moved_by}", :left_margin => -10, :size => self.header_font_size
end
def add_lining_item(order_items, precision)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width) do
text "Item", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "Qty", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 5
add_item(order_items, precision)
end
# Add order items under order info
def add_item(order_items, precision)
y_position = cursor
move_down 5
order_items.each do|odi|
# check for item not to show
# if odi.price != 0
y_position = cursor
# bounding_box([0,y_position], :width => self.item_width + 60, :height => self.item_height) do
# text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
# end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "#{number_with_precision(odi.qty, :precision => precision.to_i)}", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{odi.item_code} - #{odi.item_name}", :size => self.item_font_size,:align => :left
end
if !(odi.alt_name).empty?
move_down 4
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
end
end
end

View File

@@ -0,0 +1,162 @@
class OrderItemStarPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty)
self.page_width = print_settings.page_width
self.page_height = print_settings.page_height
self.header_font_size = print_settings.header_font_size.to_i
self.item_font_size = print_settings.item_font_size.to_i
self.margin = 0
self.price_width = 40 # No Need for item
self.qty_width = 38
self.total_width = 40 # No Need for item
self.item_width = self.page_width - (self.qty_width - self.margin)
self.item_height = 15
self.item_description_width = self.page_width - (self.price_width + self.qty_width + self.total_width)
self.label_width=90
super(:margin => [print_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# super(:margin => [10, 5, 30, 5], :page_size => [200,400])
# db font setup
if print_settings.font != ""
font_families.update("#{print_settings.font}" => {
:normal => "public/fonts/#{print_settings.font}.ttf",
:italic => "public/fonts/#{print_settings.font}.ttf",
:bold => "public/fonts/#{print_settings.font}.ttf",
:bold_italic => "public/fonts/#{print_settings.font}.ttf"
})
font "#{print_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#font "public/fonts/Chinese.ttf"
if !order_item.dining.nil?
text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
else
text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20
end
stroke_horizontal_rule
move_down 3
#order_info
order_info(order_item.order_id, order_item.order_by,order_item.order_at)
# order items
order_items(order_item, options, alt_name, print_settings.precision, before_updated_qty)
end
# Write Order Information to PDF
def order_info(order_no, order_by, order_at)
#booking ID
booking_id = get_booking_id(order_no)
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Booking: #{booking_id}", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderNo: #{order_no}", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "OrderBy: #{order_by} ", :size => self.item_font_size,:align => :left
end
move_down 2
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "Date: #{order_at.utc.getlocal.strftime("%Y-%m-%d %I:%M %p")}", :size => self.item_font_size,:align => :left
end
stroke_horizontal_rule
move_down 10
end
# Write Order items to PDF
def order_items(order_item, options, alt_name, precision, before_updated_qty)
y_position = cursor
#Add Order Item
add_order_items(order_item, options, alt_name, precision)
dash(1, :space => 1, :phase => 1)
stroke_horizontal_line 0, (self.page_width - self.margin)
add_updated_qty_text(before_updated_qty, order_item.qty, precision)
move_down 5
end
# Add order items under order info
def add_order_items(order_item, options, alt_name, precision)
y_position = cursor
move_down 5
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_width,y_position], :width => self.qty_width) do
text "[#{number_with_precision(order_item.qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
bounding_box([0,y_position], :width => self.item_width) do
text "#{order_item.item_code} - #{order_item.item_name}", :size => self.item_font_size,:align => :left
end
if alt_name
if order_item.alt_name
move_down 4
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
end
if !options.empty?
move_down 5
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "#{options}", :size => self.item_font_size,:align => :left
end
end
move_down 5
end
#add updated qty text
def add_updated_qty_text(before_updated_qty, updated_qty, precision)
if before_updated_qty.to_i > 0 && !before_updated_qty.nil?
move_down 5
# add option
y_position = cursor
bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do
text "* Change quantity [#{number_with_precision(before_updated_qty.to_i, :precision => precision.to_i)}] to [#{number_with_precision(updated_qty.to_i, :precision => precision.to_i)}]", :size => self.item_font_size,:align => :left
end
end
end
def get_booking_id(order_no)
booking = Order.joins(" JOIN booking_orders bo ON bo.order_id = orders.order_id")
.joins(" JOIN bookings b ON b.booking_id=bo.booking_id")
.where("orders.order_id='#{order_no}'")
.first()
return booking.booking_id
end
end

View File

@@ -292,18 +292,18 @@ class ReceiptBillPdf < Prawn::Document
text "#{product_name}", :size => self.item_font_size,:align => :left
end
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
if show_alt_name
if !(item.product_alt_name).empty?
move_down 2
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{item.product_alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
if show_alt_name
if !(item.product_alt_name).empty?
move_down 2
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{item.product_alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
end
move_down line_move
}

View File

@@ -0,0 +1,756 @@
class ReceiptBillStarPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
self.item_font_size = printer_settings.item_font_size.to_i
self.margin = 0
self.price_width = 50
self.qty_width = 23
self.total_width = 50
self.item_width = self.page_width - ((self.qty_width + self.price_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.label_width = 90
self.description_width = 140
self.price_num_width = 40
self.line_move = 2
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
# @double = @qty_width * 1.3
# @half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header(shop_details)
stroke_horizontal_rule
cashier_info(sale_data, customer_name, latest_order_no)
line_items(sale_items,printer_settings.precision,delimiter)
all_total(sale_data,printer_settings.precision,delimiter)
if member_info != nil
member_info(member_info,customer_name,rebate_amount,sale_data,printer_settings.precision,delimiter,current_balance)
end
customer(customer_name)
#start card sale trans data
if card_data != nil
card_sale_data(card_data)
end
#end card sale trans data
#start card blanace amount
if !card_balance_amount.nil?
card_balance_data(card_balance_amount)
end
#end card blanace amount
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
if shop_details.show_account_info
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
if other_charges_amount
show_other_charges_amount(other_charges_amount,printer_settings.precision,delimiter)
end
end
#start for individual payment
if !sale_data.equal_persons.nil?
individual_payment(sale_data,sale_data.equal_persons, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
if shop_details.note && !shop_details.note.nil?
shop_note(shop_details)
end
footer(printed_status)
end
def header (shop_details)
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down line_move
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down line_move
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down line_move
stroke_horizontal_rule
end
def cashier_info(sale_data, customer_name, latest_order_no)
if latest_order_no.nil?
move_down line_move
text "Booking : #{ sale_data.bookings[0].booking_id }", :size => self.header_font_size+2,:align => :left
move_down line_move
end
move_down line_move
if !latest_order_no.nil?
move_down line_move
text "OrderNo : #{ latest_order_no }", :size => self.header_font_size,:align => :left
end
move_down line_move
# move_down 2
y_position = cursor
bounding_box([0,y_position], :width =>self.description_width + self.price_num_width, :height => self.item_height) do
text "Receipt No: #{sale_data.receipt_no}", :size => self.item_font_size,:align => :left
end
if sale_data.bookings[0].dining_facility_id.to_i > 0
bounding_box([self.description_width - 2,y_position], :width => self.price_num_width, :height => self.item_height) do
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :right
end
end
move_down line_move
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
end
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
text "C: #{sale_data.cashier_name}", :size => self.item_font_size,:align => :right
end
move_down line_move
y_position = cursor
if sale_data.bookings[0].dining_facility_id.to_i > 0
time = sale_data.receipt_date.strftime('%d-%m-%Y') +"("+ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') +"-"+ sale_data.bookings[0].checkout_at.utc.getlocal.strftime('%I:%M %p')+")"
else
time = sale_data.receipt_date.strftime('%d-%m-%Y %H:%M %p')
end
bounding_box([0,y_position], :width =>self.page_width - 10, :height => self.item_height) do
text "Date : #{ time }",:size => self.item_font_size,:align => :left
end
# bounding_box([self.item_description_width,y_position], :width =>self.label_width+5) do
# text "(#{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') }
# - #{ sale_data.bookings[0].checkin_at.utc.getlocal.strftime('%I:%M %p') })" ,
# :size => self.item_font_size,:align => :right
# end
move_down line_move
stroke_horizontal_rule
end
def line_items(sale_items,precision,delimiter)
if precision.to_i > 0
item_label_qty_front_width = (self.item_width+self.price_width) + 2
item_label_qty_end_width = self.qty_width + 1
item_label_total_front_width = (self.item_width+self.price_width) + 3
item_label_total_end_width = self.total_width + 3
else
# self.item_width = self.item_width.to_i + 3
item_label_qty_front_width = (self.item_width+self.price_width) + 3
item_label_qty_end_width = self.qty_width + 2
item_label_total_front_width = (self.item_width+self.price_width) + 2
item_label_total_end_width = self.total_width + 1
end
move_down line_move
y_position = cursor
move_down line_move
pad_top(15) {
# @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
# move_down line_move
stroke_horizontal_rule
add_line_item_row(sale_items,precision,delimiter)
end
def add_line_item_row(sale_items,precision,delimiter)
if precision.to_i > 0
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = (self.item_width+self.price_width) + 2
item_qty_end_width = self.qty_width + 1
item_total_front_width = item_name_width + 3
item_total_end_width = self.total_width + 3
else
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = item_name_width + 3
item_qty_end_width = self.qty_width + 2
item_total_front_width = item_name_width + 2
item_total_end_width = self.total_width + 1
end
y_position = cursor
move_down line_move
sub_total = 0.0
total_qty = 0.0
show_price = Lookup.find_by_lookup_type("show_price")
sale_items.each do |item|
# check for item not to show
if item.status != 'Discount' && item.qty > 0
if !show_price.nil? && show_price.value.to_i > 0 && item.price == 0
total_qty += item.qty
else
if item.price != 0
total_qty += item.qty
end
end
end
product_name = item.product_name
# if item.status = 'promotion' && (item.remark =='promotion nett price' || item.remark == 'promotion discount')
# sub_total += -item.price #(item.qty*item.unit_price) - comment for room charges
# qty = -item.qty
# total_price = -item.price #item.qty*item.unit_price - comment for room charges
# price = -item.unit_price
# else
sub_total += item.price #(item.qty*item.unit_price) - comment for room charges
qty = item.qty
total_price = item.price #item.qty*item.unit_price - comment for room charges
price = item.unit_price
# end
if !show_price.nil? && show_price.value.to_i>0
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
else
if item.price != 0
item_row(item,precision,delimiter,product_name,price,qty ,total_price)
end
end
end
stroke_horizontal_rule
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_width + self.price_width, :height => self.item_height) do
text "Sub Total", :size => self.item_font_size,:align => :left
end
text_box "#{number_with_precision(total_qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(sub_total, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
end
def item_row(item,precision,delimiter,product_name,price,qty ,total_price)
if precision.to_i > 0
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = (self.item_width+self.price_width) + 2
item_qty_end_width = self.qty_width + 1
item_total_front_width = item_name_width + 3
item_total_end_width = self.total_width + 3
else
item_name_width = (self.item_width+self.price_width)
item_qty_front_width = item_name_width + 3
item_qty_end_width = self.qty_width + 2
item_total_front_width = item_name_width + 2
item_total_end_width = self.total_width + 1
end
y_position = cursor
pad_top(15) {
bounding_box([0,y_position], :width =>self.item_width) do
text "#{product_name}", :size => self.item_font_size,:align => :left
end
# text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :size => self.item_font_size
text_box "#{number_with_precision(price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[self.item_width,y_position], :width => self.price_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{number_with_precision(qty, :precision => precision.to_i)}", :at =>[item_qty_front_width,y_position], :width => item_qty_end_width, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{number_with_precision(total_price, :precision => precision.to_i, :delimiter => delimiter)}", :at =>[item_total_front_width,y_position], :width =>item_total_end_width, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
if show_alt_name
if !(item.product_alt_name).empty?
move_down 2
# font("public/fonts/NotoSansCJKtc-Regular.ttf") do
text "(#{item.product_alt_name})", :size => self.item_font_size,:align => :left, :inline_format => true
# end
end
end
move_down line_move
}
end
def all_total(sale_data,precision,delimiter)
move_down line_move
item_name_width = self.item_width
y_position = cursor
if sale_data.discount_type == 'member_discount'
dis_type = "Member Discount:"
else
dis_type = "Overall Discount:"
end
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ dis_type }", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "( #{number_with_precision(sale_data.total_discount, :precision => precision.to_i, :delimiter => delimiter)} )" , :size => self.item_font_size,:align => :right
end
if sale_data.sale_taxes.length > 0
incl_tax = ""
if sale_data.tax_type == "inclusive"
incl_tax = "Incl."
end
sale_data.sale_taxes.each do |st|
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ st.tax_name } (#{incl_tax} #{ st.tax_rate.to_i }%)", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(st.tax_payable_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
else
end
# move_down 5
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
# text "Total Tax", :size => self.item_font_size,:align => :left
# end
# bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
# text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right
# end
if sale_data.rounding_adjustment != 0.0
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Rounding Adjustment", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{sale_data.rounding_adjustment}", :size => self.item_font_size,:align => :right
end
end
move_down line_move
y_position = cursor
move_down line_move
bounding_box([0,y_position], :width =>self.item_description_width) do
text "Grand Total",:style => :bold, :size => self.header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(sale_data.grand_total, :precision => precision.to_i, :delimiter => delimiter)}" , :style => :bold, :size => self.header_font_size,:align => :right
end
move_down line_move
sale_payment(sale_data,precision,delimiter)
end
def sale_payment(sale_data,precision,delimiter)
stroke_horizontal_rule
#move_down line_move
sql = "SELECT SUM(payment_amount)
FROM sale_payments where payment_method='creditnote'
and sale_id='#{sale_data.sale_id}'"
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
FROM sale_payments where payment_method='creditnote'
and sale_id='#{sale_data.sale_id}'"
sale_payments = SalePayment.select("SUM(sale_payments.payment_amount) as payment_amount,sale_payments.payment_method")
.where("(CASE WHEN ((#{sql}) - (#{sql1})
ELSE SUM(payment_amount) END
FROM sale_payments
JOIN sales s ON s.sale_id=sale_payments.sale_id
JOIN sale_audits sa
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
where sa.sale_id='#{sale_data.sale_id}')) = 0
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id)
.group("payment_method")
sale_payments.each do |payment|
y_position = cursor
if payment.payment_method == "paypar"
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Redeem Payment", :size => self.item_font_size,:align => :left
end
else
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left
end
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
if sale_data.amount_received > 0
y_position = cursor
move_down line_move
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Change Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
# move_down line_move
end
end
# show member information
def member_info(member_info,customer_name,rebate_amount,sale_data,precision,delimiter,current_balance)
if rebate_amount != nil
if rebate_amount["status"] == true
stroke_horizontal_rule
total = 0
balance = 0
rebate_balance =0
redeem = 0
redeem_count = 0
rebate_amount["data"].each do |res|
total = total + res["balance"]
#total redeem amount
if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem"
redeem = redeem + res["withdraw"]
balance = balance + res["balance"]
end
#end Total redem
#total Rebate Earn
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate"
rebate_balance = rebate_balance + res["deposit"]
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Rebate Earn", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
# Total Rebate Amount if birthday
if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebatebonusAccount" && res["status"]== "Rebate"
rebate_balance = rebate_balance + res["deposit"]
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(res["deposit"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
#end Total rebate if birthday
end
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Redeem Amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
if current_balance != nil
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Old Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(current_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
end
end
if member_info["status"] == true && member_info["data"].present?
total_balance = 0
member_info["data"].each do |res|
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
total_balance = total_balance + res["balance"]
end
end
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Total Balance", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{number_with_precision(total_balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
end
end
def customer(customer_name)
# move_down line_move
y_position = cursor
#move_down line_move
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "Customer Name", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ customer_name }" , :size => self.item_font_size,:align => :right
end
move_down line_move
stroke_horizontal_rule
end
def discount_account(discount_price_by_accounts,precision,delimiter)
stroke_horizontal_rule
move_down line_move
y_position = cursor
discount_price_by_accounts.each do |ipa|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ 'Total ' + ipa[:name] + ' Discounts' }", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "(" + "#{ number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter) }" + ")" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
end
def items_account(item_price_by_accounts,precision,delimiter)
stroke_horizontal_rule
move_down line_move
y_position = cursor
item_price_by_accounts.each do |ipa|
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width) do
text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
text "#{number_with_precision(ipa[:price], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
end
def show_other_charges_amount(other_amount,precision,delimiter)
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width) do
text "Other Charges", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
text "#{number_with_precision(other_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right
end
move_down line_move
end
#individual payment per person
def individual_payment(sale_data, survey, precision, delimiter)
# per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
per_person = sale_data.grand_total.to_f / survey.to_i
stroke_horizontal_rule
move_down line_move
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width+50) do
text "Split Bill for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left
end
bounding_box([0,y_position], :width =>self.label_width) do
move_down 15
text "Amount Due (per person)", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 15
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right
end
end
def sign(sale_data)
sql = "SELECT SUM(payment_amount)
FROM sale_payments where payment_method='creditnote'
and sale_id='#{sale_data.sale_id}'"
sql1 = "SELECT CASE WHEN s.amount_changed > 0 and (s.amount_received - s.amount_changed) = s.grand_total THEN ( SELECT SUM(payment_amount)
FROM sale_payments where payment_method='creditnote'
and sale_id='#{sale_data.sale_id}'"
SalePayment.where("(CASE WHEN ((#{sql}) - (#{sql1})
ELSE SUM(payment_amount) END
FROM sale_payments
JOIN sales s ON s.sale_id=sale_payments.sale_id
JOIN sale_audits sa
ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payment_id
where sa.sale_id='#{sale_data.sale_id}')) = 0
THEN payment_method!='creditnote' ELSE 1 END) AND sale_id = ?", sale_data.sale_id).each do |payment|
if payment.payment_method == "creditnote"
y_position = cursor
stroke_horizontal_rule
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 70
stroke_horizontal_rule
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
text "Approved By" , :size => self.item_font_size,:align => :center
end
break;
end
end
if sale_data.payment_status == "foc" || sale_data.payment_status == "waste" || sale_data.payment_status == "spoile"
y_position = cursor
stroke_horizontal_rule
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 70
stroke_horizontal_rule
end
if sale_data.payment_status == "foc"
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
text "Acknowledged By" , :size => self.item_font_size,:align => :center
end
elsif sale_data.payment_status == "waste" || sale_data.payment_status == "spoile"
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
move_down 73
text "Approved By" , :size => self.item_font_size,:align => :center
end
end
end
end
def shop_note(shop)
move_down line_move
stroke_horizontal_rule
move_down line_move
move_down line_move
y_position = cursor
text "#{shop.note}", :size => self.item_font_size, :align => :left
move_down line_move
end
def footer(printed_status)
move_down line_move
stroke_horizontal_rule
move_down line_move
move_down line_move
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width) do
text "#{printed_status}",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.item_description_width+20, :height => self.item_height) do
text "Thank You! See you Again", :left_margin => -5, :size => self.item_font_size,:align => :left
end
move_down line_move
end
#start card sale trans data
def card_sale_data(card_data)
if card_data != nil && !card_data.empty?
move_down line_move
stroke_horizontal_rule
move_down line_move
y_position = cursor
card_data.each do |data|
if data['app'] == 'CUP'
data['app'] = 'UNIONPAY'
elsif data['app'] == 'MASTERCARD'
data['app'] = 'MASTER'
end
text "DATE/TIME: #{data['res_date']} #{data['res_time']} ", :size => @item_font_size, :align => :left
text "BATCH NUM: #{data['batch_no']} TRACE#: #{data['trace']}",:size => @item_font_size, :align => :left
text "RREF NUM: #{data['ref_no']} APPR CODE: #{data['app_code']} ",:size => @item_font_size, :align => :left
text "TID: #{data['tid']} ",:size => @item_font_size, :align => :left
text "#{data['app']} #{data['pan']} ",:size => @item_font_size, :align => :left
end
end
end
#start card balance data
def card_balance_data(card_balance_amount)
if card_balance_amount > 0
move_down line_move
stroke_horizontal_rule
move_down line_move
y_position = cursor
bounding_box([0, y_position], :width =>self.label_width) do
text "Card Balance: ",:style => :bold, :size => header_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{card_balance_amount}" , :size => self.item_font_size,:align => :right
end
end
end
#check ReceiptBillAltName included
def show_alt_name
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
status = false
if !bill_alt_name.empty?
bill_alt_name.each do |alt_name|
if alt_name[0] == 'ReceiptBillAltName'
if alt_name[1] == '1'
status = true
else
status = false
end
end
end
end
return status
end
end

233
app/pdf/sale_items_pdf.rb Normal file
View File

@@ -0,0 +1,233 @@
class SaleItemsPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shop_details, period, type, account, from_date, to_date, shift, sale_items, acc_cate_count, menu_cate_count, total_by_acc)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
self.item_font_size = printer_settings.item_font_size.to_i
self.margin = 5
self.price_width = 60
self.qty_width = 20
self.total_width = 40
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
@label_name_width = 70
@label_item_width = self.page_width-@label_name_width
self.label_width = 100
self.text_width = (self.page_width - 80) - self.price_width / 3
# @item_width = self.page_width.to_i / 2
# @qty_width = @item_width.to_i / 3
# @double = @qty_width * 1.3
# @half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
# db font setup
if printer_settings.font != ""
font_families.update("#{printer_settings.font}" => {
:normal => "public/fonts/#{printer_settings.font}.ttf",
:italic => "public/fonts/#{printer_settings.font}.ttf",
:bold => "public/fonts/#{printer_settings.font}.ttf",
:bold_italic => "public/fonts/#{printer_settings.font}.ttf"
})
font "#{printer_settings.font}"
fallback_fonts ["Courier", "Helvetica", "Times-Roman"]
end
# font "public/fonts/Zawgyi-One.ttf"
# font "public/fonts/padauk.ttf"
#precision checked
if printer_settings.precision.to_i > 2
printer_settings.precision = 2
end
#check delimiter
if printer_settings.delimiter
delimiter = ","
else
delimiter = ""
end
header( shop_details)
stroke_horizontal_rule
sale_details(period, type, account, from_date, to_date, shift)
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
end
def header (shop_details)
move_down 7
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
# move_down self.item_height
move_down 5
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
move_down 5
stroke_horizontal_rule
end
def sale_details(period, type, account, from_date, to_date, shift)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "Period : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{period}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "Type : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{type}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "Account : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{account}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "From Date : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{ from_date}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "To Date : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{ to_date}" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>@label_name_width, :height => self.item_height) do
text "Shift : ", :size => self.item_font_size,:align => :left
end
bounding_box([@label_name_width,y_position], :width => @label_item_width, :height => self.item_height) do
text "#{shift}" , :size => self.item_font_size,:align => :left
end
move_down 10
end
def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc)
self.item_width = 73
self.price_width = 60
item_label_qty_front_width = (self.item_width+self.price_width) + 2
item_label_qty_end_width = 32
item_label_total_front_width = (self.item_width+self.price_width) + 2
item_label_total_end_width = 64
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "Sale Items Summary", :size => self.header_font_size, :align => :center
end
total_items = 0
total_amount = 0
total_qty = 0
sub_total = 0
arr = Array.new
unless sale_items.nil?
JSON.parse(sale_items).each do |item|
if !arr.include?(item['menu_category_id'])
unless total_qty == 0 and sub_total == 0
total_details('Sub Total', total_qty, sub_total)
end
total_qty = 0
sub_total = 0
move_down 10
y_position = cursor
bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do
text "#{item['menu_category_name']}", :size => self.header_font_size, :align => :left
end
# write_stroke_dash
# dash(1, :space => 1, :phase => 1)
# stroke_horizontal_rule
# move_down 2
y_position = cursor
pad_top(15) {
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :left, :overflow => :shrink_to_fix
text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
move_down 2
stroke_horizontal_rule
end
move_down 3
y_position = cursor
pad_top(15) {
bounding_box([0,y_position], :width =>self.item_width) do
text "#{item['product_name']}", :size => self.item_font_size, :align => :left#, :overflow => :shrink_to_fix
end
text_box "#{item['unit_price'].to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "#{item['total_item'].to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{item['grand_total'].to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
if item['total_item'].to_i > 0
total_qty += item['total_item'].to_i
total_items += item['total_item'].to_i
end
sub_total += item['grand_total'].to_i
total_amount += item['grand_total'].to_i
arr.push(item['menu_category_id'])
end
# stroke_horizontal_rule
total_details('Sub Total', total_qty, sub_total)
move_down 5
total_details('Total Amount', total_items, total_amount)
move_down 10
end
end
def total_details(col_name, total_qty, sub_total)
self.item_width = 73
self.price_width = 60
item_label_qty_front_width = (self.item_width+self.price_width) + 2
item_label_qty_end_width = 32
item_label_total_front_width = (self.item_width+self.price_width) + 2
item_label_total_end_width = 64
move_down 5
stroke_horizontal_rule
y_position = cursor
pad_top(15) {
text_box "#{col_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "#{total_qty.to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "#{sub_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
end
end

View File

@@ -179,11 +179,14 @@
<th><%= t("views.right_panel.detail.sales_status") %></th>
<th><%= t("views.right_panel.detail.receipt_date") %></th>
</tr>
</thead>
<tbody>
<% add_grand_total =0 %>
<% @sales.each do |sale| %>
<tr>
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
<td><%= sale.receipt_no %></td>
<td><%= sale.total_discount %></td>
@@ -194,7 +197,15 @@
<td> <%= sale.sale_status %> </td>
<td> <%= sale.receipt_date.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
</tr>
<% add_grand_total += sale.grand_total%>
<% end %>
<% if !@sales.empty?%>
<tr style="border-top:2px solid #666;">
<th colspan="5">Balance</th>
<th colspan="4"><%= add_grand_total %></th>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -2,12 +2,12 @@
<aside id="leftsidebar" class="sidebar">
<!-- User Info -->
<!-- <div class="user-info">
<div class="image">
<div class="image">
<img src="public/image/user.png" width="48" height="48" alt="User" />
</div>
<div class="info-container">
<div class="name" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
current_login_employee.name
current_login_employee.name
</div>
<div class="email">john.doe@example.com</div>
<div class="btn-group user-helper-dropdown">
@@ -21,7 +21,7 @@
<li role="seperator" class="divider"></li>
<li><a href="javascript:void(0);"><i class="material-icons">input</i>Sign Out</a></li>
</ul>
</div>
</div>
</div>
</div> -->
<!-- #User Info -->
@@ -42,7 +42,7 @@
</a>
</li>
<% if can? :menage, OrderQueueStation %>
<li>
<li class="menu-up">
<a href="<%= oqs_root_path %>">
<i class="material-icons">room_service</i>
<span><%= t :oqs %></span>
@@ -50,8 +50,8 @@
</li>
<% end %>
<% if can? :index, :home %>
<% if current_login_employee.role != "kitchen" %>
<li>
<% if current_login_employee.role != "kitchen" %>
<li class="menu-up">
<a href="<%= origami_dashboard_path %>">
<i class="material-icons">monetization_on</i>
<span><%= t :origami %></span>
@@ -60,27 +60,27 @@
<% end %>
<% end %>
<% if can? :menage, Customer %>
<li>
<li class="menu-up">
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">widgets</i>
<span><%= t :crm %></span>
</a>
<ul class="ml-menu">
<li>
<a href="<%= crm_customers_path %>"><%= t :customer %></a>
</li>
<% if can? :menage, DiningQueue %>
<li>
<a href="<%= crm_dining_queues_path %>"><%= t :queue %></a>
</li>
<% end %>
</li>
<% end %>
</ul>
</li>
<% end %>
<% end %>
<% if can? :menage, Inventory %>
<li>
<li class="menu-up">
<a href="<%= inventory_path %>">
<i class="material-icons">store</i>
<span><%= t :inventory %></span>
@@ -88,66 +88,9 @@
</li>
<%end%>
<li class="header"><%= t :backend %></li>
<li>
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">widgets</i>
<span><%= t :transactions %></span>
</a>
<ul class="ml-menu">
<% if can? :menage, Booking %>
<li>
<a href="<%= transactions_bookings_path %>"><%= t :bookings %></a>
</li>
<% end %>
<% if can? :menage, Order %>
<li>
<a href="<%= transactions_orders_path %>"><%= t :orders %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_sales_path %>"><%= t :sale %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_credit_notes_path %>"><%= (t :credit) %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_shift_sales_path %>"><%= (t :shiftsale) %></a>
</li>
<% end %>
<% if can? :menage, Survey %>
<li>
<a href="<%= transactions_surveys_path %>"><%= t("views.right_panel.detail.survey") %></a>
</li>
<% end %>
<% if can? :manage, OrderReservation %>
<% if order_reservation %>
<li>
<a href="<%= transactions_order_reservations_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
</li>
<% end %>
<% end %>
<% if can? :manage, Sale %>
<% if bank_integration %>
<li>
<a href="<%= transactions_card_sale_trans_path %>"><%= t :cb_payments %></a>
</li>
<% end %>
<% end %>
<% if can? :manage, Sale %>
<% if bank_integration %>
<li>
<a href="<%= transactions_card_settle_trans_path %>"><%= t :cb_settlement %></a>
</li>
<% end %>
<% end %>
</ul>
</li>
<% if can? :index, :dailysale %>
<% device = request.user_agent %>
<% if device.include? 'Mobile' %>
<% if can? :index, :dailysale %>
<li>
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">assessment</i>
@@ -207,8 +150,193 @@
</li>
<% end %>
</ul>
</li>
</li>
<%end%>
<li>
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">widgets</i>
<span><%= t :transactions %></span>
</a>
<ul class="ml-menu">
<% if can? :menage, Booking %>
<li>
<a href="<%= transactions_bookings_path %>"><%= t :bookings %></a>
</li>
<% end %>
<% if can? :menage, Order %>
<li>
<a href="<%= transactions_orders_path %>"><%= t :orders %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_sales_path %>"><%= t :sale %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_credit_notes_path %>"><%= (t :credit) %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_shift_sales_path %>"><%= (t :shiftsale) %></a>
</li>
<% end %>
<% if can? :menage, Survey %>
<li>
<a href="<%= transactions_surveys_path %>"><%= t("views.right_panel.detail.survey") %></a>
</li>
<% end %>
<% if can? :manage, OrderReservation %>
<% if order_reservation %>
<li>
<a href="<%= transactions_order_reservations_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
</li>
<% end %>
<% end %>
<% if can? :manage, Sale %>
<% if bank_integration %>
<li>
<a href="<%= transactions_card_sale_trans_path %>"><%= t :cb_payments %></a>
</li>
<% end %>
<% end %>
<% if can? :manage, Sale %>
<% if bank_integration %>
<li>
<a href="<%= transactions_card_settle_trans_path %>"><%= t :cb_settlement %></a>
</li>
<% end %>
<% end %>
</ul>
</li>
<%else%>
<li id="left-menu">
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">widgets</i>
<span><%= t :transactions %></span>
</a>
<ul class="ml-menu">
<% if can? :menage, Booking %>
<li>
<a href="<%= transactions_bookings_path %>"><%= t :bookings %></a>
</li>
<% end %>
<% if can? :menage, Order %>
<li>
<a href="<%= transactions_orders_path %>"><%= t :orders %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_sales_path %>"><%= t :sale %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_credit_notes_path %>"><%= (t :credit) %></a>
</li>
<% end %>
<% if can? :menage, Sale %>
<li>
<a href="<%= transactions_shift_sales_path %>"><%= (t :shiftsale) %></a>
</li>
<% end %>
<% if can? :menage, Survey %>
<li>
<a href="<%= transactions_surveys_path %>"><%= t("views.right_panel.detail.survey") %></a>
</li>
<% end %>
<% if can? :manage, OrderReservation %>
<% if order_reservation %>
<li>
<a href="<%= transactions_order_reservations_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
</li>
<% end %>
<% end %>
<% if can? :manage, Sale %>
<% if bank_integration %>
<li>
<a href="<%= transactions_card_sale_trans_path %>"><%= t :cb_payments %></a>
</li>
<% end %>
<% end %>
<% if can? :manage, Sale %>
<% if bank_integration %>
<li>
<a href="<%= transactions_card_settle_trans_path %>"><%= t :cb_settlement %></a>
</li>
<% end %>
<% end %>
</ul>
</li>
<% if can? :index, :dailysale %>
<li>
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">assessment</i>
<span><%= t :reports %></span>
</a>
<ul class="ml-menu">
<li>
<a href="<%= reports_dailysale_index_path %>">Daily Sales</a>
</li>
<li>
<a href="<%= reports_saleitem_index_path %>">Sale Items</a>
</li>
<li>
<a href="<%= reports_product_sale_index_path %>">Product Sale</a>
</li>
<% if order_reservation %>
<li>
<a href="<%= reports_order_reservation_index_path %>"><%= t("views.right_panel.detail.order_reservation") %></a>
</li>
<% end %>
<li>
<a href="<%= reports_receipt_no_index_path %>">Receipt</a>
</li>
<li>
<a href="<%= reports_receipt_no_detail_index_path %>">Receipt Detail</a>
</li>
<li>
<a href="<%= reports_shiftsale_index_path %>">Shift Sales</a>
</li>
<li>
<a href="<%= reports_credit_payment_index_path %>">Credit Sales</a>
</li>
<li>
<a href="<%= reports_void_sale_index_path %>">Void Sales</a>
</li>
<li>
<a href="<%= reports_waste_and_spoilage_index_path %>">Wastes & Spoilages</a>
</li>
<li>
<a href="<%= reports_payment_method_index_path %>">Payment Method</a>
</li>
<li>
<a href="<%= reports_commission_index_path %>">Commission</a>
</li>
<li>
<a href="<%= reports_induty_index_path %>">Induty</a>
</li>
<li>
<a href="<%= reports_stock_check_index_path %>">Stock Check</a>
</li>
<% if bank_integration %>
<li>
<a href="<%= reports_card_sale_tran_index_path %>">CB Payments</a>
</li>
<li>
<a href="<%= reports_card_settle_tran_index_path %>">CB Settlement</a>
</li>
<% end %>
</ul>
</li>
<% end %>
<% end %>
<div id="setting" >
<li class="header"><%= t :settings %></li>
<% if can? :menage, Zone %>
<li>
@@ -232,7 +360,7 @@
<i class="material-icons col-indigo">donut_large</i>
<span><%= t :oqs %></span>
</a>
</li>
</li>
<% end %>
<% if can? :menage, Employee %>
<li>
@@ -256,7 +384,7 @@
<i class="material-icons col-pupple">donut_large</i>
<span><%= t :printer %></span>
</a>
</li>
</li>
<% end %>
<% if can? :menage, TaxProfile %>
<li>
@@ -312,8 +440,11 @@
</a>
</li>
<% end %>
</div>
</ul>
</div>
<!-- #Menu -->
<!-- Footer -->
<div class="legal">
@@ -326,4 +457,4 @@
</div>
<!-- #Footer -->
</aside>
<!-- #END# Left Sidebar
<!-- #END# Left Sidebar

View File

@@ -35,7 +35,7 @@
<!-- <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script> -->
<%= javascript_include_tag 'login', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'login', 'data-turbolinks-track': 'reload' %>
</head>
<body class="login-page">
@@ -57,8 +57,8 @@
</div>
<!-- #END# Page Loader -->
<% flash.each do |type, message| %>
<%
if type == "notice"
<%
if type == "notice"
color = "alert-success"
elsif type == "error"
color = "alert-danger"
@@ -67,22 +67,22 @@
else
color = "bg-black"
end %>
<p id="noti" class="hidden noti" data-placement-from="top" data-message="<%=message%>" data-placement-align="center"
data-animate-enter="" data-animate-exit="" data-color-name="<%=color%>" >
</p>
<% end %>
<% end %>
<div class="login-box">
<div class="logo text-center">
<img src="/image/SX-logo.png" width="150px" height="150px">
<p>
<small>Version - 1.0.1</small>
</p>
</p>
</div>
<div class="row">
<div class="col-lg-12_ col-md-12 col-sm-12 col-xs-12 text-center">
<div class="current-shop-name">
<span><%= shop_detail.name %></span>
<span><%= shop_detail.name %></span>
</div>
</div>
</div>
@@ -90,13 +90,13 @@
<div class="card padding-10">
<div class="card-header m-l-">
<div class="row clearfix">
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10">
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-10 login_pwd">
<%= f.input :emp_id, as: :hidden, required: false, class: "form-control" %>
<%= f.input :password, label: "Access PIN", required: false, class: "form-control" %>
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-10">
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-10 login_ent">
<br>
<span class="input-group-addon enter m-t-25 m-l--25" data-value="ENT" style="cursor: pointer;padding:0.1rem !important;">
<i class="material-icons">send</i>
@@ -126,10 +126,18 @@
<!-- <div class="pin_pad bg-grey" data-value="CLR">CLR</div>
<div class="pin_pad left" data-value="0">0</div>
<div class="pin_pad left bg-indigo" data-value="ENT">ENT</div> -->
<% if request.user_agent.include? 'Mobile' %>
<div class="pin_pad bg-blue-grey" data-value="CLR">CLR</div>
<div class="pin_pad left" data-value="0">0</div>
<div class="pin_pad bg-grey left" data-value="ENT">ENTER</div>
<% else %>
<div class="pin_pad bg-blue-grey" data-value="BAC">BACK</div>
<div class="pin_pad left" data-value="0">0</div>
<div class="pin_pad bg-grey left" data-value="CLR">CLR</div>
</div>
<div class="pin_pad bg-blue-grey" data-value="CLR">CLR</div>
<% end %>
</div>
</div>
</div>
<% end %>
@@ -139,7 +147,7 @@
$("#login_form_password").focus();
$(".pin_pad").click(function (event) {
event.preventDefault();
event.preventDefault();
var value = $(this).data("value");
if (value == "CLR") {
@@ -154,12 +162,12 @@
}
});
$(".enter").click(function (event) {
event.preventDefault();
event.preventDefault();
var value = $(this).data("value");
if (value == "ENT") {
$("#new_login_form").submit();
}
}
});
});
function showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit) {
@@ -199,5 +207,3 @@
</script>
</body>
</html>

View File

@@ -26,7 +26,7 @@
<div class='col-md-6'>
<span style='font-size:20px;'><b><input type='number' class="form-control" id='closing_balance_amount' value='' onkeypress="return isNumberKey(event);" onkeyup="closeCashier(this.value);"></b></span>
</div>
</div>
</div><br>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<button type="button" class="btn bg-default btn-block" id='back'><i class="material-icons">reply</i> <%= t("views.btn.back") %> </button>
@@ -59,6 +59,13 @@
</div>
<script>
// $(document).ready(function(){
// var val = $('#sale_items').val()
// if (val == 1) {
// $('#sale_items').prop( "checked", true );
// }
// })
function closeCashier(val){
var aa = parseInt(val);
if(isNaN(aa)) $("#closing_balance_amount").val("");
@@ -81,9 +88,10 @@
$('#close_cashier').on('click',function(){
var amount = $('#closing_balance_amount').val();
var shift_id = "<%= @shift.id rescue ""%>"
$.ajax({type: "POST",
url: "<%= origami_close_shift_path %>",
data: "closing_balance="+ amount + "&shift_id="+ shift_id,
data: "closing_balance="+ amount + "&shift_id="+ shift_id ,
success:function(result){
console.log(result)
window.location.href = '/';

View File

@@ -27,6 +27,22 @@
<%= f.input :precision, input_html: { min: 0, max: 2, :onkeypress => "return isNumberKey(event);", :onkeyup => "greaterThanTwo(this.value);" } %>
<%= f.input :delimiter %>
<%= f.input :heading_space %>
<% if !@print_setting.new_record? and @print_setting.unique_code == 'CloseCashierPdf' %>
<div class="form-group boolean optional sale_items bmd-form-group is-filled">
<div class="checkbox">
<input value="0" type="hidden" name="shift_sale_items">
<label class="boolean optional" for="sale_items">
<input class="boolean optional" type="checkbox" value="<%= @lookup %>" name="shift_sale_items" id="sale_items" onchange="set_value(this)">
<span class="checkbox-decorator">
<span class="check"></span>
<div class="ripple-container"></div>
</span>Shift Sale Items
</label>
</div>
</div>
<% end %>
</div>
<div class="form-actions">
@@ -82,7 +98,11 @@
.attr("value",value.target)
.text(value.deviceName));
});
}
}
if ($('#sale_items').val() == '1') {
$('#sale_items').prop('checked', true);
}
// if selected printer change call and bind
$("#print_setting_printer_name").on("change", function(){
@@ -119,4 +139,12 @@
function greaterThanTwo(val){
if(parseInt(val)>2) $("#print_setting_precision").val(2);
}
function set_value(ele){
if ($(ele).val() == '1'){
$(ele).val(0)
}else{
$(ele).val(1)
}
}
</script>

View File

@@ -58,6 +58,16 @@
<th><%= t("views.right_panel.detail.print_copies") %></th>
<td><%= @print_setting.print_copies %></td>
</tr>
<tr>
<th>Include Shift Sale Items</th>
<td>
<% if @lookup == '1' %>
<%= 'True' %>
<% else %>
<%= 'False' %>
<% end %>
</td>
</tr>
<tr>
<td colspan="2" align="right">
<%= link_to t("views.btn.edit"), edit_print_setting_path(@print_setting),:class => 'btn btn-info btn-sm waves-effect' %>

View File

@@ -31,34 +31,34 @@
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
<% if @payment_methods.include? ("MPU") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.mpu_sales") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.mpu_sales") %></th>
<% end %>
<% if @payment_methods.include? ("Master") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.master_sales") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.master_sales") %></th>
<% end %>
<% if @payment_methods.include? ("VISA") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.visa_sales") %></th>
<th style='text-align:center;'class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.visa_sales") %></th>
<% end %>
<% if @payment_methods.include? ("JCB") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.jcb_sales") %></th>
<th style='text-align:center;'class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.jcb_sales") %></th>
<% end %>
<% if @payment_methods.include? ("UNIONPAY") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.unionpay_sales") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.unionpay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("Alipay") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.alipay_sales") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.alipay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("PAYMAL") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.paymal_sales") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.paymal_sales") %></th>
<% end %>
<% if @payment_methods.include? ("DINGA") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.dinga_sales") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.dinga_sales") %></th>
<% end %>
<% if @payment_methods.include? ("JunctionPay") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.junctionpay_sales") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.junctionpay_sales") %></th>
<% end %>
<% if @payment_methods.include? ("Redeem") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.redeem_sales") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.redeem_sales") %></th>
<% end %>
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>

View File

@@ -19,7 +19,7 @@
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.void_amount") %></th>
<% if @payment_methods.include? ("MPU") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.mpu_sales") %></th>
<th style='text-align:center;' class='mobile'><%= t("views.right_panel.detail.mpu_sales") %></th>
<% end %>
<% if @payment_methods.include? ("Master") %>
<th style='text-align:center;'><%= t("views.right_panel.detail.master_sales") %></th>

View File

@@ -19,10 +19,10 @@
</select>
</div>
<% if not defined? payments %>
<div class="col-lg-2 col-md-2 col-sm-2">
<label class="font-14"><%= t("views.right_panel.detail.select_payments") %></label>
<select name="payment_type" id="payment_type" class="form-control">
<% @payments.each do |pm| %>
<option class="<%=pm[1].downcase%>" value="<%=pm[1].downcase%>"><%=pm[0]%></option>
@@ -31,9 +31,9 @@
<option value="<%=pm.payment_method%>" class="<%=pm.payment_method%>" > <%=pm.payment_method%></option>
<%end %>
</select>
</div>
</div>
<% end %>
<div class="col-lg-2 col-md-2 col-sm-2">
<div class="col-lg-2 col-md-2 col-sm-2">
<!-- <label class="">Select Shift Period</label> -->
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
<input data-behaviour='datepicker' class="form-control datepicker m-t-3" name="from" id="from" type="text" placeholder="From date" style="height: 32px;">
@@ -47,36 +47,36 @@
<select class="form-control select" name="shift_name" id="shift_name" >
</select>
</div>
<div class="col-lg-12 col-md-12 col-sm-12 margin-top-20 text-right">
<br>
<div class="col-lg-2 col-md-2 col-sm-2 margin-top-20" style="margin-top: 20px;">
<input type="submit" value="Generate Report" class='btn btn-primary'>
</div>
</div>
</div>
</div>
<% end %>
<% end %>
</div>
<% end %>
</div>
<script type="text/javascript">
$(function(){
$('#custom_excel').hide();
$('#custom_excel').click(function(){
var url = $('#custom_excel').attr('data-url');
$('#frm_report').attr('action',url)
$('#frm_report').submit();
// window.location = url;
});
var item = $('#item').val();
var payment_type = $('#payment_type');
if(item == 'order'){
$('#cashier').hide();
$('#waiter').show();
if(payment_type){
$('#payment_type').hide();
}
}
}
else if(item == 'sale'){
$('#waiter').hide();
@@ -84,7 +84,7 @@
}
else{
$('#waiter').hide();
$('#cashier').show();
$('#cashier').show();
$("#item").val('sale');
}
});
@@ -101,7 +101,7 @@
$("#to").val("<%=params[:to] rescue '-'%>");
$("#sel_period").val(<%=params[:period] rescue '-'%>);
$("#sel_sale_type").val(<%=params[:sale_type] rescue '-'%>);
$(".<%=params[:payment_type]%>").attr('selected','selected')
// shift = $(".shift-id").text()
@@ -124,7 +124,7 @@
if(item == 'sale'){
$('#waiter').hide();
$('#cashier').show();
$('#cashier').show();
if(payment_type){
$('#payment_type').show();
}

View File

@@ -20,9 +20,9 @@
<!-- <div class="row"> -->
<div class="text-right">
<a href="javascript:export_to('<%=reports_receipt_no_index_path%>.xls')" class = "btn btn-info wave-effects"><%= t("views.btn.exp_to_excel") %></a>
</div>
</div>
<!-- </div> -->
<!-- </div> -->
<!-- </div> -->
<div class="margin-top-20">
<div class="card">
@@ -34,21 +34,21 @@
</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="9"><%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )</th>
</tr>
<% end %>
<% end %>
<tr>
<th><%= t("views.right_panel.detail.dining") %></th>
<th><%= t("views.right_panel.detail.receipt_no") %></th>
<th><%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
<th><%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
<th><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></th>
<th><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %> </th>
<% @tax_profiles.each do |tax| %>
<th><%= tax.name %></th>
<th><%= tax.name %></th>
<% end %>
<!-- <th>Other Amount</th> -->
<th><%= t("views.right_panel.detail.grand_total") %></th>
@@ -69,44 +69,44 @@
delimiter = ","
else
delimiter = ""
end %>
end %>
<% grand_total = 0 %>
<% old_grand_total = 0 %>
<% after_rounding = 0 %>
<% total_tax = 0 %>
<% guest_count = 0 %>
<% total_sum = 0 %>
<% discount_amt = 0 %>
<% total_sum = 0 %>
<% discount_amt = 0 %>
<% other_amt = 0 %>
<% total_nett = 0 %>
<% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
<% total_nett = 0 %>
<% rounding_adj = 0%> <% gov_tax = 0 %> <% service_charge = 0 %>
<% tax_profile_count = @tax_profiles.length %>
<%
<%
ttax_count = tax_profile_count - @sale_taxes.length
ttax_flag = true
@sale_taxes.each do |tax|
@sale_taxes.each do |tax|
if tax.tax_name.downcase.include?("service")
ttax_flag = false
end
end
end
%>
<%if !@sale_data.nil? %>
<%if !@sale_data.nil? %>
<% @sale_data.each do |result| %>
<% grand_total +=result.grand_total.to_f %>
<% old_grand_total += result.grand_total_after_rounding() %>
<% total_tax += result.total_tax.to_f %>
<% total_sum += result.total_amount.to_f %>
<% total_sum += result.total_amount.to_f %>
<% discount_amt += result.total_discount.to_f %>
<% rounding_adj += result.rounding_adjustment.to_f %>
<% sale_tax_count = result.sale_taxes.length %>
<% tax_count = tax_profile_count - sale_tax_count %>
<% tax_flag = true %>
<% result.sale_taxes.each do |tax|
<% result.sale_taxes.each do |tax|
if tax.tax_name.downcase.include?("service")
tax_flag = false
end
@@ -116,7 +116,7 @@
<td>
<%if result.type %>
<%= result.type %> - <%= result.name %>
<%= result.type %> - <%= result.name %>
<% else %>
-
<% end %>
@@ -130,13 +130,13 @@
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %></td>
<%end%> -->
<% if !result.sale_taxes.empty? %>
<% num = 1
<% num = 1
if tax_flag && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
<% num += 1
end %>
<% end %>
<% result.sale_taxes.each do |tax| %>
@@ -144,13 +144,13 @@
<%= number_with_precision(tax.tax_payable_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<%end%>
<% num = 1
<% num = 1
if tax_flag==false && tax_count > 0 %>
<% while num <= tax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
<% num += 1
end %>
<% end %>
<% else %>
@@ -158,17 +158,21 @@
<td><%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<% end %>
<%end%>
<td><%= number_with_precision(result.grand_total_after_rounding(), precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
<% if result.old_grand_total.nil? %>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%else%>
<td><%= number_with_precision(result.old_grand_total, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></td>
<%end%>
<td><%= result.rounding_adjustment.to_f rescue '-' %></td>
<td><%= number_with_precision(result.grand_total, precision: precision.to_i ,delimiter: delimiter) %></td>
</tr>
<% end %>
<tr style="border-top:4px double #666;">
<td colspan="3">&nbsp;</td>
<td><b><%= number_with_precision(total_sum, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(discount_amt, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<!-- <% if !@sale_taxes.empty?
<!-- <% if !@sale_taxes.empty?
@sale_taxes.each do |tax| %>
<td>
<b><%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b>
@@ -181,13 +185,13 @@
<% end %> -->
<% if !@sale_taxes.empty? %>
<% num = 1
<% num = 1
if ttax_flag && ttax_count > 0 %>
<% while num <= ttax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
<% num += 1
end %>
<% end %>
<% @sale_taxes.each do |tax| %>
@@ -195,13 +199,13 @@
<%= number_with_precision(tax.st_amount, precision: precision.to_i ,delimiter: delimiter) rescue '-' %>
</td>
<%end%>
<% num = 1
<% num = 1
if ttax_flag==false && ttax_count > 0 %>
<% while num <= ttax_count %>
<td>
<%= number_with_precision(0, precision: precision.to_i ,delimiter: delimiter) %>
</td>
<% num += 1
<% num += 1
end %>
<% end %>
<% else %>
@@ -210,16 +214,16 @@
<% end %>
<%end%>
<td><b><%= number_with_precision(old_grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '0' %></b></td>
<td><b><%= rounding_adj.to_f rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
<td><b><%= number_with_precision(old_grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '0' %></b></td>
<td><b><%= rounding_adj.to_f rescue '-' %></b></td>
<td><b><%= number_with_precision(grand_total.to_f, precision: precision.to_i ,delimiter: delimiter) rescue '-' %></b></td>
</tr>
<tr>
<td colspan="3">&nbsp;</td>
<td><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %></td>
<td><%= t("views.right_panel.detail.discount") %> <%= t("views.right_panel.detail.amount") %></td>
<% @tax_profiles.each do |tax| %>
<td><%= tax.name %></td>
<% end %>
@@ -243,20 +247,20 @@
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) ;
@@ -271,50 +275,50 @@
to = new_date.getDate() + "-" + month + "-" + new_date.getFullYear();
$('#to').val(to)
search_by_date();
});
});
function search_by_date(){
from = $("#from").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);
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');
shift.empty();
var str = '';
var param_shift = '';
var param_shift = '';
var param_shift = '<%= params[:shift_name] rescue '-'%>';
if (from == '' && to == '') {
from = $("#from").val();
to = $("#to").val();
}
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 ;
@@ -323,18 +327,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>
</script>

View File

@@ -15,8 +15,9 @@
<hr />
<div class="text-right">
<%= link_to "Print", reports_print_sale_items_path(:type => params[:sale_type], :period => params[:period], :account => params[:account_type], :from => @from, :to => @to, :shift_name => params[:shift_name], :shift_from => @shift_from, :shift_to => @shift_to, :menu_cate_count => @menu_cate_count, :sale_items => @sale_data.to_json), :method => 'post', class:"btn btn-info wave-effects" %>
<a href="javascript:export_to('<%=reports_saleitem_index_path%>.xls')" class = "btn btn-info wave-effects "><%= t("views.btn.exp_to_excel") %></a>
</div>
</div>
<div class="margin-top-20">
<div class="card">

View File

@@ -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,39 @@
<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 class="d-none d-sm-table-cell"><%= t("views.btn.other_payment") %></th>
<th class="d-none d-sm-table-cell"><%= 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,19 +80,19 @@
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 '-'%>
@@ -94,7 +100,7 @@
<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 +108,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 +141,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 +150,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 +190,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 +223,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 +243,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>

View File

@@ -3,45 +3,47 @@ class ActionController::Base
private
def lookup_domain
if request.subdomain.present? && request.subdomain != "www"
from = request.subdomain.downcase + "." + request.domain.downcase
def lookup_domain
if request.subdomain.present? && request.subdomain != "www"
from = request.subdomain.downcase + "." + request.domain.downcase
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
if (!@license.nil?)
logger.info "Location - " + @license.dbschema
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
logger.info "Location - " + @license.dbschema
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
else
# reconnect_default_db
logger.info 'License is nil'
# redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}]
end
else
end
else
# check for license file
if check_license
current_license(ENV["SX_PROVISION_URL"])
else
redirect_to activate_path
end
end
if check_license
current_license(ENV["SX_PROVISION_URL"])
else
redirect_to activate_path
end
end
end
def current_license(url)
def current_license(url)
@license = License.new(url)
flag = @license.detail_with_local_file()
if (flag == 0)
flash[:notice] = 'Expired or No License!'
flash[:notice] = 'Expired or No License!'
elsif (flag == 2)
flash[:notice] = 'Expiring! Please, License extend...'
flash[:notice] = 'Expiring! Please, License extend...'
else
puts "RUN SAY BYAR"
end
end
def cache_license(url, lookup)
@license = License.new(url, lookup)
def cache_license(url, lookup)
@license = License.new(url, lookup)
if (@license.detail_with_local_cache(lookup) == true)
return @license
@@ -51,7 +53,7 @@ class ActionController::Base
end
def check_license
License.check_license_file
License.check_license_file
end
def check_installation
@@ -83,7 +85,7 @@ class ActionController::Base
# RESTful url for localize
def default_url_options
{ locale: I18n.locale }
end
end
end
@@ -92,26 +94,26 @@ class ActionController::API
private
def lookup_domain
if request.subdomain.present? && request.subdomain != "www"
from = request.subdomain.downcase + "." + request.domain.downcase
def lookup_domain
if request.subdomain.present? && request.subdomain != "www"
from = request.subdomain.downcase + "." + request.domain.downcase
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
if (!@license.nil?)
logger.info "Location - " + @license.dbschema
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
logger.info "Location - " + @license.dbschema
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
else
# reconnect_default_db
logger.info 'License is nil'
# redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}]
end
end
end
end
end
end
def cache_license(url, lookup)
@license = License.new(url, lookup)
def cache_license(url, lookup)
@license = License.new(url, lookup)
if (@license.detail_with_local_cache(lookup) == true)
return @license
@@ -143,7 +145,6 @@ class ActionController::API
# RESTful url for localize
def default_url_options
{ locale: I18n.locale }
end
end
end

View File

@@ -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,8 @@ 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"
post "print_sale_items", to: "saleitem#print_sale_items", as: "print_sale_items"
end

BIN
dump.rdb

Binary file not shown.