diff --git a/Gemfile b/Gemfile index ccffbe23..a272cec9 100644 --- a/Gemfile +++ b/Gemfile @@ -10,10 +10,13 @@ end gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -gem 'mysql2', '>= 0.3.18', '< 0.5' +#gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL +gem 'pg' + + # redis server for cable # gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index ae2a3941..fbf61a33 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -119,7 +119,6 @@ GEM minitest (5.10.2) multi_json (1.12.1) multi_xml (0.6.0) - mysql2 (0.4.6) nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) @@ -258,6 +257,7 @@ DEPENDENCIES jquery-rails kaminari! listen (~> 3.0.5) + pg mysql2 (>= 0.3.18, < 0.5) prawn prawn-table diff --git a/app/assets/javascripts/orgiami.js b/app/assets/javascripts/orgiami.js index fc91e269..cd8622c3 100644 --- a/app/assets/javascripts/orgiami.js +++ b/app/assets/javascripts/orgiami.js @@ -15,3 +15,88 @@ //= require jquery_ujs //= require turbolinks //= require cable + +$(document).ready(function(){ + $(".orders").on('click', function(){ + var zone_name=$(this).find(".orders-table").text(); + var receipt_no=$(this).find(".orders-receipt-no").text(); + var unique_id=$(this).find(".orders-id").text(); + + var cashier=""; + var receipt_date=""; + var sub_total=0; + var discount_amount=0; + var tax_amount=0; + var grand_total_amount=0; + + $("#order-title").text("ORDER DETAILS - " + zone_name); + // clear order items + $("#order-items-table").children("tbody").empty(); + + // AJAX call for order + $.ajax({ + type: "GET", + url: "origami/" + unique_id, + data: { 'id' : unique_id }, + success:function(result){ + for (i = 0; i < result.length; i++) { + var data = JSON.stringify(result[i]); + var parse_data = JSON.parse(data); + + // Receipt Header + receipt_no = result[i].receipt_no; + cashier = result[i].cashier_name; + receipt_date = result[i].receipt_date; + + $("#receipt_no").text(receipt_no); + $("#cashier").text(cashier==null?"":cashier); + $("#receipt_date").text(receipt_date); + + + //Receipt Charges + sub_total += (parse_data.qty*parse_data.price); + discount_amount = parse_data.discount_amount; + tax_amount = parse_data.tax_amount; + grand_total_amount = parse_data.grand_total_amount; + + $("#order-sub-total").text(sub_total); + $("#order-food").text(''); + $("#order-beverage").text(''); + $("#order-discount").text(discount_amount); + $("#order-Tax").text(tax_amount); + $("#order-grand-total").text(grand_total_amount); + + // Ordered Items + var order_items_rows = "" + + "" + parse_data.item_name + "" + + "" + parse_data.qty + "" + + "" + parse_data.qty*parse_data.price + "" + + ""; + + $("#order-items-table").children("tbody").append(order_items_rows); + } + } + }); + // End AJAX Call + + $('.orders').removeClass('selected-item'); + $(this).addClass('selected-item'); + }); + + // Bill Request + $('#request_bills').click(function() { + var order_id=$(".selected-item").find(".orders-id").text(); + window.location.href = '/origami/request_bills/'+ order_id + return false; + }); + + // Payment for Bill + $('#pay').click(function() { + var sale_id=$(".selected-item").find(".orders-id").text(); + window.location.href = '/origami/sale/'+ sale_id + "/payment" + return false; + }); +}); + + + diff --git a/app/assets/stylesheets/orgiami.scss b/app/assets/stylesheets/orgiami.scss index afefe4c7..d94bc702 100644 --- a/app/assets/stylesheets/orgiami.scss +++ b/app/assets/stylesheets/orgiami.scss @@ -19,13 +19,45 @@ color:white; cursor:pointer; } + .cashier_number:hover{ background:#A9F5F2; } + .long{ width:100% } +.sold { + background-color: red; +} + +.selected-item { + background-color: blue; +} + +/* Reciept Style */ +#order-charges-table td { + border-top: none !important; +} + +.charges-name { + width: 80%; + text-align: left; +} + +.item-name { + width: 60%; + text-align: left; +} + +.item-attr { + width: 20%; + text-align: right; +} + + +/* Colors */ .purple { background-color:#7a62d3; } diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 480e9204..9733e488 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -7,16 +7,18 @@ class Origami::HomeController < BaseOrigamiController def show str = [] + type=params[:id].split('-')[0]; - - if !params[:sale_id].nil? - @order_details = SaleItem.get_order_items_details(params[:sale_id]) + # Sale + if type == "SAL" + @order_details = SaleItem.get_order_items_details(params[:id]) @order_details.each do |ord_detail| str.push(ord_detail) end render :json => str.to_json + # Booking else - @order_details = OrderItem.get_order_items_details(params[:order_id]) + @order_details = OrderItem.get_order_items_details(params[:id]) @order_details.each do |ord_detail| str.push(ord_detail) end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index de40bfd7..c5b87b6b 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,27 +1,29 @@ class Origami::RequestBillsController < BaseOrigamiController - def show - @sale = Sale.new + def print + @sale = Sale.new + sale_order=SaleOrder.new booking_id = params[:id] check_booking = Booking.find_by_booking_id(booking_id) if check_booking.sale_id.nil? - #check if it doesn't exist - @status = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee.name) - @sale_data = Sale.find_by_sale_id(check_booking.sale_id) - @sale_items = SaleItem.where("sale_id=?",check_booking.sale_id) + # Create Sale if it doesn't exist + @status, @sale_id = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee.name) + @sale_data = Sale.find_by_sale_id(@sale_id) + @sale_items = SaleItem.where("sale_id=?",@sale_id) else @sale_data = Sale.find_by_sale_id(check_booking.sale_id) - @sale_items = SaleItem.where("sale_id=?",check_booking.sale_id) + @sale_items = SaleItem.where("sale_id=?",@sale_id) end - unique_code="ReceiptBillPdf" + unique_code = "ReceiptBillPdf" + customer_name = Customer.select("name").where('customer_id=' + @sale_data.customer_id) print_settings=PrintSetting.find_by_unique_code(unique_code) - printer = Printer::ReceiptPrinter.new(print_settings) - - printer.print_receipt_bill(print_settings,@sale_items,@sale,@sale_data) - + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer_name) + redirect_to origami_root_path end + diff --git a/app/models/account.rb b/app/models/account.rb index ee768fb6..5d775b83 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -4,6 +4,6 @@ class Account < ApplicationRecord has_many :menu_items def self.collection - Account.select("id, title").map { |e| [e.title, e.id] } - end + Account.select("id, title").map { |e| [e.title, e.id] } + end end diff --git a/app/models/order.rb b/app/models/order.rb index 9807758c..dde46bc1 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -221,15 +221,13 @@ class Order < ApplicationRecord .group("orders.order_id, order_items.order_items_id,dining_facilities.name") end - def self.get_booking_order_table booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, - bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") - .joins("left join orders on orders.order_id = booking_orders.order_id") - .joins("left join sale_orders on sale_orders.order_id = orders.order_id") - .joins("left join sales on sales.sale_id = sale_orders.sale_id") + .joins("left join orders on orders.order_id = booking_orders.order_id") + .joins("left join sales on sales.sale_id = bookings.sale_id") .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status") @@ -237,7 +235,8 @@ class Order < ApplicationRecord #Origami: Cashier : to view order type Room def self.get_booking_order_rooms - booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as room_name") + booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id, + sales.sale_id as sale_id,dining_facilities.name as room_name") .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") .joins("left join orders on orders.order_id = booking_orders.order_id") @@ -250,7 +249,7 @@ class Order < ApplicationRecord #Origami: Cashier : to view order type Room def self.get_order_rooms order_rooms = Order.select("orders.order_id as order_id,sum(order_items.qty*order_items.price) as total_price, - order_items.id as order_items_id,dining_facilities.name as room_name") + order_items.id as order_items_id,dining_facilities.name as room_name") .joins("left join booking_orders on booking_orders.order_id = orders.order_id left join bookings on bookings.booking_id = booking_orders.order_id left join dining_facilities on dining_facilities.id = bookings.dining_facility_id @@ -264,7 +263,8 @@ class Order < ApplicationRecord def self.get_orders from = Time.now.beginning_of_day.utc to = Time.now.end_of_day.utc - orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status, + bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") .joins("left join booking_orders on booking_orders.order_id = orders.order_id left join bookings on bookings.booking_id = booking_orders.order_id left join dining_facilities on dining_facilities.id = bookings.dining_facility_id @@ -273,6 +273,10 @@ class Order < ApplicationRecord left join sales on sales.sale_id = sale_orders.sale_id") .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) .group("orders.order_id,order_items.order_items_id,dining_facilities.name,sales.receipt_no,bookings.booking_id,sales.sale_id") +<<<<<<< HEAD +======= + +>>>>>>> f9c8dbc03eee1b539ce04480b411b1d761e570f4 end private diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index b60d08ae..15138f74 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -64,12 +64,12 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker self.print(filename) end #Bill Receipt Print - def print_receipt_bill(printer_settings,sale_items,sale,sale_data) + def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name) #Use CUPS service #Generate PDF #Print - pdf = ReceiptBillPdf.new(printer_settings,sale_items,sale,sale_data) - pdf.render_file "tmp/receipt_bill.pdf" + pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name) + pdf.render_file "tmp/receipt_bill.pdf" self.print("tmp/receipt_bill.pdf") end diff --git a/app/models/sale.rb b/app/models/sale.rb index bd7e5668..1a9c9a28 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -35,7 +35,7 @@ class Sale < ApplicationRecord order = booking.booking_orders.take.order puts "add sale order" link_order_sale(order.id) - return status + return status, sale_id end end @@ -76,7 +76,8 @@ class Sale < ApplicationRecord self.save! - #compute summary + + #compute sales summary compute #Update the order items that is billed @@ -218,6 +219,7 @@ class Sale < ApplicationRecord private + def product_get_unit_price(item_code) menu_item_hash =MenuItem.search_by_item_code(item_code) if (menu_instance_code) diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 52ab480b..1ebd1632 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -12,17 +12,22 @@ class SaleItem < ApplicationRecord def self.get_order_items_details(sale_id) - sale_orders = SaleOrder.where("sale_id=?",sale_id) - if sale_orders - sale_orders.each do |sale_order| - order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price") - .joins("left join sales on sales.id = sale_items.sale_id") - .where("sale_items.sale_id=?",sale_order.sale_id) - return order_details - end - else - return false - end + order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date, + sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price") + .joins("left join sales on sales.sale_id = sale_items.sale_id") + .where("sale_items.sale_id=?",sale_id) + + # sale_orders = SaleOrder.where("sale_id=?",sale_id) + # if sale_orders + # sale_orders.each do |sale_order| + # order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price") + # .joins("left join sales on sales.id = sale_items.sale_id") + # .where("sale_items.sale_id=?",sale_order.sale_id) + # return order_details + # end + # else + # return false + # end end private diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index ffce7da2..5853b946 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -1,6 +1,6 @@ class ReceiptBillPdf < 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(printer_settings, sale_items,sale, sale_data) + def initialize(printer_settings, sale_items, sale_data, customer_name) self.p_width = 200 self.page_height = 1450 self.margin = 10 @@ -19,11 +19,11 @@ class ReceiptBillPdf < Prawn::Document #setting page margin and width super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.p_width, self.page_height]) self.header_font_size = 10 - self.item_font_size = 6 + self.item_font_size = 9 header( printer_settings.printer_name, printer_settings.name) stroke_horizontal_rule - cashier_info(sale.receipt_no,sale.customer, sale.receipt_date) + cashier_info(sale_data, customer_name) line_items(sale_items) all_total(sale_data) @@ -41,7 +41,7 @@ class ReceiptBillPdf < Prawn::Document end - def cashier_info(receipt_no, customer, receipt_date) + def cashier_info(sale_data, customer_name) move_down 5 move_down 2 y_position = cursor @@ -50,7 +50,7 @@ class ReceiptBillPdf < Prawn::Document end bounding_box([self.price_width, y_position], :width =>self.receipt_width) do - text "#{receipt_no}" , :size => self.item_font_size, :align => :left + text "#{sale_data.receipt_no}" , :size => self.item_font_size, :align => :left end move_down 5 @@ -59,7 +59,7 @@ class ReceiptBillPdf < Prawn::Document text "Customer:", :size => self.item_font_size,:align => :left end bounding_box([self.price_width,y_position], :width =>self.price_width) do - text "#{customer}" , :size => self.item_font_size,:align => :left + text "#{customer_name}" , :size => self.item_font_size,:align => :left end move_down 5 @@ -68,7 +68,7 @@ class ReceiptBillPdf < Prawn::Document text "Date:", :size => self.item_font_size,:align => :left end bounding_box([self.price_width,y_position], :width =>self.price_width) do - text "#{receipt_date}" , :size => self.item_font_size,:align => :left + text "#{sale_data.receipt_date.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left end # stroke_horizontal_rule move_down 5 @@ -139,7 +139,6 @@ class ReceiptBillPdf < Prawn::Document end def all_total(sale_data) - move_down 5 y_position =cursor diff --git a/app/views/api/bookings/show.json.jbuilder b/app/views/api/bookings/show.json.jbuilder index 27ec21b9..2e8708d3 100644 --- a/app/views/api/bookings/show.json.jbuilder +++ b/app/views/api/bookings/show.json.jbuilder @@ -1,7 +1,7 @@ if (@booking) json.id @booking.booking_id json.status @booking.booking_status - json.checkin_at @booking.checkin_at + json.checkin_at @booking.checkin_at.strftime("%d-%m-%Y") json.checkin_by @booking.checkin_by json.table_name @booking.dining_facility.name @@ -17,9 +17,9 @@ if (@booking) order_items = [] @booking.booking_orders.each do |bo| order = Order.find(bo.order_id) - if (order.status == "new") + #if (order.status == "new") order_items = order_items + order.order_items - end + #end end json.order_items order_items do |item| diff --git a/app/views/crm/home/_booking.html.erb b/app/views/crm/home/_booking.html.erb index afacb52e..91348459 100644 --- a/app/views/crm/home/_booking.html.erb +++ b/app/views/crm/home/_booking.html.erb @@ -44,6 +44,7 @@ $(function(){ $("#assign").removeAttr("disabled"); $("#crm_print").removeAttr("disabled"); $("#crm_print").attr('data',$(this).attr('data')); + var url = $(this).attr('data-ref'); show_details(url); }); diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 47d80f38..f2120cde 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -61,11 +61,8 @@

