From bd1414e07fa8f950e6f916d00627ce73d4e0fe79 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sat, 3 Jun 2017 10:59:46 +0630 Subject: [PATCH 01/18] Gemfile and gem lock --- Gemfile | 4 ++-- Gemfile.lock | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index 7668adad..08464196 100644 --- a/Gemfile +++ b/Gemfile @@ -9,10 +9,10 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 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' +#gem 'pg' # redis server for cable gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 24527519..79a0d2f8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -114,11 +114,11 @@ GEM mini_portile2 (2.1.0) minitest (5.10.2) multi_json (1.12.1) + mysql2 (0.4.6) nio4r (2.1.0) 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) @@ -251,7 +251,7 @@ DEPENDENCIES jquery-rails kaminari! listen (~> 3.0.5) - pg + mysql2 (>= 0.3.18, < 0.5) prawn prawn-table puma (~> 3.0) From 324f1e3b24f547493bd9504f164ccc5369b52d10 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 6 Jun 2017 10:10:47 +0630 Subject: [PATCH 02/18] update query in order model for origami --- Gemfile.lock | 2 -- app/models/order.rb | 18 +++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index bd6f0991..7bf4f9a4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -116,9 +116,7 @@ GEM mini_portile2 (2.1.0) 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) diff --git a/app/models/order.rb b/app/models/order.rb index 3fabf91b..497fdd9b 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -211,15 +211,15 @@ class Order < ApplicationRecord #Origami: Cashier : to view order type Table def self.get_order_table - order_table = Order.select("orders.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 table_name") - .joins("left join booking_orders on booking_orders.order_id = orders.id - left join bookings on bookings.id = booking_orders.id + order_table = Order.select("orders.order_id as order_id,sum(order_items.qty*order_items.price) as total_price, + order_items.order_items_id as order_items_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.booking_order_id left join dining_facilities on dining_facilities.id = bookings.dining_facility_id - left join order_items on order_items.order_id = orders.id") + left join order_items on order_items.order_id = orders.order_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") + .group("orders.order_id, order_items.id,dining_facilities.name") + end def self.get_booking_order_table @@ -270,8 +270,7 @@ class Order < ApplicationRecord left join sale_orders on sale_orders.order_id = orders.order_id 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.id,order_items.id,dining_facilities.name") + .group("orders.order_id,order_items.order_items_id,dining_facilities.name") end @@ -285,4 +284,5 @@ class Order < ApplicationRecord def set_order_date self.date = Time.now.utc end + end From 231eec6a01c8b9e33529ce2e9548fa5b300690f3 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Tue, 6 Jun 2017 10:50:51 +0630 Subject: [PATCH 03/18] Payment delete bug fix --- app/views/settings/menu_item_options/show.html.erb | 3 +-- app/views/settings/payment_method_settings/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/views/settings/menu_item_options/show.html.erb b/app/views/settings/menu_item_options/show.html.erb index fdcb9d09..611f3165 100644 --- a/app/views/settings/menu_item_options/show.html.erb +++ b/app/views/settings/menu_item_options/show.html.erb @@ -2,8 +2,7 @@ diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 5a29b74c..d866d47d 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -1,41 +1,110 @@ -

<%= notice %>

+
+ +
+
-

Crm Customers

