diff --git a/Gemfile b/Gemfile index 0b7c3f11..bcbebe51 100644 --- a/Gemfile +++ b/Gemfile @@ -12,7 +12,8 @@ gem 'rails', '~> 5.1.0' gem 'mysql2', '>= 0.3.18', '< 0.5' -gem 'pg' +#Use PosgreSQL +# gem 'pg' # redis server for cable # gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 5dce67dc..e2c1dd73 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -119,7 +119,6 @@ GEM nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) - pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -253,7 +252,6 @@ DEPENDENCIES kaminari! listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) - pg prawn prawn-table puma (~> 3.0) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 80a09b47..7df365ec 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -80,4 +80,14 @@ $(document).ready(function(){ success: function(data){ } }); }); + + $('#print_order_summary').on('click',function(){ + var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); + var params = { 'id':assigned_item_id }; + $.ajax({ + type: 'GET', + url: '/oqs/print/print_order_summary/'+assigned_item_id, + success: function(data){ } + }); + }); }); diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 443a754b..df9b1542 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -28,7 +28,7 @@ class Api::OrdersController < Api::ApiController @order = Order.new @order.source = params[:order_source] @order.order_type = params[:order_type] - @order.customer_id = params[:customer_id] + @order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile @order.items = params[:order_items] @order.guest = params[:guest_info] @order.table_id = params[:table_id] diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 1292a5e6..2b676f21 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -35,15 +35,15 @@ class Oqs::HomeController < BaseOqsController # Query for OQS with status def queue_items_query(status) - AssignedOrderItem.select("assigned_order_items.id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") - .joins("join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id + AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") + .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id left join dining_facilities as df on df.zone_id = oqpz.zone_id left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id - left join orders as od ON od.id = assigned_order_items.order_id + left join orders as od ON od.order_id = assigned_order_items.order_id left join order_items as odt ON odt.item_code = assigned_order_items.item_code - left join customers as cus ON cus.id = od.customer_id") + left join customers as cus ON cus.customer_id = od.customer_id") .where("assigned_order_items.delivery_status = #{status}") - .group("assigned_order_items.id") + .group("assigned_order_items.assigned_order_item_id") .order("odt.item_name DESC") end end diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index 368a513d..1b48fae6 100644 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -2,7 +2,7 @@ class Oqs::PrintController < ApplicationController def print unique_code="OrderItemPdf" assigned_item_id=params[:id] - assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id) + assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('assigned_order_item_id='+assigned_item_id) print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) @@ -13,4 +13,19 @@ class Oqs::PrintController < ApplicationController assigned_item.print_status=true assigned_item.save end + + def print_order_summary + unique_code="OrderSummaryPdf" + assigned_item_id=params[:id] + assigned_order_item=AssignedOrderItem.select("order_id").where('assigned_order_item_id='+assigned_item_id) + + print_settings=PrintSetting.find_by_unique_code(unique_code) + order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) + order_queue_printer.print_order_summary(print_settings,assigned_order_item[0].order_id) + + # update print status when complete click + assigned_item=AssignedOrderItem.find(assigned_item_id) + assigned_item.print_status=true + assigned_item.save + end end diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb index 6bd00638..f9c20a2d 100644 --- a/app/controllers/settings/menu_item_instances_controller.rb +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -41,7 +41,7 @@ class Settings::MenuItemInstancesController < ApplicationController category = MenuCategory.find(catID.menu_category_id) respond_to do |format| if @settings_menu_item_instances.save - @settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes] + @settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?) @settings_menu_item_instances.save format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' } format.json { render :show, status: :created, location: @settings_menu_item_instances } diff --git a/app/models/login_form.rb b/app/forms/login_form.rb similarity index 100% rename from app/models/login_form.rb rename to app/forms/login_form.rb diff --git a/app/jobs/order_queue_processor_job.rb b/app/jobs/order_queue_processor_job.rb index e9a8c13f..e92faa36 100644 --- a/app/jobs/order_queue_processor_job.rb +++ b/app/jobs/order_queue_processor_job.rb @@ -5,7 +5,7 @@ class OrderQueueProcessorJob < ApplicationJob # Do something later #Order ID order = Order.find(order_id) - + #Loop through the order stations and process the items #Execute orders and send to order stations if order diff --git a/app/models/assigned_order_item.rb b/app/models/assigned_order_item.rb index c2d2e8b0..3ac84077 100644 --- a/app/models/assigned_order_item.rb +++ b/app/models/assigned_order_item.rb @@ -1,4 +1,9 @@ class AssignedOrderItem < ApplicationRecord + before_create :generate_custom_id + + #primary key - need to be unique + self.primary_key = "assigned_order_item_id" + belongs_to :order belongs_to :order_queue_station @@ -11,4 +16,9 @@ class AssignedOrderItem < ApplicationRecord assigned_order_item.delivery_status = false assigned_order_item.save end + + private + def generate_custom_id + self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI") + end end diff --git a/app/models/booking.rb b/app/models/booking.rb index fcd0c909..01cf0f46 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -1,9 +1,17 @@ + class Booking < ApplicationRecord + self.primary_key = "booking_id" + #primary key - need to be unique + before_create :generate_custom_id belongs_to :dining_facility, :optional => true belongs_to :sale, :optional => true has_many :booking_orders + has_many :orders, :through => :booking_orders - + private + def generate_custom_id + self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI") + end end diff --git a/app/models/booking_order.rb b/app/models/booking_order.rb index c9f748f0..ddf5ed18 100644 --- a/app/models/booking_order.rb +++ b/app/models/booking_order.rb @@ -1,5 +1,5 @@ class BookingOrder < ApplicationRecord - #primary key - need to be unique + #primary key - need to be unique belongs_to :booking belongs_to :order diff --git a/app/models/cashier_login_log.rb b/app/models/cashier_login_log.rb index d64860ce..353e9c90 100644 --- a/app/models/cashier_login_log.rb +++ b/app/models/cashier_login_log.rb @@ -1,4 +1,11 @@ class CashierLoginLog < ApplicationRecord + before_create :generate_custom_id + belongs_to :cashier_station belongs_to :employee + + private + def generate_custom_id + self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, "CLO") + end end diff --git a/app/models/crm.rb b/app/models/crm.rb deleted file mode 100644 index 3407e215..00000000 --- a/app/models/crm.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Crm - def self.table_name_prefix - 'crm_' - end -end diff --git a/app/models/customer.rb b/app/models/customer.rb index 42247791..86a638c7 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,4 +1,7 @@ class Customer < ApplicationRecord + self.primary_key = "customer_id" + + before_create :generate_custom_id has_many :orders has_many :sales @@ -8,4 +11,9 @@ class Customer < ApplicationRecord def lastest_invoices sales.where(:customer_id => self.id).order("created_at desc").limit(5) end + + private + def generate_custom_id + self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS") + end end diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 2a4e86be..7d69ca3e 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -1,5 +1,5 @@ class MenuItem < ApplicationRecord - belongs_to :account + # belongs_to :account belongs_to :menu_category, :optional => true has_many :menu_item_instances belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true diff --git a/app/models/order.rb b/app/models/order.rb index dc969187..60eca518 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,6 +1,8 @@ class Order < ApplicationRecord - #primary key - need to be unique + self.primary_key = "order_id" + #primary key - need to be unique + before_create :generate_custom_id before_create :set_order_date belongs_to :customer @@ -40,7 +42,7 @@ class Order < ApplicationRecord self.adding_line_items #Add Order Table and Room relation afrer order creation - BookingOrder.create({:booking_id => booking.id, :order => self}) + BookingOrder.create({:booking_id => booking.booking_id, :order => self}) #Send order to queue one it done! process_order_queue @@ -182,14 +184,6 @@ class Order < ApplicationRecord return new_items_list end - private - def validate_api_inputs - - end - - def set_order_date - self.date = Time.now.utc - end #Update Items Count and Quantity changes whenever there is changes def update_products_and_quantity_count @@ -223,8 +217,10 @@ 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, order_items.id,dining_facilities.name") + end #Origami: Cashier : to view order type Room def self.get_order_rooms @@ -250,4 +246,14 @@ class Order < ApplicationRecord .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) .group("orders.id,order_items.id,dining_facilities.name") end + + + private + def generate_custom_id + self.order_id = SeedGenerator.generate_id(self.class.name, "ODR") + end + + def set_order_date + self.date = Time.now.utc + end end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 1633c1c4..0e258ac4 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -1,5 +1,8 @@ class OrderItem < ApplicationRecord + self.primary_key = "order_items_id" + #primary key - need to be unique + before_create :generate_custom_id #Associations belongs_to :order, autosave: true @@ -42,4 +45,9 @@ class OrderItem < ApplicationRecord .where("order_items.order_id=?",order_id) end + + private + def generate_custom_id + self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI") + end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 6a8a4b78..3428bb98 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -10,12 +10,12 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker self.print("tmp/receipt.pdf") end - def print_order_summary(printer_settings,booking_id) + def print_order_summary(printer_settings,order_id) #Use CUPS service #Generate PDF #Print - order=print_query('booking',booking_id) - filename = "tmp/order_summary_#{booking_id}" + ".pdf" + order=print_query('order_summary',order_id) + filename = "tmp/order_summary_#{order_id}" + ".pdf" pdf = OrderSummaryPdf.new(order,printer_settings) pdf.render_file filename @@ -25,21 +25,23 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # Query for OQS with status def print_query(type, code) if type == 'order_item' - OrderItem.select("order_items.item_code, order_items.item_name,order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") - .joins("left join orders ON orders.id = order_items.order_id + OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") + .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id - left join bookings AS b ON b.id = bo.booking_id - left join dining_facilities AS df ON df.id = b.dining_facility_id - left join customers as cus ON cus.id = orders.customer_id") + left join bookings AS b ON b.booking_id = bo.booking_id + left join dining_facilities AS df ON df.dining_facility_id = b.dining_facility_id + left join customers as cus ON cus.customer_id = orders.customer_id") .where("order_items.item_code=" + code) .group("order_items.item_code") else - OrderItem.select("order_items.item_code, order_items.item_name, df.name as dining") - .joins("left join orders ON orders.id = order_items.order_id + OrderItem.select("order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") + .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id - left join bookings AS b ON b.id = bo.booking_id - left join dining_facilities AS df ON df.id = b.dining_facility_id") - .where("booking.id=" + code) + left join bookings AS b ON b.booking_id = bo.booking_id + left join dining_facilities AS df ON df.dining_facility_id = b.dining_facility_id + left join customers as cus ON cus.customer_id = orders.customer_id") + .where("orders.order_id=" + code.to_s) + .group("order_items.item_code") end end diff --git a/app/models/room_booking.rb b/app/models/room_booking.rb index fb7c0dac..7efa52cb 100644 --- a/app/models/room_booking.rb +++ b/app/models/room_booking.rb @@ -1,3 +1,4 @@ class RoomBooking < Booking - + has_many :orders + end diff --git a/app/models/sale.rb b/app/models/sale.rb index 1a1c4b67..880f0c54 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1,6 +1,9 @@ -#primary key - need to be unique generated for multiple shops - class Sale < ApplicationRecord + self.primary_key = "sale_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id + #before_create :generate_receipt_no belongs_to :cashier, :optional => true belongs_to :customer, :optional => true @@ -243,4 +246,8 @@ class Sale < ApplicationRecord end end + private + def generate_custom_id + self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") + end end diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index cce6982d..c99d2dfc 100644 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -1,6 +1,9 @@ class SaleAudit < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_audit_id" + #primary key - need to be unique generated for SaleAudit + before_create :generate_custom_id + belongs_to :sale def record_audit_void(sale_id, void_by, approved_by, reason) @@ -50,4 +53,9 @@ class SaleAudit < ApplicationRecord sale_audit.remark = remark sale_audit.save! end + + private + def generate_custom_id + self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI") + end end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index c92ed48f..e202a53c 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -1,9 +1,17 @@ class SaleItem < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_item_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id belongs_to :sale #compute items - discount, tax, price_change def compute_item end + + private + def generate_custom_id + self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI") + end end diff --git a/app/models/sale_order.rb b/app/models/sale_order.rb index 23fd39bd..15da1386 100644 --- a/app/models/sale_order.rb +++ b/app/models/sale_order.rb @@ -1,6 +1,14 @@ class SaleOrder < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_order_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id belongs_to :sale belongs_to :order + + private + def generate_custom_id + self.sale_order_id = SeedGenerator.generate_id(self.class.name, "SOI") + end end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 2f7b72ea..15fe4c74 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -1,5 +1,8 @@ class SalePayment < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_payment_id" + + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id belongs_to :sale @@ -156,4 +159,8 @@ class SalePayment < ApplicationRecord end + private + def generate_custom_id + self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") + end end diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb index 6e0a2d47..79de9134 100644 --- a/app/models/sale_tax.rb +++ b/app/models/sale_tax.rb @@ -1,5 +1,12 @@ class SaleTax < ApplicationRecord -#primary key - need to be unique generated for multiple shops + self.primary_key = "sale_tax_id" + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id belongs_to :sale + + private + def generate_custom_id + self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI") + end end diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index 4351e74b..d55af84d 100644 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -14,8 +14,9 @@ class SeedGenerator < ApplicationRecord seed.current = current_no seed.save end + padding_len = 15 - prefix.length - return prefix + "-" + seed.current.to_s + return prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0') end def self.new_receipt_no diff --git a/app/models/test.rb b/app/models/test.rb deleted file mode 100644 index fe0afa77..00000000 --- a/app/models/test.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Test < ApplicationRecord -end diff --git a/app/models/transactions.rb b/app/models/transactions.rb deleted file mode 100644 index 9cffb0d1..00000000 --- a/app/models/transactions.rb +++ /dev/null @@ -1,5 +0,0 @@ -module Transactions - def self.table_name_prefix - 'transactions_' - end -end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 356327b4..3044c578 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -11,21 +11,61 @@ class OrderItemPdf < Prawn::Document stroke_horizontal_rule move_down 5 - cashier_info(order_item.order_by,order_item.order_at, order_item.customer) + #order_info + order_info(order_item.order_by,order_item.order_at, order_item.customer) + # order items + order_items(order_item) end - def cashier_info(order_by, order_at, customer) - move_down 5 + # Write Order Information to PDF + def order_info(order_by, order_at, customer) y_position = cursor - bounding_box([0,y_position], :width =>200, :height => 20) do - text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y %m %d")}", :size => 7,:align => :left + bounding_box([0,y_position], :width => 200, :height => 15) do + text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left end stroke_horizontal_rule + move_down 20 + end + + # Write Order items to PDF + def order_items(order_item) + y_position = cursor + + bounding_box([0,y_position], :width => 180, :height => 15) do + text "Item", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 15) do + text "Qty", :size => 7,:align => :right + end + + stroke_horizontal_rule move_down 5 + + #Add Order Item + add_order_items(order_item) + end + + # Add order items under order info + def add_order_items(order_item) + y_position = cursor + + move_down 5 + + bounding_box([0,y_position], :width => 180, :height => 20) do + text "#{order_item.item_name}", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 20) do + text "#{order_item.qty}", :size => 7,:align => :right + end + + move_down 5 + end end diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 8b79b40e..8a7a1ad9 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -7,11 +7,68 @@ class OrderSummaryPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - font_size 9 - text "#{"table_name"}", :size => 15 + text "#{order[0].dining}", :size => 15 stroke_horizontal_rule move_down 5 + #order_info + order_info(order[0].order_by,order[0].order_at, order[0].customer) + + # order items + order_items(order) + + end + + # Write Order Information to PDF + def order_info(order_by, order_at, customer) + y_position = cursor + + bounding_box([0,y_position], :width => 200, :height => 15) do + text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left + end + + stroke_horizontal_rule + + move_down 20 + end + + # Write Order items to PDF + def order_items(order_item) + y_position = cursor + + bounding_box([0,y_position], :width => 180, :height => 15) do + text "Item", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 15) do + text "Qty", :size => 7,:align => :right + end + + stroke_horizontal_rule + move_down 5 + + #Add Order Item + add_order_items(order_item) + end + + # Add order items under order info + def add_order_items(order_item) + y_position = cursor + + move_down 5 + + order_item.each do|odi| + bounding_box([0,y_position], :width => 180, :height => 20) do + text "#{odi.item_name}", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 20) do + text "#{odi.qty}", :size => 7,:align => :right + end + end + + move_down 5 + end end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 982264ab..47d80f38 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -61,7 +61,7 @@

