Merge branch 'adminbsb_ui_changes' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-11-22 18:39:56 +06:30
43 changed files with 1321 additions and 1166 deletions

View File

@@ -6,7 +6,8 @@ class MenuCategory < ApplicationRecord
belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true
has_many :menu_items
validates_presence_of :name, :menu, :order_by
validates_presence_of :code, :name, :menu, :order_by
validates_uniqueness_of :code
default_scope { order('order_by asc') }
scope :active, -> {where("is_available = 1")}

View File

@@ -13,8 +13,9 @@ class MenuItem < ApplicationRecord
has_many :menu_item_sets
has_many :item_sets, through: :menu_item_sets
validates_presence_of :name, :type, :min_qty, :taxable,:account_id
validates_presence_of :item_code, :name, :type, :min_qty, :taxable,:account_id
validates_uniqueness_of :item_code
default_scope { order('item_code asc') }
scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') }

View File

@@ -4,6 +4,8 @@ class MenuItemInstance < ApplicationRecord
has_many :menu_instance_item_sets
has_many :item_sets, through: :menu_instance_item_sets
# before_create :generate_menu_item_instance_code
validates_presence_of :item_instance_code
# validates_uniqueness_of :item_instance_code
def self.findParentCategory(item)
if item.menu_category_id

View File

@@ -955,7 +955,7 @@ end
# .joins("join sale_payments on sale_id = sales.sale_id")
# .group("sales.sale_id")
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb"',today)
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(sales.receipt_date,"%Y-%m-%d") = ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb")',today)
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount")