Merge branch 'master' of ssh://bitbucket.org/code2lab/sxrestaurant
# Conflicts: # app/models/order_item.rb
This commit is contained in:
@@ -2,6 +2,6 @@ class Account < ApplicationRecord
|
||||
validates_presence_of :title, :account_type
|
||||
|
||||
has_many :menu_items
|
||||
# belongs_to :lookup , :class_name => "Lookup" ,:foreign_key => :tax_type
|
||||
# belongs_to :lookup , :class_name => "Lookup"
|
||||
|
||||
end
|
||||
|
||||
@@ -5,10 +5,13 @@ class MenuItem < ApplicationRecord
|
||||
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||
has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id"
|
||||
|
||||
validates_presence_of :item_code, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
|
||||
validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item
|
||||
|
||||
default_scope { order('item_code asc') }
|
||||
|
||||
scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') }
|
||||
scope :set_menu_item, -> { where(type: 'SetMenuItem') }
|
||||
|
||||
def self.collection
|
||||
MenuItem.select("id, name").map { |e| [e.name, e.id] }
|
||||
end
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
class MenuItemAttribute < ApplicationRecord
|
||||
validates_presence_of :attribute_type, :name, :value
|
||||
|
||||
def self.collection
|
||||
MenuItemAttribute.select("id, name").map { |e| [e.name, e.id] }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,7 +25,7 @@ class Order < ApplicationRecord
|
||||
if self.new_booking
|
||||
booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking",
|
||||
:checkin_at => Time.now.utc, :checkin_by => self.employee_name,
|
||||
:booking_status => "new" })
|
||||
:booking_status => "assign" })
|
||||
else
|
||||
if (self.booking_id.to_i > 0 )
|
||||
booking = Booking.find(self.booking_id)
|
||||
@@ -215,7 +215,9 @@ class Order < ApplicationRecord
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true)
|
||||
|
||||
.group("orders.id")
|
||||
|
||||
end
|
||||
#Origami: Cashier : to view order type Room
|
||||
def self.get_order_rooms
|
||||
@@ -226,7 +228,7 @@ class Order < ApplicationRecord
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true)
|
||||
.group("orders.id")
|
||||
.group("orders.id,order_items.id,dining_facilities.name")
|
||||
end
|
||||
#Origami: Cashier : to view orders
|
||||
def self.get_orders
|
||||
@@ -238,6 +240,7 @@ class Order < ApplicationRecord
|
||||
left join bookings on bookings.id = booking_orders.id
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
|
||||
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||
.group("orders.id")
|
||||
end
|
||||
|
||||
@@ -41,6 +41,7 @@ class OrderItem < ApplicationRecord
|
||||
order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
|
||||
.joins("left join orders on orders.id = order_items.order_id")
|
||||
.where("order_items.order_id=?",order_id)
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -63,4 +63,13 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
|
||||
self.print(filename)
|
||||
end
|
||||
#Bill Receipt Print
|
||||
def print_receipt_bill(printer_settings,sale_items,sale)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = ReceiptBillPdf.new(printer_settings,sale_items,sale)
|
||||
pdf.render_file "tmp/receipt_bill_#{sale.id}.pdf"
|
||||
self.print("tmp/receipt_bill_#{sale.id}.pdf")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user