From 2b0dcd4ab938c3dd1c0a2df07c74cebfea463270 Mon Sep 17 00:00:00 2001 From: Yan Date: Mon, 21 Aug 2017 16:50:24 +0630 Subject: [PATCH] update and fix --- app/controllers/settings/set_menu_items_controller.rb | 2 +- app/controllers/settings/simple_menu_items_controller.rb | 2 +- app/pdf/crm_order_pdf.rb | 4 ++-- app/pdf/order_item_pdf.rb | 4 ++-- app/pdf/order_summary_pdf.rb | 4 ++-- app/pdf/queue_no_pdf.rb | 4 ++-- app/pdf/receipt_bill_pdf.rb | 4 ++-- app/views/api/restaurant/menu/_menu_item.json.jbuilder | 1 + app/views/settings/set_menu_items/_form.html.erb | 2 ++ app/views/settings/simple_menu_items/_form.html.erb | 2 ++ db/migrate/20170331024749_create_menu_items.rb | 1 + db/seeds.rb | 8 ++++++-- 12 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index 4f451de5..a9e91a94 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -132,6 +132,6 @@ class Settings::SetMenuItemsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_params - params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets) + params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit) end end diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index 4cf9318c..418cc2b8 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -154,6 +154,6 @@ class Settings::SimpleMenuItemsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_params - params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets) + params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets, :unit) end end diff --git a/app/pdf/crm_order_pdf.rb b/app/pdf/crm_order_pdf.rb index a7f85098..22a381ca 100644 --- a/app/pdf/crm_order_pdf.rb +++ b/app/pdf/crm_order_pdf.rb @@ -1,8 +1,8 @@ class CrmOrderPdf < Prawn::Document attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width def initialize(booking,order_items,printer_settings) - self.page_width = PrintSetting.where("name = ?","CRM Order").first.page_width - self.page_height = PrintSetting.where("name = ?","CRM Order").first.page_height + self.page_width = printer_settings.page_width + self.page_height = printer_settings.page_height self.margin = 10 # self.price_width = self.p_width / 2 self.price_width=80 diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 7b2e350b..4b9fb821 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -2,8 +2,8 @@ class OrderItemPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order_item, print_status, options, alt_name) - self.page_width = PrintSetting.where("name = ?","OrderItemPdf").first.page_width - self.page_height = PrintSetting.where("name = ?","OrderItemPdf").first.page_height + self.page_width = printer_settings.page_width + self.page_height = printer_settings.page_height self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 902c68ad..53248ebb 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -2,8 +2,8 @@ class OrderSummaryPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(print_settings,order, print_status, order_items = nil,alt_name) - self.page_width = PrintSetting.where("name = ?","Order Summary").first.page_width - self.page_height = PrintSetting.where("name = ?","Order Summary").first.page_height + self.page_width = printer_settings.page_width + self.page_height = printer_settings.page_height self.margin = 0 self.price_width = 40 # No Need for item self.qty_width = 40 diff --git a/app/pdf/queue_no_pdf.rb b/app/pdf/queue_no_pdf.rb index cda410ca..49e13bd9 100644 --- a/app/pdf/queue_no_pdf.rb +++ b/app/pdf/queue_no_pdf.rb @@ -1,8 +1,8 @@ class QueueNoPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width def initialize(printer_settings, queue) - self.page_width = PrintSetting.where("name = ?","Queue No").first.page_width - self.page_height = PrintSetting.where("name = ?","Queue No").first.page_height + self.page_width = printer_settings.page_width + self.page_height = printer_settings.page_height self.margin = 5 self.price_width = 35 self.qty_width = 20 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 809f7678..1d9b3f4d 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -2,8 +2,8 @@ class ReceiptBillPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status) - self.page_width = PrintSetting.where("name = ?","Receipt Bill").first.page_width - self.page_height = PrintSetting.where("name = ?","Receipt Bill").first.page_height + self.page_width = printer_settings.page_width + self.page_height = printer_settings.page_height self.margin = 5 self.price_width = 40 self.qty_width = 20 diff --git a/app/views/api/restaurant/menu/_menu_item.json.jbuilder b/app/views/api/restaurant/menu/_menu_item.json.jbuilder index cd8648db..7a450850 100644 --- a/app/views/api/restaurant/menu/_menu_item.json.jbuilder +++ b/app/views/api/restaurant/menu/_menu_item.json.jbuilder @@ -35,6 +35,7 @@ json.account_id item.account_id json.min_qty item.min_qty json.is_available item.is_available json.is_sub_item item.is_sub_item +json.unit item.unit json.item_sets item.item_sets json.attributes attr_format json.options item.item_options diff --git a/app/views/settings/set_menu_items/_form.html.erb b/app/views/settings/set_menu_items/_form.html.erb index f243fb74..33be7f3a 100644 --- a/app/views/settings/set_menu_items/_form.html.erb +++ b/app/views/settings/set_menu_items/_form.html.erb @@ -16,6 +16,8 @@ <%= f.input :is_sub_item, :class => "form-control" %> + <%= f.input :unit, :collection => Lookup.collection_of("unit") ,:class => "form-control" %> + <%= f.input :item_attributes, :collection => @item_attributes, :input_html => { :multiple => true }, :class => "form-control item_attributes" %> <%= f.input :item_options, :collection => @item_options, :input_html => { :multiple => true }, :class => "form-control item_options" %> diff --git a/app/views/settings/simple_menu_items/_form.html.erb b/app/views/settings/simple_menu_items/_form.html.erb index 721c7230..82ef5f17 100644 --- a/app/views/settings/simple_menu_items/_form.html.erb +++ b/app/views/settings/simple_menu_items/_form.html.erb @@ -16,6 +16,8 @@ <%= f.input :is_sub_item, :class => "form-control" %> + <%= f.input :unit, :collection => Lookup.collection_of("unit") ,:class => "form-control" %> + <%= f.input :item_attributes, :collection => @item_attributes, :input_html => { :multiple => true }, :class => "form-control item_attributes" %> <%= f.input :item_options, :collection => @item_options, :input_html => { :multiple => true }, :class => "form-control item_options" %> diff --git a/db/migrate/20170331024749_create_menu_items.rb b/db/migrate/20170331024749_create_menu_items.rb index 75897d52..3ab06a94 100644 --- a/db/migrate/20170331024749_create_menu_items.rb +++ b/db/migrate/20170331024749_create_menu_items.rb @@ -7,6 +7,7 @@ class CreateMenuItems < ActiveRecord::Migration[5.1] t.string :image_path t.text :description t.string :information + t.string :unit t.string :type, :null => false, :default => "SimpleMenuItem" t.references :menu_category, foreign_key: true t.json :item_attributes diff --git a/db/seeds.rb b/db/seeds.rb index bf458f2a..27859c89 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -95,8 +95,12 @@ float_value = Lookup.create([{lookup_type:'float_value', name: '500', value: '50 # customer type customer_type = Lookup.create([{lookup_type:'customer_type', name: 'Dinein', value: 'Dinein'}, - {lookup_type:'customer_type', name: 'Takeaway', value: 'Takeaway'}, - {lookup_type:'customer_type', name: 'Delivery', value: 'Delivery'}]) + {lookup_type:'customer_type', name: 'Takeaway', value: 'Takeaway'}, + {lookup_type:'customer_type', name: 'Delivery', value: 'Delivery'}]) + +#unit +units = Lookup.create([{lookup_type:'unit', name: 'PCS', value: 'pcs'}, + {lookup_type:'unit', name: 'KG', value: 'kg'}]) # Default CUSTOMER customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000",card_no:"000", customer_type:"Dinein", tax_profiles:["2", "1"]})