- + - <% end diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index ea53d676..bfde5890 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -1,6 +1,6 @@
+
- -
- +
+
- -
- - <% if @booking_orders %> - <% @booking_orders.each do |booking_order| %> - <% if booking_order.order_status != "new" %> -
-
-

- <%=booking_order.table_name%>

- Receipt No : <%=booking_order.receipt_no%>
- Order Status : <%=booking_order.order_status %> -
-
- <% else %> -
-
-

<%=booking_order.table_name%>

- Order Status : <%=booking_order.order_status %> -
-
- <% end %> - <%end %> - <%end %> +
+ <% + @booking_orders.each do |bko| + # Assigned Id for new Order? Sale? + unique_id="" + # For CSS- Class for Order? Sale? + sale_status="" + if bko.order_status == 'new' + unique_id=bko.booking_id + else + unique_id=bko.sale_id + sale_status="sold" + end + %> +
+
+ +

<%= bko.table_name %>

+

+ Receipt No : + + <%= bko.receipt_no %> + +

+

+ Order Status : + + <%= bko.order_status %> + + +

+
+
+ <% + end + %>
- - -
- -
- - <% if @booking_rooms %> - <% @booking_rooms.each do |booking_room| %> - <% if !booking_room.order_status = 'new'%> -
-
-

