Merge branch 'r-1902001-01-dev' of gitlab.com:code2lab/SXRestaurant into r-1902001-01-dev

This commit is contained in:
code2lab
2019-06-03 11:47:14 +06:30
68 changed files with 2234 additions and 1353 deletions

View File

@@ -5,9 +5,14 @@ class PrintSetting < ApplicationRecord
def self.get_precision_delimiter
setting = PrintSetting.find_by_unique_code("CloseCashierPdf")
if setting.nil?
setting = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf")
star_setting = PrintSetting.find_by_unique_code("CloseCashierStarPdf")
if star_setting.nil?
setting = PrintSetting.find_by_unique_code("CloseCashierCustomisePdf")
else
return star_setting
end
end
return setting
end
end

View File

@@ -37,7 +37,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# pdf.render_file filename
# self.print(filename, cashier_terminal.printer_name)
# end
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?
@@ -81,10 +81,15 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
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)
def print_sale_items_report(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items)
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)
if print_settings.unique_code == "SaleItemsPdf"
pdf = SaleItemsPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil)
end
if print_settings.unique_code == "SaleItemsStarPdf"
pdf = SaleItemsStarPdf.new(print_settings, shop_details, period_name, type, account, from_date, to_date, shift_name, sale_items, nil, nil, nil)
end
pdf.render_file filename

View File

@@ -879,7 +879,6 @@ 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
@@ -952,7 +951,6 @@ def self.get_by_shiftsales(from,to,shift)
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,
@@ -961,7 +959,8 @@ def self.get_by_shiftsales(from,to,shift)
:credit_sales => shift_sale.credit_sales,
:other_sales => shift_sale.other_sales.to_f,
:foc_sales => foc,
:grand_total => shift_sale.grand_total
:grand_total => shift_sale.grand_total,
:shift_id => shift_sale.id
}
end
@@ -1127,15 +1126,6 @@ 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," +
@@ -2544,6 +2534,15 @@ end
end
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.pending_sale(type)
query = Sale.all
query = query.joins("join sale_orders as sale_orders on sale_orders.sale_id = sales.sale_id")