+
+
+ +
+
+ + + + + + + + + + -
NameCompanyContact noEmail
- - - - - - - - - - - - - + + <% @crm_customers.each do |crm_customer| %> + + + + + + + + <% end %> + +
NameCompanyContact noEmailDate of birthMembershipMembership typeMembership authentication code
<%= crm_customer.name %><%= crm_customer.company %><%= crm_customer.contact_no %><%= crm_customer.email %>
+
+
- - <% @crm_customers.each do |crm_customer| %> - - <%= crm_customer.name %> - <%= crm_customer.company %> - <%= crm_customer.contact_no %> - <%= crm_customer.email %> - <%= crm_customer.date_of_birth %> - <%= crm_customer.membership_id %> - <%= crm_customer.membership_type %> - <%= crm_customer.membership_authentication_code %> - <%= link_to 'Show', crm_customer_path(crm_customer) %> - <%= link_to 'Edit', edit_crm_customer_path(crm_customer) %> - <%= link_to 'Destroy', crm_customer_path(crm_customer), method: :delete, data: { confirm: 'Are you sure?' } %> - - <% end %> - - +
-
+
+ <%= simple_form_for crm_customers_path, :html => { :class => 'form-horizontal' } do |f| %> + +
+ <%= f.input :name, :class => "form-control col-md-6" %> +
+
+ <%= f.input :company, :class => "form-control col-md-6" %> +
+
+ <%= f.input :contact_no, :class => "form-control col-md-6" %> +
+
+ <%= f.input :email, :class => "form-control col-md-6" %> +
-<%= link_to 'New Crm Customer', new_crm_customer_path %> +
+ + <%= f.text_field :date_of_birth,:class=>"form-control datepicker",:readonly =>true, :value => @date_of_birth%> + +
+ +
+ <%= f.select :membership_id, options_for_select(@membership.collect { |member| + [member["id"].name.titleize, member["id"].id] }, 1), {}, { id: 'countries_select' } %> + +
+ + +
+ <%= f.input :membership_type, :class => "form-control col-md-6" %> +
+
+ <%= f.input :membership_authentication_code, :class => "form-control col-md-6" %> + +
+
+ <%= f.button :submit, "Submit", :class => 'btn btn-primary' , :id => 'submit_account' %> +
+ <%end%> +
+
+ + From 2abc2e5f3df781f1e28b0e7c9003f6905f35ac8e Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Tue, 6 Jun 2017 14:33:14 +0630 Subject: [PATCH 05/18] Assign Order Item Bug ix --- .../settings/processing_items/_form.html.erb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/views/settings/processing_items/_form.html.erb b/app/views/settings/processing_items/_form.html.erb index 60e493d8..61ee6438 100644 --- a/app/views/settings/processing_items/_form.html.erb +++ b/app/views/settings/processing_items/_form.html.erb @@ -20,9 +20,18 @@ From d28449a9c9f7249aea22208daab8074db7b09180 Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 6 Jun 2017 14:34:24 +0630 Subject: [PATCH 06/18] updated for bill print --- app/controllers/origami/request_bills_controller.rb | 10 +--------- app/models/printer/receipt_printer.rb | 2 +- db/seeds.rb | 6 ++++++ 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 3fd7ffea..152f0fb0 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,6 +1,6 @@ class Origami::RequestBillsController < BaseOrigamiController - def create + def show @sale = Sale.new @@ -26,12 +26,4 @@ class Origami::RequestBillsController < BaseOrigamiController end - - def show - sale_id = params[:sale_id] - if Sale.exists?(sale_id) - @sale_data = Sale.find_by_id(sale_id) - end - end - end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 86d43190..93ab277c 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -69,7 +69,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker #Generate PDF #Print pdf = ReceiptBillPdf.new(printer_settings,sale_items,sale,sale_data) - pdf.render_file "tmp/receipt_bill.pdf" + pdf.render_file "tmp/receipt_bill.pdf" self.print("tmp/receipt_bill.pdf") end end diff --git a/db/seeds.rb b/db/seeds.rb index 4d7799db..6ba7d6b2 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -137,3 +137,9 @@ admin_employee = Employee.create({name: "Administrator", role: "Administrator", #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"} + ) From fbf312f71c7c834494736a194587c3546927f0ec Mon Sep 17 00:00:00 2001 From: Yan Date: Tue, 6 Jun 2017 17:01:15 +0630 Subject: [PATCH 07/18] change show to print method in req bills controller --- app/controllers/origami/request_bills_controller.rb | 2 +- app/pdf/receipt_bill_pdf.rb | 2 +- config/routes.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 7906c854..cb2f1b83 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,6 +1,6 @@ class Origami::RequestBillsController < BaseOrigamiController - def show + def print @sale = Sale.new booking_id = params[:id] diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index cc0f44de..5853b946 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -19,7 +19,7 @@ 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 diff --git a/config/routes.rb b/config/routes.rb index df652e6b..42813ed8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -72,8 +72,8 @@ Rails.application.routes.draw do resources :discounts, only: [:index,:new, :create ] #add discount type resources :customers, only: [:index,:new, :create ] #add customer type end - resources :request_bills, only: [:show] - get 'sale/:sale_id/payment' => 'request_bills#show' + resources :request_bills, only: [:print] + get 'sale/:sale_id/payment' => 'request_bills#print' end #--------- Waiter/Ordering Station ------------# From 59434e2c3a6b10ae7e5fa66136621a8e14d40e31 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Tue, 6 Jun 2017 17:29:34 +0630 Subject: [PATCH 08/18] Menu item with Accout --- .../settings/set_menu_items_controller.rb | 2 +- .../settings/simple_menu_items_controller.rb | 2 +- app/models/account.rb | 4 +++- app/models/menu_item.rb | 3 ++- .../settings/set_menu_items/_form.html.erb | 1 + .../settings/set_menu_items/show.html.erb | 2 ++ .../settings/simple_menu_items/_form.html.erb | 1 + .../settings/simple_menu_items/show.html.erb | 2 ++ ...ts.rb => 20170331024747_create_accounts.rb} | 0 db/migrate/20170331024749_create_menu_items.rb | 1 + db/seeds.rb | 18 +++++++++++------- 11 files changed, 25 insertions(+), 11 deletions(-) rename db/migrate/{20170602101727_create_accounts.rb => 20170331024747_create_accounts.rb} (100%) diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index 1c3e2247..5946ff49 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -81,6 +81,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, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) + params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) end end diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index b02310dc..05952d0d 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -78,6 +78,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, :menu_category_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) + params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) end end diff --git a/app/models/account.rb b/app/models/account.rb index e1cdc6d3..a950865c 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -3,5 +3,7 @@ class Account < ApplicationRecord has_many :menu_items # belongs_to :lookup , :class_name => "Lookup" - + def self.collection + Account.select("id, title").map { |e| [e.title, e.id] } + end end diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 22ec36de..9ff40ae2 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -1,9 +1,10 @@ class MenuItem < ApplicationRecord - # 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 has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id" + belongs_to :account validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item diff --git a/app/views/settings/set_menu_items/_form.html.erb b/app/views/settings/set_menu_items/_form.html.erb index bdf0e97e..aeae0f5c 100644 --- a/app/views/settings/set_menu_items/_form.html.erb +++ b/app/views/settings/set_menu_items/_form.html.erb @@ -6,6 +6,7 @@ <%= f.input :name %> <%= f.input :alt_name %> <%= f.input :type %> + <%= f.input :account_id, :label => "Account type", :collection => Account.collection %> <%= f.input :menu_item_id, :label => "Parent Menu Item", :collection => MenuItem.collection %> <%= f.input :min_qty %> diff --git a/app/views/settings/set_menu_items/show.html.erb b/app/views/settings/set_menu_items/show.html.erb index 0082c819..ba23771f 100644 --- a/app/views/settings/set_menu_items/show.html.erb +++ b/app/views/settings/set_menu_items/show.html.erb @@ -19,6 +19,7 @@ Name Alt name Type + Account Type Menu category Menu item Min qty @@ -35,6 +36,7 @@ <%= @settings_menu_item.name rescue "-" %> <%= @settings_menu_item.alt_name %> <%= @settings_menu_item.type %> + <%= @settings_menu_item.account.title %> <%= @settings_menu_item.menu_category_id %> <%= @settings_menu_item.menu_item_id %> <%= @settings_menu_item.min_qty %> diff --git a/app/views/settings/simple_menu_items/_form.html.erb b/app/views/settings/simple_menu_items/_form.html.erb index 885f725e..01c5b482 100644 --- a/app/views/settings/simple_menu_items/_form.html.erb +++ b/app/views/settings/simple_menu_items/_form.html.erb @@ -6,6 +6,7 @@ <%= f.input :name %> <%= f.input :alt_name %> <%= f.input :type %> + <%= f.input :account_id, :label => "Account type", :collection => Account.collection %> <%= f.input :menu_item_id, :label => "Parent Menu Item", :collection => MenuItem.collection %> <%= f.input :min_qty %> <%= f.input :min_selectable_item %> diff --git a/app/views/settings/simple_menu_items/show.html.erb b/app/views/settings/simple_menu_items/show.html.erb index d2d93e0e..11620acd 100644 --- a/app/views/settings/simple_menu_items/show.html.erb +++ b/app/views/settings/simple_menu_items/show.html.erb @@ -21,6 +21,7 @@ Name Alt name Type + Accout Menu category Menu item Min qty @@ -37,6 +38,7 @@ <%= @settings_menu_item.name rescue "-" %> <%= @settings_menu_item.alt_name %> <%= @settings_menu_item.type %> + <%= @settings_menu_item.account.title %> <%= @settings_menu_item.menu_category_id %> <%= @settings_menu_item.menu_item_id %> <%= @settings_menu_item.min_qty %> diff --git a/db/migrate/20170602101727_create_accounts.rb b/db/migrate/20170331024747_create_accounts.rb similarity index 100% rename from db/migrate/20170602101727_create_accounts.rb rename to db/migrate/20170331024747_create_accounts.rb diff --git a/db/migrate/20170331024749_create_menu_items.rb b/db/migrate/20170331024749_create_menu_items.rb index f61a9172..81baa5ab 100644 --- a/db/migrate/20170331024749_create_menu_items.rb +++ b/db/migrate/20170331024749_create_menu_items.rb @@ -10,6 +10,7 @@ class CreateMenuItems < ActiveRecord::Migration[5.0] t.string :type, :null => false, :default => "SimpleMenuItem" t.references :menu_category, foreign_key: true t.references :menu_item, foreign_key: true + t.references :account, foreign_key: true t.integer :min_qty, :null => false, :default => 1 t.boolean :taxable, :null => false, :default => true t.integer :min_selectable_item, :null => false, :default => 1 diff --git a/db/seeds.rb b/db/seeds.rb index 5e4dd995..aefa396c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -74,6 +74,10 @@ booking_status = Lookup.create([{lookup_type:'booking_status', name: 'Available' account_type = Lookup.create([{lookup_type:'account_type', name: 'Income', value: 'income'}, {lookup_type:'account_type', name: 'Expense', value: 'expense'}]) +#Account for Menu Item Type (eg: Food, Beverage) +food = Account.create({title: "Food", account_type: "0"}) +beverage = Account.create({title: "Beverage", account_type: "1"}) + #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"}) @@ -104,17 +108,17 @@ menu_category3 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Men menu_category4 = MenuCategory.create({menu: menu, code:"C006", name: "Sample Menu Category 4", alt_name: "Sample Alternate Category 4", order_by: 1, menu_category_id: menu_category3.id, created_by: "SYSTEM DEFAULT"}) #Default Menu items -menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 }) +menu_category1_menu_item0 = SimpleMenuItem.create({item_code:"01001", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"half portion",item_instance_code:"01001-1", menu_item: menu_category1_menu_item0, price:12.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"full portion",item_instance_code:"01001-2", menu_item: menu_category1_menu_item0, price:18.00, is_on_promotion:false}]) -menu_category1_menu_item1 = SetMenuItem.create({item_code:"I004", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 }) -menu_category1_menu_item2 = SetMenuItem.create({item_code:"I005", name: "Default Menu Item Name 2",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 2", min_selectable_item: 1, max_selectable_item:1 }) -menu_category1_menu_item3 = SetMenuItem.create({item_code:"I006", name: "Default Menu Item Name 3",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 3", min_selectable_item: 1, max_selectable_item:1 }) +menu_category1_menu_item1 = SetMenuItem.create({item_code:"I004", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category1 , min_selectable_item: 1, max_selectable_item:1 , account: food}) +menu_category1_menu_item2 = SetMenuItem.create({item_code:"I005", name: "Default Menu Item Name 2",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 2", min_selectable_item: 1, max_selectable_item:1 , account: food}) +menu_category1_menu_item3 = SetMenuItem.create({item_code:"I006", name: "Default Menu Item Name 3",parent: menu_category1_menu_item1, alt_name: "Alternate Menu Item Name 3", min_selectable_item: 1, max_selectable_item:1 , account: food}) -menu_category2_menu_item0 = SimpleMenuItem.create({item_code:"I007", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 }) -menu_category2_menu_item1 = SimpleMenuItem.create({item_code:"I008", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 }) -menu_category2_menu_item2 = SimpleMenuItem.create({item_code:"I009", name: "Default Menu Item Name 2", alt_name: "Alternate Menu Item Name 2",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 3 }) +menu_category2_menu_item0 = SimpleMenuItem.create({item_code:"I007", name: "Default Menu Item Name 0", alt_name: "Alternate Menu Item Name 0",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) +menu_category2_menu_item1 = SimpleMenuItem.create({item_code:"I008", name: "Default Menu Item Name 1", alt_name: "Alternate Menu Item Name 1",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 2 , account: food}) +menu_category2_menu_item2 = SimpleMenuItem.create({item_code:"I009", name: "Default Menu Item Name 2", alt_name: "Alternate Menu Item Name 2",menu_category: menu_category2 , min_selectable_item: 1, max_selectable_item:1, min_qty: 3 , account: food}) menu_item_attribute_size_small = MenuItemAttribute.create({attribute_type:"size", name: "Small", value: "small"}) menu_item_attribute_size_medium = MenuItemAttribute.create({attribute_type:"size",name: "Medium", value: "medium"}) From c18b57eca8c8b19dd05b796c2be4ccf2b633cfb7 Mon Sep 17 00:00:00 2001 From: Nweni Date: Wed, 7 Jun 2017 10:29:00 +0630 Subject: [PATCH 09/18] payment --- app/assets/stylesheets/orgiami.scss | 8 ++++++++ app/views/origami/home/index.html.erb | 10 ++++++---- app/views/origami/request_bills/show.html.erb | 10 ++++------ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/orgiami.scss b/app/assets/stylesheets/orgiami.scss index 327c5897..afefe4c7 100644 --- a/app/assets/stylesheets/orgiami.scss +++ b/app/assets/stylesheets/orgiami.scss @@ -29,3 +29,11 @@ .purple { background-color:#7a62d3; } + +.red { + background-color:#ff0000; +} + +.green{ + background-color: #009900 +} diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 4897407d..7a955a8d 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -190,13 +190,13 @@ - - + @@ -217,12 +217,14 @@ function callOrderDetails(sale_order_id){ sale_id = sale_order_id.split("_")[1] url = "origami/"+sale_order_id.split("_")[1] data_val = { sale_id: sale_order_id.split("_")[1]} - + $("#pay").prop('disabled',false); + $("#request_bills").prop('disabled',true); }else{ order_id = sale_order_id.split("_")[1] url = "origami/"+order_id data_val = { order_id: sale_order_id.split("_")[1]} - + $("#request_bills").prop('disabled',false); + $("#pay").prop('disabled',true); } table_or_order_id = order_id pay_sale_id = sale_id diff --git a/app/views/origami/request_bills/show.html.erb b/app/views/origami/request_bills/show.html.erb index 573a63f4..6de89ab8 100644 --- a/app/views/origami/request_bills/show.html.erb +++ b/app/views/origami/request_bills/show.html.erb @@ -4,12 +4,10 @@
- - Receipt No : <%=@sale_data.receipt_no rescue ' '%> - Receipt Date : <%=@sale_data.receipt_date rescue '-'%> + Receipt Date : <%=@sale_data.receipt_date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> Table No <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %> - Sale Id <% if @sale_data %><%=@sale_data.sale_id %><% end %> + Sale Id <% if @sale_data %><%=@sale_data.sale_id %><% end %>
@@ -152,8 +150,8 @@
-
DEL
-
CLR
+
DEL
+
CLR
From 608cd5bb213133737863321de01fcd187524e647 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Wed, 7 Jun 2017 10:53:15 +0630 Subject: [PATCH 10/18] update seed --- db/seeds.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 9d9dbb61..41b975eb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -94,6 +94,9 @@ room = Room.create({name:"Default Room", zone: zone2, status:"available", seater #Tax Profile tax_profiles = TaxProfile.create({id:1, name: "Commerical Tax", rate:5.0, order_by:1, 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"}) #Default menu menu = Menu.create({name: "Default Menu", is_active: true, created_by: "SYSTEM DEFAULT"}) @@ -137,7 +140,3 @@ 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"}) From ad5d41768d97ed0e28d1510868635dc401bda935 Mon Sep 17 00:00:00 2001 From: PhyoTheingi Date: Wed, 7 Jun 2017 11:02:53 +0630 Subject: [PATCH 11/18] Fix conflict --- db/seeds.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/db/seeds.rb b/db/seeds.rb index 41b975eb..02fa39fb 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -74,10 +74,6 @@ booking_status = Lookup.create([{lookup_type:'booking_status', name: 'Available' account_type = Lookup.create([{lookup_type:'account_type', name: 'Income', value: 'income'}, {lookup_type:'account_type', name: 'Expense', value: 'expense'}]) -#Account for Menu Item Type (eg: Food, Beverage) -food = Account.create({title: "Food", account_type: "0"}) -beverage = Account.create({title: "Beverage", account_type: "1"}) - #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"}) From 9a23716c2360d1ee2aee1f686e9dab47b93d7c04 Mon Sep 17 00:00:00 2001 From: Nweni Date: Wed, 7 Jun 2017 13:02:12 +0630 Subject: [PATCH 12/18] others payment --- .../origami/card_payments_controller.rb | 10 ------ .../origami/others_payments_controller.rb | 10 ++++++ .../origami/payments_controller.rb | 12 ++++--- .../origami/request_bills_controller.rb | 10 +----- .../index.html.erb | 0 .../{request_bills => payments}/show.html.erb | 32 ++++++++++++++----- config/routes.rb | 10 +++--- 7 files changed, 49 insertions(+), 35 deletions(-) delete mode 100644 app/controllers/origami/card_payments_controller.rb create mode 100644 app/controllers/origami/others_payments_controller.rb rename app/views/origami/{card_payments => others_payments}/index.html.erb (100%) rename app/views/origami/{request_bills => payments}/show.html.erb (92%) diff --git a/app/controllers/origami/card_payments_controller.rb b/app/controllers/origami/card_payments_controller.rb deleted file mode 100644 index 2df4b266..00000000 --- a/app/controllers/origami/card_payments_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Origami::CardPaymentsController < BaseOrigamiController - - - def index - end - - def create - end - -end diff --git a/app/controllers/origami/others_payments_controller.rb b/app/controllers/origami/others_payments_controller.rb new file mode 100644 index 00000000..e92c9535 --- /dev/null +++ b/app/controllers/origami/others_payments_controller.rb @@ -0,0 +1,10 @@ +class Origami::OthersPaymentsController < BaseOrigamiController + + + def index + end + + def create + end + +end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index f64e27e3..45b03c79 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -5,13 +5,17 @@ class Origami::PaymentsController < BaseOrigamiController end def create - #payment type - #sale status - #point - get [ food amount ] + cash = params[:cash] + card = params[:card] + + #process_payment(invoice, action_by) end def show - + sale_id = params[:sale_id] + if Sale.exists?(sale_id) + @sale_data = Sale.find_by_sale_id(sale_id) + end end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 31766599..9e14e9ea 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -25,13 +25,5 @@ class Origami::RequestBillsController < BaseOrigamiController printer.print_receipt_bill(print_settings,@sale_items,@sale,@sale_data) end - - - def show - sale_id = params[:sale_id] - if Sale.exists?(sale_id) - @sale_data = Sale.find_by_sale_id(sale_id) - end - end - + end diff --git a/app/views/origami/card_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb similarity index 100% rename from app/views/origami/card_payments/index.html.erb rename to app/views/origami/others_payments/index.html.erb diff --git a/app/views/origami/request_bills/show.html.erb b/app/views/origami/payments/show.html.erb similarity index 92% rename from app/views/origami/request_bills/show.html.erb rename to app/views/origami/payments/show.html.erb index 6de89ab8..e35696d2 100644 --- a/app/views/origami/request_bills/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -87,7 +87,7 @@

-
CARD
+
OTHERS PAYMENT
0.0

@@ -150,8 +150,8 @@
-
DEL
-
CLR
+
DEL
+
CLR
@@ -191,6 +191,10 @@ $(document).on('click', '.cashier_number', function(event){ update_balance(); break; + case 'clr': + $('#cash').text("0.0"); + update_balance(); + break; } event.handled = true; } else { @@ -207,16 +211,28 @@ $( document ).ready(function() { $('#card_payment').click(function() { var sale_id = $('#sale_id').text(); - window.location.href = '/origami/sale/'+ sale_id + "/payment/card_payment" + window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment" return false; }); $('#pay').click(function() { - console.log("pay") - if($('#amount_due').text() > 0){ - console.log("greater") + + if($('#balance').text() > 0){ + alert(" Insufficient Amount!") }else{ - console.log("less") + // payment + var cash = $('#cash').text(); + var credit = $('#credit').text(); + var card = $('#card').text(); + + $.ajax({type: "POST", + url: "<%= origami_payment_process_path %>", + data: "cash="+ cash, + success:function(result){ + alert("THANK YOU") + } + }); + } }); diff --git a/config/routes.rb b/config/routes.rb index 64b5feeb..558e2c2d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -68,14 +68,16 @@ Rails.application.routes.draw do namespace :origami do root "home#index" get "/:booking_id" => "home#show" do #origami/:booking_id will show - resources :payments, only: [:index, :new, :create ] #add payment by payment_method resources :discounts, only: [:index,:new, :create ] #add discount type resources :customers, only: [:index,:new, :create ] #add customer type end - # resources :request_bills, only: [:show] - get 'sale/:sale_id/payment' => 'request_bills#show' + + get 'sale/:sale_id/payment' => 'payments#show' + post 'payment_process' => 'payments#create' + get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" - get 'sale/:sale_id/payment/card_payment' => "card_payments#index" + get 'sale/:sale_id/payment/others_payment' => "others_payments#index" + end #--------- Waiter/Ordering Station ------------# From 810a6d8afcc0b9fda0be676a2b48a7b1700b68f7 Mon Sep 17 00:00:00 2001 From: Nweni Date: Wed, 7 Jun 2017 14:45:03 +0630 Subject: [PATCH 13/18] update sale_payment database --- .../origami/payments_controller.rb | 9 ++- app/models/sale_audit.rb | 5 +- app/models/sale_payment.rb | 70 ++++++++++--------- app/views/origami/payments/show.html.erb | 5 +- .../20170403174111_create_sale_audits.rb | 4 +- 5 files changed, 52 insertions(+), 41 deletions(-) diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 45b03c79..bac414ad 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -6,9 +6,12 @@ class Origami::PaymentsController < BaseOrigamiController def create cash = params[:cash] - card = params[:card] - - #process_payment(invoice, action_by) + sale_id = params[:sale_id] + if(Sale.exists?(sale_id)) + saleObj = Sale.find(sale_id) + sale_payment = SalePayment.new + sale_payment.process_payment(saleObj, @user, cash) + end end def show diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index c99d2dfc..29daa796 100644 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -1,6 +1,6 @@ class SaleAudit < ApplicationRecord self.primary_key = "sale_audit_id" - + #primary key - need to be unique generated for SaleAudit before_create :generate_custom_id @@ -44,13 +44,14 @@ class SaleAudit < ApplicationRecord sale_audit.save! end - def record_payment(sale_id, remark, action_by) + def self.record_payment(sale_id, remark, action_by) sale_audit = SaleAudit.new() sale_audit.sale_id = sale_id sale_audit.action = "SALEPAYMENT" sale_audit.action_at = DateTime.now.utc sale_audit.action_by = action_by sale_audit.remark = remark + sale_audit.approved_by = Time.now sale_audit.save! end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 15fe4c74..8f9b7294 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -1,17 +1,21 @@ class SalePayment < ApplicationRecord self.primary_key = "sale_payment_id" - + #primary key - need to be unique generated for multiple shops before_create :generate_custom_id belongs_to :sale - :attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status + attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status + + def process_payment(invoice, action_by, cash_amount) - def process_payment(invoice, action_by) self.sale = invoice - + self.received_amount = cash_amount + + payment_method = "cash" amount_due = invoice.grand_total + #get all payment for this invoices invoice.sale_payments.each do |payment| if (payment.payment_status == "paid" ) @@ -22,32 +26,33 @@ class SalePayment < ApplicationRecord if (amount_due > 0) payment_status = false #route to payment type - switch (payment_method) - case "cash" + case payment_method + when "cash" payment_status = cash_payment - case "creditnote" - payment_status = creditnote_payment - case "visa" - payment_status = external_terminal_card_payment(:visa) - case "master" - payment_status = external_terminal_card_payment(:master) - case "jcb" - payment_status = external_terminal_card_payment(:jcb) - case "mpu" - payment_status = external_terminal_card_payment(:mpu) - case "unionpay" - payment_status = external_terminal_card_payment(:unionpay) - case "vochure" - payment_status = vochure_payment - case "giftcard" - payment_status = giftcard_payment - case "paypar" - #TODO: implement paypar implementation + when "creditnote" + if !self.customer_id.nil? + payment_status = creditnote_payment(self.customer_id) + end + when "visa" + payment_status = external_terminal_card_payment(:visa) + when "master" + payment_status = external_terminal_card_payment(:master) + when "jcb" + payment_status = external_terminal_card_payment(:jcb) + when "mpu" + payment_status = external_terminal_card_payment(:mpu) + when "unionpay" + payment_status = external_terminal_card_payment(:unionpay) + when "vochure" + payment_status = vochure_payment + when "giftcard" + payment_status = giftcard_payment + when "paypar" payment_status = paypar_payment + else + puts "it was something else" end - - #record an payment in sale-audit remark = "Payment #{payment_method}- for Invoice #{invoice.receipt_no} Due [#{amount_due}]| pay amount -> #{amount} | Payment Status ->#{payment_status}" sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) @@ -66,10 +71,9 @@ class SalePayment < ApplicationRecord private def cash_payment payment_status = false - self.payment_method = "cash" self.payment_amount = self.received_amount - self.outstanding_amount = self.sale.grand_total - received_amount + self.outstanding_amount = self.sale.grand_total - self.received_amount self.payment_status = "paid" payment_method = self.save! @@ -78,7 +82,8 @@ class SalePayment < ApplicationRecord return payment_status end - def creditnote_payment(self.customer_id) + def creditnote_payment(customer_id) + payment_status = false self.payment_method = "creditnote" @@ -147,11 +152,12 @@ class SalePayment < ApplicationRecord end def sale_update_payment_status(paid_amount) - + puts "paid_amount" + puts paid_amount #update amount_outstanding self.sale.amount_received = self.sale.amount_received + paid_amount - self.sale.amount_changed = amount - self.sale.amount_received - if (self.sale.grand_total <= self.sale.amount_received && self.sale.amount_changed > 0) + self.sale.amount_changed = amount - self.sale.amount_received + if (self.sale.grand_total <= self.sale.amount_received && self.sale.amount_changed > 0) self.sale.payment_status = "paid" self.sale.sale_status = "completed" self.sale.save! diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index e35696d2..ccd9fd77 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -172,6 +172,7 @@ $(document).on('click', '.cashier_number', function(event){ original_value = $('#cash').text(); var input_type = $(this).attr("data-type"); + switch (input_type) { case 'num': var input_value = $(this).attr("data-value"); @@ -224,10 +225,10 @@ $( document ).ready(function() { var cash = $('#cash').text(); var credit = $('#credit').text(); var card = $('#card').text(); - + var sale_id = $('#sale_id').text(); $.ajax({type: "POST", url: "<%= origami_payment_process_path %>", - data: "cash="+ cash, + data: "cash="+ cash + "&sale_id=" + sale_id, success:function(result){ alert("THANK YOU") } diff --git a/db/migrate/20170403174111_create_sale_audits.rb b/db/migrate/20170403174111_create_sale_audits.rb index ae6ba3f4..e8197c4b 100644 --- a/db/migrate/20170403174111_create_sale_audits.rb +++ b/db/migrate/20170403174111_create_sale_audits.rb @@ -7,8 +7,8 @@ class CreateSaleAudits < ActiveRecord::Migration[5.0] t.string :action, :null => false t.datetime :action_at, :null => false t.string :action_by, :null => false - t.string :approved_by, :null => false - t.datetime :approved_by, :null => false + t.string :approved_by, :null => true + t.datetime :approved_at, :null => true t.string :remark t.timestamps end From 114c4ee14ddfe232fb09db3fafbec3cdc5597cb3 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 7 Jun 2017 17:13:27 +0630 Subject: [PATCH 14/18] all changed for index in origami --- app/assets/javascripts/orgiami.js | 85 ++++ app/assets/stylesheets/orgiami.scss | 32 ++ app/controllers/origami/home_controller.rb | 10 +- .../origami/request_bills_controller.rb | 5 +- app/models/order.rb | 15 +- app/models/sale.rb | 4 +- app/models/sale_item.rb | 27 +- app/views/oqs/home/index.html.erb | 5 +- app/views/origami/home/index.html.erb | 464 +++++++----------- app/views/origami/home/index_old.html.erb | 328 +++++++++++++ config/routes.rb | 3 +- 11 files changed, 666 insertions(+), 312 deletions(-) create mode 100644 app/views/origami/home/index_old.html.erb 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 327c5897..392f7700 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 cb2f1b83..62289c89 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -2,6 +2,7 @@ class Origami::RequestBillsController < BaseOrigamiController def print @sale = Sale.new + sale_order=SaleOrder.new booking_id = params[:id] check_booking = Booking.find_by_booking_id(booking_id) @@ -9,7 +10,7 @@ class Origami::RequestBillsController < BaseOrigamiController # 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) + @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=?",@sale_id) @@ -22,6 +23,6 @@ class Origami::RequestBillsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer_name) - + redirect_to origami_root_path end end diff --git a/app/models/order.rb b/app/models/order.rb index 036f9006..16d22d57 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -223,12 +223,11 @@ class Order < ApplicationRecord 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") @@ -236,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") @@ -249,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 @@ -263,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 diff --git a/app/models/sale.rb b/app/models/sale.rb index db1eedcf..1a9c9a28 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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/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 ac8c7678..45bfe596 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 +
+
+ -
- - - - - - - - - -
- - - - - -
-
-
+
+
-
-
-
- +
- - + - - + +
- - + \ No newline at end of file diff --git a/app/views/origami/home/index_old.html.erb b/app/views/origami/home/index_old.html.erb new file mode 100644 index 00000000..d480cf8d --- /dev/null +++ b/app/views/origami/home/index_old.html.erb @@ -0,0 +1,328 @@ +
+
+ + + + + + +
+ + +
+ +
+ + <% 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 %> +
+
+ + +
+ +
+ + <% 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 %> +
+
+ + +
+ + +
+ + <% 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 %> +
+
+ +
+ +
+ +
+
+
+
ORDER DETAILS +

+
+
+
+
+ + + + + + +
ItemsQTY + Price +
+
+
+ + + + + + + + + +
+ + + + + +
+
+ + +
+
+
+ +
+ + + + + + + + + + + + +
+
+ + diff --git a/config/routes.rb b/config/routes.rb index ddf9275a..a57dc4dc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -73,7 +73,8 @@ Rails.application.routes.draw do resources :customers, only: [:index,:new, :create ] #add customer type end - resources :request_bills, only: [:print] + # resources :request_bills, only: [:print] + get "/request_bills/:id" => "request_bills#print" get 'sale/:sale_id/payment' => 'request_bills#show' get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" From a601cf6d7598e485be9f9928c3e7ae2ed9046f12 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 7 Jun 2017 18:08:44 +0630 Subject: [PATCH 15/18] editing migration --- app/models/menu_item.rb | 2 +- ...747_create_accounts.rb => 20170531024747_create_accounts.rb} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename db/migrate/{20170331024747_create_accounts.rb => 20170531024747_create_accounts.rb} (100%) diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 89967e2e..5f8b95cf 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -4,7 +4,7 @@ class MenuItem < ApplicationRecord has_many :menu_item_instances belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id" - belongs_to :account + belongs_to :account, :optional => true validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item diff --git a/db/migrate/20170331024747_create_accounts.rb b/db/migrate/20170531024747_create_accounts.rb similarity index 100% rename from db/migrate/20170331024747_create_accounts.rb rename to db/migrate/20170531024747_create_accounts.rb From f746c1823816e371dd530897b2e37e7185dd9628 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 7 Jun 2017 18:47:50 +0630 Subject: [PATCH 16/18] (important)migrateion files changed --- Gemfile.lock | 2 -- app/models/account.rb | 4 ++-- app/models/menu_item.rb | 2 +- app/models/order.rb | 1 - db/migrate/20170324135138_create_zones.rb | 2 +- db/migrate/20170325111608_create_menus.rb | 2 +- db/migrate/20170327152733_create_menu_categories.rb | 2 +- ...e_accounts.rb => 20170331024747_create_accounts.rb} | 0 db/migrate/20170331024749_create_menu_items.rb | 2 +- .../20170402083337_create_menu_item_attributes.rb | 2 +- db/migrate/20170402083525_create_menu_item_options.rb | 2 +- .../20170402084230_create_menu_item_instances.rb | 2 +- db/migrate/20170403135121_create_customers.rb | 2 +- db/migrate/20170403135934_create_orders.rb | 2 +- db/migrate/20170403140820_create_order_items.rb | 2 +- db/migrate/20170403142424_create_dining_facilities.rb | 2 +- .../20170403151731_create_order_queue_stations.rb | 2 +- ...170403152600_create_order_queue_process_by_zones.rb | 2 +- .../20170403153001_create_payment_method_settings.rb | 2 +- db/migrate/20170403155230_create_employees.rb | 2 +- db/migrate/20170403155500_create_cashier_terminals.rb | 2 +- db/migrate/20170403155531_create_cashier_login_logs.rb | 2 +- db/migrate/20170403160742_create_sales.rb | 2 +- db/migrate/20170403161857_create_sale_items.rb | 2 +- db/migrate/20170403163219_create_sale_taxes.rb | 2 +- db/migrate/20170403163734_create_sale_payments.rb | 2 +- db/migrate/20170403174029_create_sale_orders.rb | 2 +- db/migrate/20170403174111_create_sale_audits.rb | 2 +- db/migrate/20170403174309_create_lookups.rb | 2 +- db/migrate/20170403183755_create_tax_profiles.rb | 2 +- db/migrate/20170404034234_create_bookings.rb | 2 +- db/migrate/20170408105938_create_seed_generators.rb | 2 +- .../20170414071634_create_membership_settings.rb | 2 +- .../20170414090001_create_assigned_order_items.rb | 2 +- db/migrate/20170414110918_create_booking_orders.rb | 2 +- db/migrate/20170421171849_add_company_address_email.rb | 2 +- db/migrate/20170507045043_order_items_completed_by.rb | 2 +- db/seeds.rb | 10 +++++----- 38 files changed, 40 insertions(+), 43 deletions(-) rename db/migrate/{20170531024747_create_accounts.rb => 20170331024747_create_accounts.rb} (100%) diff --git a/Gemfile.lock b/Gemfile.lock index 533cd08b..ae2a3941 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -124,7 +124,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) @@ -260,7 +259,6 @@ DEPENDENCIES kaminari! listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) - pg prawn prawn-table puma (~> 3.0) diff --git a/app/models/account.rb b/app/models/account.rb index a950865c..dc2e7cf8 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -4,6 +4,6 @@ class Account < ApplicationRecord has_many :menu_items # belongs_to :lookup , :class_name => "Lookup" 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/menu_item.rb b/app/models/menu_item.rb index 5f8b95cf..89967e2e 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -4,7 +4,7 @@ class MenuItem < ApplicationRecord has_many :menu_item_instances belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id" - belongs_to :account, :optional => true + belongs_to :account validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item diff --git a/app/models/order.rb b/app/models/order.rb index 6755ad63..367081c8 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -272,7 +272,6 @@ class Order < ApplicationRecord left join sale_orders on sale_orders.order_id = orders.order_id 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") end 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/20170531024747_create_accounts.rb b/db/migrate/20170331024747_create_accounts.rb similarity index 100% rename from db/migrate/20170531024747_create_accounts.rb rename to db/migrate/20170331024747_create_accounts.rb 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..1bfd1bfc 100644 --- a/db/migrate/20170403135121_create_customers.rb +++ b/db/migrate/20170403135121_create_customers.rb @@ -1,4 +1,4 @@ -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 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/seeds.rb b/db/seeds.rb index 78d927a4..0d5d2804 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -141,9 +141,9 @@ admin_employee = Employee.create({name: "Administrator", role: "Administrator", 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"} - ) +# 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"} +# ) From b395e2e6f1409c6e43006867225e858ea01c4f43 Mon Sep 17 00:00:00 2001 From: Yan Date: Wed, 7 Jun 2017 19:10:57 +0630 Subject: [PATCH 17/18] updated seed for customer --- db/migrate/20170403135121_create_customers.rb | 2 +- db/migrate/20170530072247_create_shops.rb | 2 +- db/seeds.rb | 15 +++++++-------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/db/migrate/20170403135121_create_customers.rb b/db/migrate/20170403135121_create_customers.rb index 1bfd1bfc..318e7bf1 100644 --- a/db/migrate/20170403135121_create_customers.rb +++ b/db/migrate/20170403135121_create_customers.rb @@ -4,7 +4,7 @@ class CreateCustomers < ActiveRecord::Migration[5.1] 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/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 0d5d2804..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"}) @@ -141,9 +140,9 @@ admin_employee = Employee.create({name: "Administrator", role: "Administrator", 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"} -# ) +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"} + ) From 234ef9bc1530722cf20393409b0d2bb39b8f4330 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 7 Jun 2017 22:17:12 +0630 Subject: [PATCH 18/18] change crm booking --- Gemfile | 2 +- Gemfile.lock | 2 -- app/controllers/origami/request_bills_controller.rb | 2 +- app/models/order.rb | 2 -- app/views/api/bookings/show.json.jbuilder | 6 +++--- app/views/crm/home/_booking.html.erb | 2 +- config/routes.rb | 3 +++ 7 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Gemfile b/Gemfile index 9030eff4..f413ead6 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,7 @@ 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 diff --git a/Gemfile.lock b/Gemfile.lock index 533cd08b..2c4c94b3 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) @@ -259,7 +258,6 @@ DEPENDENCIES jquery-rails kaminari! listen (~> 3.0.5) - mysql2 (>= 0.3.18, < 0.5) pg prawn prawn-table diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 9e14e9ea..9ccce028 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -1,6 +1,6 @@ class Origami::RequestBillsController < BaseOrigamiController - def create + def show @sale = Sale.new diff --git a/app/models/order.rb b/app/models/order.rb index 0473e92c..a8a6a3ef 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -218,7 +218,6 @@ 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.order_id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true) - .group("orders.order_id, order_items.order_items_id,dining_facilities.name") end def self.get_booking_order_table @@ -271,7 +270,6 @@ class Order < ApplicationRecord left join sale_orders on sale_orders.order_id = orders.order_id 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") end 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 f69f5fe0..d4f2a756 100644 --- a/app/views/crm/home/_booking.html.erb +++ b/app/views/crm/home/_booking.html.erb @@ -40,7 +40,7 @@ $(function(){ $(".summary-items tbody tr").remove(); $("#cancel").removeAttr("disabled"); $("#assign").removeAttr("disabled"); - var url = $(this).attr('data-ref');alert(url); + var url = $(this).attr('data-ref'); show_details(url); }); diff --git a/config/routes.rb b/config/routes.rb index 558e2c2d..d69e753b 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 + resources :request_bills, only: [:show] + get 'sale/:sale_id/payment' => 'request_bills#show' + get 'sale/:sale_id/payment' => 'payments#show' post 'payment_process' => 'payments#create'