- <%=booking_room.room_name%>

- Receipt No : <%=booking_room.receipt_no%>
- Order Status : <%=booking_room.order_status %> -
-
- <% else %> -
-
-

<%=booking_room.room_name%>ddd

\ - Order Status : <%=booking_room.order_status %> -
-
- <% end %> - <%end %> - <%end %> + +
+
+ <% + @booking_rooms.each do |rmo| + # Assigned Id for new Order? Sale? + unique_id="" + # For CSS- Class for Order? Sale? + sale_status="" + if rmo.order_status == 'new' + unique_id=rmo.booking_id + else + unique_id=rmo.sale_id + sale_status="sold" + end + %> +
+
+ +

<%= rmo.room_name %>

+

+ Receipt No : + + <%= rmo.receipt_no %> + +

+

+ Order Status : + + <%= rmo.order_status %> + + +

+
+
+ <% + end + %>
- -
- - -
- - -
- - <% if @orders %> - <% @orders.each do |order| %> - <% if !order.order_status = 'new'%> -
-
-

- Order No:<%=order.order_id%>

- Receipt No : <%=order.receipt_no%>
- Order Status : <%=order.order_status %> -
-
- <% else %> -
-
-

Order No:<%=order.order_id%>

- Order Status : <%=order.order_status %> -
-
- <% end %> - <%end %> - <%end %> - + +
+
+ <% + @orders.each do |odr| + # Assigned Id for new Order? Sale? + unique_id="" + # For CSS- Class for Order? Sale? + sale_status="" + if odr.order_status == 'new' + unique_id=odr.booking_id + else + unique_id=odr.sale_id + sale_status="sold" + end + %> +
+
+ +

