Merge branch 'sqa-1804-001' of bitbucket.org:code2lab/sxrestaurant into r-1804001-01

This commit is contained in:
phyusin
2018-05-14 17:05:23 +06:30
25 changed files with 328 additions and 183 deletions

View File

@@ -155,24 +155,28 @@ class Menu < ApplicationRecord
# Menu Item Attributes
item_attrs = []
attributes = row["Attributes"].split(',')
attributes.each do |attr|
attribute = MenuItemAttribute.find_by_name(attr)
if attribute.nil?
attribute = MenuItemAttribute.create({ attribute_type:"any", name: attr.capitalize, value: attr.downcase })
if !row["Attributes"].nil?
attributes = row["Attributes"].split(',')
attributes.each do |attr|
attribute = MenuItemAttribute.find_by_name(attr)
if attribute.nil?
attribute = MenuItemAttribute.create({ attribute_type:"any", name: attr.capitalize, value: attr.downcase })
end
item_attrs.push(attribute.id)
end
item_attrs.push(attribute.id)
end
# Menu Item Options
item_opts = []
if !row["Options"].nil?
options = row["Options"].split(',')
options.each do |opt|
option = MenuItemOption.find_by_name(opt)
if option.nil?
option = MenuItemOption.create({ option_type:"any", name: opt.capitalize, value: opt.downcase })
options.each do |opt|
option = MenuItemOption.find_by_name(opt)
if option.nil?
option = MenuItemOption.create({ option_type:"any", name: opt.capitalize, value: opt.downcase })
end
item_opts.push(option.id)
end
item_opts.push(option.id)
end
menu_itm = MenuItem.find_by_item_code(row["Item Code"])
@@ -189,7 +193,11 @@ class Menu < ApplicationRecord
menu_inst = MenuItemInstance.find_by_item_instance_code(row["Instance Code"])
if !menu_inst
imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: row["Instance Name"], item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"])
instance_name = ''
if !row["Instance Name"].nil?
instance_name = row["Instance Name"]
end
imported_instance = MenuItemInstance.create(menu_item_id: menu_itm.id, item_instance_code: row["Instance Code"], item_instance_name: instance_name, item_attributes: [], price: row["Price"], is_on_promotion: false, promotion_price: 0, is_available: true, is_default: row["Is Default"])
# else
# status = status + "Instance Code already exists for " + row["Instance Name"] + "."
end

View File

@@ -38,7 +38,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# 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)
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)
#Use CUPS service
#Generate PDF
@@ -46,7 +46,7 @@ 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)
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_waste,total_spoile)
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
if !close_cashier_pdf.empty?
@@ -55,7 +55,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
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)
else
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount)
pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_waste,total_spoile)
end
end
end

View File

@@ -1091,6 +1091,14 @@ end
return sale_arr
end
def self.get_total_waste(shift_id)
query = Sale.where("sale_status = 'waste' and shift_sale_id = ?", shift_id)
end
def self.get_total_spoile(shift_id)
query = Sale.where("sale_status = 'spoile' and shift_sale_id = ?", shift_id)
end
def self.get_separate_tax(shift_sale_range=nil,shift,from,to,payment_type)
# wrong amount tax for service and commercial tax