- + - + <% @@ -193,7 +193,7 @@
+
diff --git a/config/application.rb b/config/application.rb index 90f088bd..2a47de48 100644 --- a/config/application.rb +++ b/config/application.rb @@ -13,9 +13,6 @@ module SXRestaurants # -- all .rb files in that directory are automatically loaded. config.active_record.time_zone_aware_types = [:datetime, :time] config.active_job.queue_adapter = :sidekiq - - # config.generators do |g| - # g.orm :active_record, primary_key_type: :uuid - # end + end end diff --git a/config/routes.rb b/config/routes.rb index 8951a571..3c2ae56e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -100,7 +100,9 @@ Rails.application.routes.draw do post 'update_delivery', to: "home#update_delivery_status" + # Pass assigned_order_item_id get 'print/print/:id', to: "print#print" + get 'print/print_order_summary/:id', to: "print#print_order_summary" #dashboard # end diff --git a/db/migrate/20170403135121_create_customers.rb b/db/migrate/20170403135121_create_customers.rb index 76e9894a..8094f035 100644 --- a/db/migrate/20170403135121_create_customers.rb +++ b/db/migrate/20170403135121_create_customers.rb @@ -1,6 +1,7 @@ class CreateCustomers < ActiveRecord::Migration[5.0] def change - create_table :customers do |t| + create_table :customers, :id => false do |t| + t.string :customer_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync t.string :name, :null => false t.string :company t.string :contact_no diff --git a/db/migrate/20170403135934_create_orders.rb b/db/migrate/20170403135934_create_orders.rb index d318386e..a80e2760 100644 --- a/db/migrate/20170403135934_create_orders.rb +++ b/db/migrate/20170403135934_create_orders.rb @@ -1,10 +1,11 @@ class CreateOrders < ActiveRecord::Migration[5.0] def change - create_table :orders do |t| + create_table :orders, :id => false do |t| + t.string :order_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync t.datetime :date, :null => false t.string :source, :null => false, :default => "emenu" t.string :order_type, :null => false, :default => "dine-in" - t.references :customer, foreign_key: true + t.string :customer_id, foreign_key: true, :limit => 16 t.integer :item_count, :null => false, :default => 0 t.integer :quantity_count, :null => false, :default => 0 t.string :status, :null => false, :default => "new" diff --git a/db/migrate/20170403140820_create_order_items.rb b/db/migrate/20170403140820_create_order_items.rb index 847381a4..32760907 100644 --- a/db/migrate/20170403140820_create_order_items.rb +++ b/db/migrate/20170403140820_create_order_items.rb @@ -1,7 +1,8 @@ class CreateOrderItems < ActiveRecord::Migration[5.0] def change - create_table :order_items do |t| - t.references :order, foreign_key: true, :null => false + create_table :order_items, :id => false do |t| + t.string :order_items_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing + t.string :order_id, foreign_key: true, :null => false, :limit => 16 t.string :order_item_status, :null => false, :default => "new" t.string :item_order_by #person who order this t.string :item_code, :null => false diff --git a/db/migrate/20170403155531_create_cashier_login_logs.rb b/db/migrate/20170403155531_create_cashier_login_logs.rb index b12f258f..176c5cae 100644 --- a/db/migrate/20170403155531_create_cashier_login_logs.rb +++ b/db/migrate/20170403155531_create_cashier_login_logs.rb @@ -1,6 +1,8 @@ class CreateCashierLoginLogs < ActiveRecord::Migration[5.0] def change - create_table :cashier_login_logs do |t| + create_table :cashier_login_logs, :id => false, :primary_key => :cashier_login_log_id do |t| + t.string :cashier_login_log_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing + t.references :cashier_terminal, foreign_key: true t.references :employee, foreign_key: true t.datetime :login_at, :null => false diff --git a/db/migrate/20170403160742_create_sales.rb b/db/migrate/20170403160742_create_sales.rb index 4780a788..c2bb718a 100644 --- a/db/migrate/20170403160742_create_sales.rb +++ b/db/migrate/20170403160742_create_sales.rb @@ -1,13 +1,15 @@ class CreateSales < ActiveRecord::Migration[5.0] def change - create_table :sales do |t| + create_table :sales, :id => false do |t| + t.string :sale_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing + t.integer :cashier_id, :index => true t.string :cashier_name t.string :requested_by, :null => false t.datetime :requested_at, :null => false t.string :receipt_no, :null => false t.datetime :receipt_date, :null => false - t.references :customer, foreign_key: true + t.string :customer_id, foreign_key: true, :limit => 16 t.string :payment_status, :null => false, :default => "outstanding" t.string :sale_status, :null => false, :default => "new" t.decimal :total_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00 diff --git a/db/migrate/20170403161857_create_sale_items.rb b/db/migrate/20170403161857_create_sale_items.rb index 7f4533e3..aaf1dac3 100644 --- a/db/migrate/20170403161857_create_sale_items.rb +++ b/db/migrate/20170403161857_create_sale_items.rb @@ -1,7 +1,8 @@ class CreateSaleItems < ActiveRecord::Migration[5.0] def change - create_table :sale_items do |t| - t.references :sale, foreign_key: true + create_table :sale_items, :id => false do |t| + t.string :sale_item_id, :limit => 16, :primary_key => true#custom primary key - to ensure consistence for cloud syncing + t.string :sale_id, foreign_key: true, :limit => 16 t.string :product_code, :null => false t.string :product_name, :null => false t.string :remark diff --git a/db/migrate/20170403163219_create_sale_taxes.rb b/db/migrate/20170403163219_create_sale_taxes.rb index c52e4117..3d28381a 100644 --- a/db/migrate/20170403163219_create_sale_taxes.rb +++ b/db/migrate/20170403163219_create_sale_taxes.rb @@ -1,7 +1,9 @@ class CreateSaleTaxes < ActiveRecord::Migration[5.0] def change - create_table :sale_taxes do |t| - t.references :sale, foreign_key: true + create_table :sale_taxes, :id => false do |t| + t.string :sale_tax_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing + + t.string :sale_id, foreign_key: true, :limit => 16 t.string :tax_name, :null => false t.decimal :tax_rate, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :tax_payable_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00 diff --git a/db/migrate/20170403163734_create_sale_payments.rb b/db/migrate/20170403163734_create_sale_payments.rb index 3da5cb17..3badca93 100644 --- a/db/migrate/20170403163734_create_sale_payments.rb +++ b/db/migrate/20170403163734_create_sale_payments.rb @@ -1,13 +1,15 @@ class CreateSalePayments < ActiveRecord::Migration[5.0] def change - create_table :sale_payments do |t| - t.references :sale, foreign_key: true + create_table :sale_payments, :id => false do |t| + t.string :sale_payment_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing + + t.string :sale_id, foreign_key: true, :limit => 16 t.string :payment_method, :null => false, :default => "cash" t.decimal :payment_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.decimal :outstanding_amount, :precision => 10, :scale => 2, :null => false, :default => 0.00 t.string :payment_reference t.string :payment_status, :null => false, :default => "new" - + t.timestamps end end diff --git a/db/migrate/20170403174029_create_sale_orders.rb b/db/migrate/20170403174029_create_sale_orders.rb index 50923ac2..3da13e60 100644 --- a/db/migrate/20170403174029_create_sale_orders.rb +++ b/db/migrate/20170403174029_create_sale_orders.rb @@ -1,8 +1,10 @@ class CreateSaleOrders < ActiveRecord::Migration[5.0] def change - create_table :sale_orders do |t| - t.references :sale, foreign_key: true - t.references :order, foreign_key: true + create_table :sale_orders, :id => false do |t| + t.primary_key :sale_order_id #custom primary key - to ensure consistence for cloud syncing + + t.string :sale_id, foreign_key: true,:limit => 16 + t.string :order_id, foreign_key: true, :limit => 16 t.timestamps end diff --git a/db/migrate/20170403174111_create_sale_audits.rb b/db/migrate/20170403174111_create_sale_audits.rb index 1880478b..ae6ba3f4 100644 --- a/db/migrate/20170403174111_create_sale_audits.rb +++ b/db/migrate/20170403174111_create_sale_audits.rb @@ -1,7 +1,9 @@ class CreateSaleAudits < ActiveRecord::Migration[5.0] def change - create_table :sale_audits do |t| - t.references :sale, foreign_key: true + create_table :sale_audits, :id => false do |t| + t.string :sale_audit_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing + + t.string :sale_id, foreign_key: true, :limit => 16 t.string :action, :null => false t.datetime :action_at, :null => false t.string :action_by, :null => false diff --git a/db/migrate/20170404034234_create_bookings.rb b/db/migrate/20170404034234_create_bookings.rb index a67e7a30..f41e8fb4 100644 --- a/db/migrate/20170404034234_create_bookings.rb +++ b/db/migrate/20170404034234_create_bookings.rb @@ -1,6 +1,8 @@ class CreateBookings < ActiveRecord::Migration[5.0] def change - create_table :bookings do |t| + create_table :bookings, :id => false do |t| + t.string :booking_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing + t.references :dining_facility, foreign_key: true t.string :type, :null => false, :default => "Table" t.datetime :checkin_at, :null => false @@ -10,7 +12,8 @@ class CreateBookings < ActiveRecord::Migration[5.0] t.datetime :reserved_at t.string :reserved_by t.string :booking_status, :null => false, :default => "new" - t.references :sale, foreign_key: true + t.string :sale_id, foreign_key: true, :limit => 16 + t.string :customer_id, foreign_key: true, :limit => 16 t.timestamps end diff --git a/db/migrate/20170414090001_create_assigned_order_items.rb b/db/migrate/20170414090001_create_assigned_order_items.rb index e617adea..02b95017 100644 --- a/db/migrate/20170414090001_create_assigned_order_items.rb +++ b/db/migrate/20170414090001_create_assigned_order_items.rb @@ -1,9 +1,10 @@ class CreateAssignedOrderItems < ActiveRecord::Migration[5.0] def change - create_table :assigned_order_items do |t| + create_table :assigned_order_items, :id => false do |t| + t.string :assigned_order_item_id, :limit => 16, :primary_key => true #custom primary key - to ensure consistence for cloud syncing t.string :item_code, :null => false, :index => true t.references :order_queue_station, foreign_key: true - t.references :order, foreign_key: true + t.string :order_id, foreign_key: true, :limit => 16 t.boolean :print_status t.boolean :delivery_status diff --git a/db/migrate/20170414110918_create_booking_orders.rb b/db/migrate/20170414110918_create_booking_orders.rb index 9a28a5af..e9bf7cc0 100644 --- a/db/migrate/20170414110918_create_booking_orders.rb +++ b/db/migrate/20170414110918_create_booking_orders.rb @@ -1,8 +1,10 @@ class CreateBookingOrders < ActiveRecord::Migration[5.0] def change - create_table :booking_orders do |t| - t.references :booking, foreign_key: true - t.references :order, foreign_key: true + create_table :booking_orders, :id => false do |t| + #t.string :booking_order_id, :limit => 16, :null => false, :index => true, :unique => true #custom primary key - to ensure consistence for cloud syncing + t.primary_key :booking_order_id + t.string :booking_id, foreign_key: true, :limit => 16 + t.string :order_id, foreign_key: true, :limit => 16 t.timestamps end diff --git a/db/seeds.rb b/db/seeds.rb index 5e4dd995..4d7799db 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -133,3 +133,7 @@ zone_queue_station = OrderQueueProcessByZone.create({order_queue_station: zone_o #Create Adminstrator employee admin_employee = Employee.create({name: "Administrator", role: "Administrator", password: "99999", emp_id:"999", created_by: "SYSTEM DEFAULT"}) + +#Account for Menu Item Type (eg: Food, Beverage) +food = Account.create({title: "Food", account_type: "0"}) +beverage = Account.create({title: "Beverage", account_type: "1"}) diff --git a/redis-stable.tar.gz b/redis-stable.tar.gz deleted file mode 100644 index 47c49f3b..00000000 Binary files a/redis-stable.tar.gz and /dev/null differ diff --git a/spec/models/test_spec.rb b/spec/models/test_spec.rb deleted file mode 100644 index 2b626b06..00000000 --- a/spec/models/test_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'rails_helper' - -RSpec.describe Test, type: :model do - pending "add some examples to (or delete) #{__FILE__}" -end