diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index 21d95770..218bacb8 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -9,7 +9,7 @@ class MenuCategory < ApplicationRecord validates_presence_of :code, :name, :menu, :order_by validates_uniqueness_of :code - default_scope { order('name asc') } + default_scope { order('order_by asc') } scope :active, -> {where("is_available = 1")} def self.destroyCategory(menu_category) diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index e184cd51..03e90011 100755 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -16,7 +16,7 @@ class MenuItem < ApplicationRecord validates_presence_of :item_code, :name, :type, :min_qty,:account_id validates_uniqueness_of :item_code - default_scope { order('name asc') } + default_scope { order('item_code asc') } scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') } scope :set_menu_item, -> { where(type: 'SetMenuItem') } diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index 4d0b23f2..4e4d586b 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -205,7 +205,7 @@ class ReceiptBillA5Pdf < Prawn::Document price = item.unit_price product_name = item.product_name - if show_price.to_i>0 + 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 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 458e1780..fa923720 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -187,7 +187,7 @@ class ReceiptBillPdf < Prawn::Document total_qty = 0.0 sale_items.each do |item| # check for item not to show - show_price = Lookup.find_by_lookup_type("show_price").value + show_price = Lookup.find_by_lookup_type("show_price") sub_total += item.price #(item.qty*item.unit_price) - comment for room charges if item.status != 'Discount' && item.qty > 0 @@ -198,7 +198,7 @@ class ReceiptBillPdf < Prawn::Document price = item.unit_price product_name = item.product_name - if show_price.to_i>0 + 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 diff --git a/app/views/oqs/edit/index.html.erb b/app/views/oqs/edit/index.html.erb index d9485b3a..64015e82 100644 --- a/app/views/oqs/edit/index.html.erb +++ b/app/views/oqs/edit/index.html.erb @@ -104,10 +104,12 @@ $(document).ready(function(){ $('#qty-update').on('click', function(){ var qty_weight = $("input[name='qty_weight']").val(); - if(parseInt(qty_weight) > parseInt(original_value)){ + if(parseInt(qty_weight) >= parseInt(original_value)){ swal("Alert!", "Not allowed over quantity", "warning"); return; } + + var remarks = $("textarea[name='remarks']").val(); var order_items_id = $(this).attr('data-id'); diff --git a/app/views/origami/dashboard/_menu.json.jbuilder b/app/views/origami/dashboard/_menu.json.jbuilder index 5fe53223..ff9721a3 100644 --- a/app/views/origami/dashboard/_menu.json.jbuilder +++ b/app/views/origami/dashboard/_menu.json.jbuilder @@ -5,7 +5,14 @@ json.valid_time_from menu.valid_time_from.strftime("%H:%M") json.valid_time_to menu.valid_time_to.strftime("%H:%M") if (menu.menu_categories) - json.categories menu.menu_categories do |category| + order_by = Lookup.find_by_lookup_type("order_by") + if !order_by.nil? && order_by.value == "name" + categories = MenuCategory.where("menu_id ='#{menu.id}'").order("name asc") + else + categories = menu.menu_categories + end + byebug + json.categories categories do |category| menu_category = MenuCategory.find_by_menu_category_id(category.id) if !menu_category.nil? @@ -25,10 +32,14 @@ if (menu.menu_categories) json.parent_id category.menu_category_id json.is_available category.is_available - + if !order_by.nil? && order_by.value == "name" + menu_items = MenuItem.find_by_menu_category_id(category.id).order("name asc") + else + menu_items = category.menu_items + end if category.menu_items - json.items category.menu_items do |item| + json.items menu_items do |item| if item.is_available json.partial! 'origami/addorders/menu_item', item: item end diff --git a/app/views/reports/commission/index.xls.erb b/app/views/reports/commission/index.xls.erb index 4ea1f2f0..6ec88072 100755 --- a/app/views/reports/commission/index.xls.erb +++ b/app/views/reports/commission/index.xls.erb @@ -1,3 +1,10 @@ + + +
+ + + +