<%= odr.table_name %>

+

+ Receipt No : + + <%= odr.receipt_no %> + +

+

+ Order Status : + + <%= odr.order_status %> + + +

+
+
+ <% + end + %>
- - +
-
- - - +
+ + -
-
-
-
ORDER DETAILS -

-
-
-
-
- - +
+
+
+
ORDER DETAILS -
+
+
+
+
+

Receipt No:

+

Cashier:

+
+
+

Date:

+
+
+
+
+ + + + + + + + +
ItemsQTY + Price +
+
+ -
- - - - - - - - - -
- - - - - -
-
-
+
+
-
-
-
- +
- - + - - - + + +
+ + diff --git a/config/routes.rb b/config/routes.rb index 3e8826c5..680ffb22 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -72,6 +72,9 @@ Rails.application.routes.draw do resources :customers, only: [:index,:new, :create ] #add customer type end + + get "/request_bills/:id" => "request_bills#print" + get 'sale/:sale_id/payment' => 'payments#show' post 'payment_process' => 'payments#create' diff --git a/db/migrate/20170324135138_create_zones.rb b/db/migrate/20170324135138_create_zones.rb index 30a92048..00139170 100644 --- a/db/migrate/20170324135138_create_zones.rb +++ b/db/migrate/20170324135138_create_zones.rb @@ -1,4 +1,4 @@ -class CreateZones < ActiveRecord::Migration[5.0] +class CreateZones < ActiveRecord::Migration[5.1] def change create_table :zones do |t| t.string :name, :null => false diff --git a/db/migrate/20170325111608_create_menus.rb b/db/migrate/20170325111608_create_menus.rb index a542de50..84efdf2d 100644 --- a/db/migrate/20170325111608_create_menus.rb +++ b/db/migrate/20170325111608_create_menus.rb @@ -1,4 +1,4 @@ -class CreateMenus < ActiveRecord::Migration[5.0] +class CreateMenus < ActiveRecord::Migration[5.1] def change create_table :menus do |t| t.string :name diff --git a/db/migrate/20170327152733_create_menu_categories.rb b/db/migrate/20170327152733_create_menu_categories.rb index 9315e61e..59e3a8c9 100644 --- a/db/migrate/20170327152733_create_menu_categories.rb +++ b/db/migrate/20170327152733_create_menu_categories.rb @@ -1,4 +1,4 @@ -class CreateMenuCategories < ActiveRecord::Migration[5.0] +class CreateMenuCategories < ActiveRecord::Migration[5.1] def change create_table :menu_categories do |t| t.references :menu, foreign_key: true diff --git a/db/migrate/20170331024749_create_menu_items.rb b/db/migrate/20170331024749_create_menu_items.rb index 81baa5ab..a67156c5 100644 --- a/db/migrate/20170331024749_create_menu_items.rb +++ b/db/migrate/20170331024749_create_menu_items.rb @@ -1,4 +1,4 @@ -class CreateMenuItems < ActiveRecord::Migration[5.0] +class CreateMenuItems < ActiveRecord::Migration[5.1] def change create_table :menu_items do |t| t.string :item_code, :null => false diff --git a/db/migrate/20170402083337_create_menu_item_attributes.rb b/db/migrate/20170402083337_create_menu_item_attributes.rb index b2c3b0fd..302202a6 100644 --- a/db/migrate/20170402083337_create_menu_item_attributes.rb +++ b/db/migrate/20170402083337_create_menu_item_attributes.rb @@ -1,4 +1,4 @@ -class CreateMenuItemAttributes < ActiveRecord::Migration[5.0] +class CreateMenuItemAttributes < ActiveRecord::Migration[5.1] def change create_table :menu_item_attributes do |t| t.string :attribute_type, :null => false diff --git a/db/migrate/20170402083525_create_menu_item_options.rb b/db/migrate/20170402083525_create_menu_item_options.rb index a9e9734a..841b66a0 100644 --- a/db/migrate/20170402083525_create_menu_item_options.rb +++ b/db/migrate/20170402083525_create_menu_item_options.rb @@ -1,4 +1,4 @@ -class CreateMenuItemOptions < ActiveRecord::Migration[5.0] +class CreateMenuItemOptions < ActiveRecord::Migration[5.1] def change create_table :menu_item_options do |t| t.string :name, :null => false diff --git a/db/migrate/20170402084230_create_menu_item_instances.rb b/db/migrate/20170402084230_create_menu_item_instances.rb index d5effcbf..c79cb322 100644 --- a/db/migrate/20170402084230_create_menu_item_instances.rb +++ b/db/migrate/20170402084230_create_menu_item_instances.rb @@ -1,4 +1,4 @@ -class CreateMenuItemInstances < ActiveRecord::Migration[5.0] +class CreateMenuItemInstances < ActiveRecord::Migration[5.1] def change create_table :menu_item_instances do |t| t.references :menu_item, :foreign_key => true, :null => false diff --git a/db/migrate/20170403135121_create_customers.rb b/db/migrate/20170403135121_create_customers.rb index 8094f035..318e7bf1 100644 --- a/db/migrate/20170403135121_create_customers.rb +++ b/db/migrate/20170403135121_create_customers.rb @@ -1,10 +1,10 @@ -class CreateCustomers < ActiveRecord::Migration[5.0] +class CreateCustomers < ActiveRecord::Migration[5.1] def change 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 + t.string :contact_no, :unique => true t.string :email t.date :date_of_birth t.string :membership_id diff --git a/db/migrate/20170403135934_create_orders.rb b/db/migrate/20170403135934_create_orders.rb index a80e2760..4439bdba 100644 --- a/db/migrate/20170403135934_create_orders.rb +++ b/db/migrate/20170403135934_create_orders.rb @@ -1,4 +1,4 @@ -class CreateOrders < ActiveRecord::Migration[5.0] +class CreateOrders < ActiveRecord::Migration[5.1] def change create_table :orders, :id => false do |t| t.string :order_id, :limit => 16, :primary_key => true #custom foreign_key to prevent conflict during sync diff --git a/db/migrate/20170403140820_create_order_items.rb b/db/migrate/20170403140820_create_order_items.rb index 32760907..b0f43c32 100644 --- a/db/migrate/20170403140820_create_order_items.rb +++ b/db/migrate/20170403140820_create_order_items.rb @@ -1,4 +1,4 @@ -class CreateOrderItems < ActiveRecord::Migration[5.0] +class CreateOrderItems < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170403142424_create_dining_facilities.rb b/db/migrate/20170403142424_create_dining_facilities.rb index 788747d8..599151c6 100644 --- a/db/migrate/20170403142424_create_dining_facilities.rb +++ b/db/migrate/20170403142424_create_dining_facilities.rb @@ -1,4 +1,4 @@ -class CreateDiningFacilities < ActiveRecord::Migration[5.0] +class CreateDiningFacilities < ActiveRecord::Migration[5.1] def change create_table :dining_facilities do |t| t.references :zone, foreign_key: true diff --git a/db/migrate/20170403151731_create_order_queue_stations.rb b/db/migrate/20170403151731_create_order_queue_stations.rb index f5c84269..6ad93bb1 100644 --- a/db/migrate/20170403151731_create_order_queue_stations.rb +++ b/db/migrate/20170403151731_create_order_queue_stations.rb @@ -1,4 +1,4 @@ -class CreateOrderQueueStations < ActiveRecord::Migration[5.0] +class CreateOrderQueueStations < ActiveRecord::Migration[5.1] def change create_table :order_queue_stations do |t| t.string :station_name, :null => false diff --git a/db/migrate/20170403152600_create_order_queue_process_by_zones.rb b/db/migrate/20170403152600_create_order_queue_process_by_zones.rb index d6b7d207..8f0ee73c 100644 --- a/db/migrate/20170403152600_create_order_queue_process_by_zones.rb +++ b/db/migrate/20170403152600_create_order_queue_process_by_zones.rb @@ -1,4 +1,4 @@ -class CreateOrderQueueProcessByZones < ActiveRecord::Migration[5.0] +class CreateOrderQueueProcessByZones < ActiveRecord::Migration[5.1] def change create_table :order_queue_process_by_zones do |t| t.references :order_queue_station, :null => false diff --git a/db/migrate/20170403153001_create_payment_method_settings.rb b/db/migrate/20170403153001_create_payment_method_settings.rb index 2fea9098..981d42d3 100644 --- a/db/migrate/20170403153001_create_payment_method_settings.rb +++ b/db/migrate/20170403153001_create_payment_method_settings.rb @@ -1,4 +1,4 @@ -class CreatePaymentMethodSettings < ActiveRecord::Migration[5.0] +class CreatePaymentMethodSettings < ActiveRecord::Migration[5.1] def change create_table :payment_method_settings do |t| t.string :payment_method, :null => false diff --git a/db/migrate/20170403155230_create_employees.rb b/db/migrate/20170403155230_create_employees.rb index a283ec95..c4bf65ac 100644 --- a/db/migrate/20170403155230_create_employees.rb +++ b/db/migrate/20170403155230_create_employees.rb @@ -1,4 +1,4 @@ -class CreateEmployees < ActiveRecord::Migration[5.0] +class CreateEmployees < ActiveRecord::Migration[5.1] def change create_table :employees do |t| t.string :name, :null => false diff --git a/db/migrate/20170403155500_create_cashier_terminals.rb b/db/migrate/20170403155500_create_cashier_terminals.rb index dc5a5eb5..274c7914 100644 --- a/db/migrate/20170403155500_create_cashier_terminals.rb +++ b/db/migrate/20170403155500_create_cashier_terminals.rb @@ -1,4 +1,4 @@ -class CreateCashierTerminals < ActiveRecord::Migration[5.0] +class CreateCashierTerminals < ActiveRecord::Migration[5.1] def change create_table :cashier_terminals do |t| t.string :name, :null => false diff --git a/db/migrate/20170403155531_create_cashier_login_logs.rb b/db/migrate/20170403155531_create_cashier_login_logs.rb index 176c5cae..0887f3bd 100644 --- a/db/migrate/20170403155531_create_cashier_login_logs.rb +++ b/db/migrate/20170403155531_create_cashier_login_logs.rb @@ -1,4 +1,4 @@ -class CreateCashierLoginLogs < ActiveRecord::Migration[5.0] +class CreateCashierLoginLogs < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170403160742_create_sales.rb b/db/migrate/20170403160742_create_sales.rb index c2bb718a..7e4850f1 100644 --- a/db/migrate/20170403160742_create_sales.rb +++ b/db/migrate/20170403160742_create_sales.rb @@ -1,4 +1,4 @@ -class CreateSales < ActiveRecord::Migration[5.0] +class CreateSales < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170403161857_create_sale_items.rb b/db/migrate/20170403161857_create_sale_items.rb index aaf1dac3..cb07db08 100644 --- a/db/migrate/20170403161857_create_sale_items.rb +++ b/db/migrate/20170403161857_create_sale_items.rb @@ -1,4 +1,4 @@ -class CreateSaleItems < ActiveRecord::Migration[5.0] +class CreateSaleItems < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170403163219_create_sale_taxes.rb b/db/migrate/20170403163219_create_sale_taxes.rb index 3d28381a..ef52c9dc 100644 --- a/db/migrate/20170403163219_create_sale_taxes.rb +++ b/db/migrate/20170403163219_create_sale_taxes.rb @@ -1,4 +1,4 @@ -class CreateSaleTaxes < ActiveRecord::Migration[5.0] +class CreateSaleTaxes < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170403163734_create_sale_payments.rb b/db/migrate/20170403163734_create_sale_payments.rb index 3badca93..0e2f308a 100644 --- a/db/migrate/20170403163734_create_sale_payments.rb +++ b/db/migrate/20170403163734_create_sale_payments.rb @@ -1,4 +1,4 @@ -class CreateSalePayments < ActiveRecord::Migration[5.0] +class CreateSalePayments < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170403174029_create_sale_orders.rb b/db/migrate/20170403174029_create_sale_orders.rb index 3da13e60..e2b3fe40 100644 --- a/db/migrate/20170403174029_create_sale_orders.rb +++ b/db/migrate/20170403174029_create_sale_orders.rb @@ -1,4 +1,4 @@ -class CreateSaleOrders < ActiveRecord::Migration[5.0] +class CreateSaleOrders < ActiveRecord::Migration[5.1] def change create_table :sale_orders, :id => false do |t| t.primary_key :sale_order_id #custom primary key - to ensure consistence for cloud syncing diff --git a/db/migrate/20170403174111_create_sale_audits.rb b/db/migrate/20170403174111_create_sale_audits.rb index e8197c4b..e1dcfffd 100644 --- a/db/migrate/20170403174111_create_sale_audits.rb +++ b/db/migrate/20170403174111_create_sale_audits.rb @@ -1,4 +1,4 @@ -class CreateSaleAudits < ActiveRecord::Migration[5.0] +class CreateSaleAudits < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170403174309_create_lookups.rb b/db/migrate/20170403174309_create_lookups.rb index a825cc8f..2fbd3fa7 100644 --- a/db/migrate/20170403174309_create_lookups.rb +++ b/db/migrate/20170403174309_create_lookups.rb @@ -1,4 +1,4 @@ -class CreateLookups < ActiveRecord::Migration[5.0] +class CreateLookups < ActiveRecord::Migration[5.1] def change create_table :lookups do |t| t.string :lookup_type, :null => false diff --git a/db/migrate/20170403183755_create_tax_profiles.rb b/db/migrate/20170403183755_create_tax_profiles.rb index 7f9893d5..1f9dfceb 100644 --- a/db/migrate/20170403183755_create_tax_profiles.rb +++ b/db/migrate/20170403183755_create_tax_profiles.rb @@ -1,4 +1,4 @@ -class CreateTaxProfiles < ActiveRecord::Migration[5.0] +class CreateTaxProfiles < ActiveRecord::Migration[5.1] def change create_table :tax_profiles do |t| t.string :name, :null => false diff --git a/db/migrate/20170404034234_create_bookings.rb b/db/migrate/20170404034234_create_bookings.rb index f41e8fb4..89795a83 100644 --- a/db/migrate/20170404034234_create_bookings.rb +++ b/db/migrate/20170404034234_create_bookings.rb @@ -1,4 +1,4 @@ -class CreateBookings < ActiveRecord::Migration[5.0] +class CreateBookings < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170408105938_create_seed_generators.rb b/db/migrate/20170408105938_create_seed_generators.rb index eb58749a..14e62fe1 100644 --- a/db/migrate/20170408105938_create_seed_generators.rb +++ b/db/migrate/20170408105938_create_seed_generators.rb @@ -1,4 +1,4 @@ -class CreateSeedGenerators < ActiveRecord::Migration[5.0] +class CreateSeedGenerators < ActiveRecord::Migration[5.1] def change create_table :seed_generators do |t| t.string :model, :null => false, :default => "sale" diff --git a/db/migrate/20170414071634_create_membership_settings.rb b/db/migrate/20170414071634_create_membership_settings.rb index e15bf082..fca5cce4 100644 --- a/db/migrate/20170414071634_create_membership_settings.rb +++ b/db/migrate/20170414071634_create_membership_settings.rb @@ -1,4 +1,4 @@ -class CreateMembershipSettings < ActiveRecord::Migration[5.0] +class CreateMembershipSettings < ActiveRecord::Migration[5.1] def change create_table :membership_settings do |t| t.string :membership_type, :null => false, :default => "internal" diff --git a/db/migrate/20170414090001_create_assigned_order_items.rb b/db/migrate/20170414090001_create_assigned_order_items.rb index 02b95017..3eaf58cf 100644 --- a/db/migrate/20170414090001_create_assigned_order_items.rb +++ b/db/migrate/20170414090001_create_assigned_order_items.rb @@ -1,4 +1,4 @@ -class CreateAssignedOrderItems < ActiveRecord::Migration[5.0] +class CreateAssignedOrderItems < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170414110918_create_booking_orders.rb b/db/migrate/20170414110918_create_booking_orders.rb index e9bf7cc0..25e24b43 100644 --- a/db/migrate/20170414110918_create_booking_orders.rb +++ b/db/migrate/20170414110918_create_booking_orders.rb @@ -1,4 +1,4 @@ -class CreateBookingOrders < ActiveRecord::Migration[5.0] +class CreateBookingOrders < ActiveRecord::Migration[5.1] def change 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 diff --git a/db/migrate/20170421171849_add_company_address_email.rb b/db/migrate/20170421171849_add_company_address_email.rb index fb0e81f1..81667406 100644 --- a/db/migrate/20170421171849_add_company_address_email.rb +++ b/db/migrate/20170421171849_add_company_address_email.rb @@ -1,4 +1,4 @@ -class AddCompanyAddressEmail < ActiveRecord::Migration[5.0] +class AddCompanyAddressEmail < ActiveRecord::Migration[5.1] def change end end diff --git a/db/migrate/20170507045043_order_items_completed_by.rb b/db/migrate/20170507045043_order_items_completed_by.rb index a00fdbb4..c6c791c0 100644 --- a/db/migrate/20170507045043_order_items_completed_by.rb +++ b/db/migrate/20170507045043_order_items_completed_by.rb @@ -1,4 +1,4 @@ -class OrderItemsCompletedBy < ActiveRecord::Migration[5.0] +class OrderItemsCompletedBy < ActiveRecord::Migration[5.1] def change add_column :order_items, :completed_by, :string add_column :order_items, :completed_at, :datetime diff --git a/db/migrate/20170530072247_create_shops.rb b/db/migrate/20170530072247_create_shops.rb index 25de6c6a..4f07d5c4 100644 --- a/db/migrate/20170530072247_create_shops.rb +++ b/db/migrate/20170530072247_create_shops.rb @@ -9,7 +9,7 @@ class CreateShops < ActiveRecord::Migration[5.1] t.string :state, :null => false t.string :country, :null => false t.string :phone_no, :null => false - t.string :reserviation_no, :null => false + t.string :reservation_no, :null => false t.string :license, :null => false t.datetime :activated_at, :null => false t.text :license_data, :null => false diff --git a/db/seeds.rb b/db/seeds.rb index 02fa39fb..fd9a9e96 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -75,9 +75,8 @@ account_type = Lookup.create([{lookup_type:'account_type', name: 'Income', value {lookup_type:'account_type', name: 'Expense', value: 'expense'}]) #WALK CUSTOMER - Default CUSTOMER (take key 1) -customer = Customer.create({id:1, name:"WALK-IN", contact_no:"000000000"}) -customer = Customer.create({id:2, name:"TAKEAWAY", contact_no:"000000000"}) - +customer = Customer.create({name:"WALK-IN", email: "cus1@customer.com", contact_no:"000000000"}) +customer2 = Customer.create({name:"TAKEAWAY", email: "cus2@customer.com", contact_no:"111111111"}) #Default ZOne zone = Zone.create({id:1, name: "Default Zone", is_active:true, created_by: "SYSTEM DEFAULT"}) @@ -136,3 +135,14 @@ 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"}) + +shop = Shop.create( + {name: "Beauty In The Pot", address: "address", township: "Yangon", city: "Yangon", state: "Yangon", + country: "Myanmar", phone_no: "09123456789", reservation_no: "bip000001", license: "license", + activated_at: "2017-06-06", license_data: "license_data", base_currency: "Ks", id_prefix: "abc"} + ) +