From 23cb3dbbc18fb2eec83e945d0afb537848b115e5 Mon Sep 17 00:00:00 2001 From: phyusin Date: Tue, 13 Feb 2018 13:48:25 +0630 Subject: [PATCH 1/9] gemfile.lock --- Gemfile.lock | 60 ++++++++++++++++++++++++++-------------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 899a471a..1c7e6534 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GEM bcrypt (3.1.11) bindex (0.5.0) builder (3.2.3) - byebug (10.0.0) + byebug (9.1.0) cancancan (1.17.0) capistrano (3.10.1) airbrussh (>= 1.0.0) @@ -66,7 +66,7 @@ GEM capistrano-rails (1.3.1) capistrano (~> 3.1) capistrano-bundler (~> 1.1) - carrierwave (1.2.2) + carrierwave (1.2.1) activemodel (>= 4.0.0) activesupport (>= 4.0.0) mime-types (>= 1.16) @@ -81,7 +81,7 @@ GEM coffee-script-source (1.12.2) concurrent-ruby (1.0.5) connection_pool (2.2.1) - crass (1.0.3) + crass (1.0.2) cups (0.1.10) database_cleaner (1.6.2) diff-lcs (1.3) @@ -92,17 +92,17 @@ GEM factory_girl_rails (4.9.0) factory_girl (~> 4.9.0) railties (>= 3.0.0) - faker (1.8.7) - i18n (>= 0.7) + faker (1.8.4) + i18n (~> 0.5) ffi (1.9.18) - filterrific (5.0.1) - font-awesome-rails (4.7.0.3) + filterrific (2.1.2) + font-awesome-rails (4.7.0.2) railties (>= 3.2, < 5.2) globalid (0.4.1) activesupport (>= 4.2.0) httparty (0.15.6) multi_xml (>= 0.5.2) - i18n (0.9.3) + i18n (0.9.1) concurrent-ruby (~> 1.0) jbuilder (2.7.0) activesupport (>= 4.2.0) @@ -142,32 +142,32 @@ GEM mini_magick (4.8.0) mini_mime (1.0.0) mini_portile2 (2.3.0) - minitest (5.11.3) + minitest (5.10.3) momentjs-rails (2.17.1) railties (>= 3.1) - multi_json (1.13.1) + multi_json (1.12.2) multi_xml (0.6.0) - mysql2 (0.4.10) + mysql2 (0.4.9) nested_form (0.3.2) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (4.2.0) - nio4r (2.2.0) - nokogiri (1.8.2) + nio4r (2.1.0) + nokogiri (1.8.1) mini_portile2 (~> 2.3.0) pdf-core (0.7.0) - pg (1.0.0) + pg (0.21.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) - puma (3.11.2) - rack (2.0.4) + puma (3.10.0) + rack (2.0.3) rack-cors (1.0.2) rack-protection (2.0.0) rack - rack-test (0.8.2) + rack-test (0.7.0) rack (>= 1.0, < 3) rails (5.1.4) actioncable (= 5.1.4) @@ -192,12 +192,12 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (12.3.0) + rake (12.2.1) rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) redis (3.3.5) - rspec-core (3.7.1) + rspec-core (3.7.0) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) @@ -205,7 +205,7 @@ GEM rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) - rspec-rails (3.7.2) + rspec-rails (3.7.1) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) @@ -213,14 +213,14 @@ GEM rspec-expectations (~> 3.7.0) rspec-mocks (~> 3.7.0) rspec-support (~> 3.7.0) - rspec-support (3.7.1) + rspec-support (3.7.0) ruby-ole (1.2.12.1) - sass (3.5.5) + sass (3.5.3) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) + sass-rails (5.0.6) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) @@ -238,7 +238,7 @@ GEM simple_form (3.5.0) actionpack (> 4, < 5.2) activemodel (> 4, < 5.2) - spreadsheet (1.1.5) + spreadsheet (1.1.4) ruby-ole (>= 1.0) spring (2.0.2) activesupport (>= 4.2) @@ -263,12 +263,12 @@ GEM to_xls-rails (1.3.1) spreadsheet (>= 0.8.5) ttfunk (1.5.1) - turbolinks (5.1.0) - turbolinks-source (~> 5.1) - turbolinks-source (5.1.0) + turbolinks (5.0.1) + turbolinks-source (~> 5) + turbolinks-source (5.0.3) tzinfo (1.2.4) thread_safe (~> 0.1) - uglifier (4.1.5) + uglifier (3.2.0) execjs (>= 0.3.0, < 3) web-console (3.5.1) actionview (>= 5.0) @@ -277,8 +277,8 @@ GEM railties (>= 5.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.3) - whenever (0.10.0) + websocket-extensions (0.1.2) + whenever (0.9.7) chronic (>= 0.6.3) PLATFORMS From f19fb769f62612526e9e139f91022369938cfb57 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 14 Feb 2018 14:14:53 +0630 Subject: [PATCH 2/9] change split bill process --- README.md | 2 +- app/controllers/origami/home_controller.rb | 8 ++- app/controllers/origami/orders_controller.rb | 19 +++++++ app/controllers/origami/rooms_controller.rb | 8 ++- .../origami/split_bill_controller.rb | 52 +++++++++++++++++-- app/views/origami/home/show.html.erb | 43 ++++++--------- app/views/origami/orders/show.html.erb | 9 +++- app/views/origami/rooms/show.html.erb | 37 +++++-------- app/views/origami/split_bill/index.html.erb | 31 ++++++----- 9 files changed, 133 insertions(+), 76 deletions(-) diff --git a/README.md b/README.md index cb35bff4..b42782e7 100755 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ SQL Update after rake clear:data runned Change type in mysql *run if you got font error for Myanmar, Chinese, etc... => ALTER TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for table - => ALTER DATABASE [database_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database + => ALTER DATABASE [database_name] CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database For split bill 1) settings/lookups => { type:split_bill, name:SplitBill, value:1 } diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 9c7ddda1..58f64a27 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -38,6 +38,8 @@ class Origami::HomeController < BaseOrigamiController if !order.order_items.empty? if !@order_items_count.key?(booking.dining_facility_id) @order_items_count.store(booking.dining_facility_id, order.order_items.count) + else + @order_items_count[booking.dining_facility_id] += order.order_items.count end end end @@ -47,6 +49,8 @@ class Origami::HomeController < BaseOrigamiController if sale.sale_status !='completed' if !@order_items_count.key?(booking.dining_facility_id) @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) + else + @order_items_count[booking.dining_facility_id] += sale.sale_items.count end end end @@ -116,9 +120,9 @@ class Origami::HomeController < BaseOrigamiController @checkout_alert_time = Lookup.collection_of('checkout_alert_time') #for split bill lookup_spit_bill = Lookup.collection_of('split_bill') - @spit_bill = 0 + @split_bill = 0 if !lookup_spit_bill[0].nil? - @spit_bill = lookup_spit_bill[0][1] + @split_bill = lookup_spit_bill[0][1] end end diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index ea976ffd..b4d7baf0 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -13,6 +13,21 @@ class Origami::OrdersController < BaseOrigamiController end end + @orders.each do |order| + order.order_items.each_with_index do |item, index| + if !item.set_menu_items.nil? + instance_item_sets = JSON.parse(item.set_menu_items) + arr_instance_item_sets = Array.new + instance_item_sets.each do |instance_item| + item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name + arr_instance_item_sets.push(item_instance_name) + item.price = item.price.to_f + instance_item["price"].to_f + end + order.order_items[index].set_menu_items = arr_instance_item_sets + end + end + end + @order_items_count = Hash.new bookings = Booking.all if !bookings.nil? @@ -24,6 +39,8 @@ class Origami::OrdersController < BaseOrigamiController if !order.order_items.empty? if !@order_items_count.key?(booking.dining_facility_id) @order_items_count.store(booking.dining_facility_id, order.order_items.count) + else + @order_items_count[booking.dining_facility_id] += order.order_items.count end end end @@ -33,6 +50,8 @@ class Origami::OrdersController < BaseOrigamiController if sale.sale_status !='completed' if !@order_items_count.key?(booking.dining_facility_id) @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) + else + @order_items_count[booking.dining_facility_id] += sale.sale_items.count end end end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 3902354d..fd28230e 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -34,6 +34,8 @@ class Origami::RoomsController < BaseOrigamiController if !order.order_items.empty? if !@order_items_count.key?(booking.dining_facility_id) @order_items_count.store(booking.dining_facility_id, order.order_items.count) + else + @order_items_count[booking.dining_facility_id] += order.order_items.count end end end @@ -43,6 +45,8 @@ class Origami::RoomsController < BaseOrigamiController if sale.sale_status !='completed' if !@order_items_count.key?(booking.dining_facility_id) @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) + else + @order_items_count[booking.dining_facility_id] += sale.sale_items.count end end end @@ -119,9 +123,9 @@ class Origami::RoomsController < BaseOrigamiController # end lookup_spit_bill = Lookup.collection_of('split_bill') - @spit_bill = 0 + @split_bill = 0 if !lookup_spit_bill[0].nil? - @spit_bill = lookup_spit_bill[0][1] + @split_bill = lookup_spit_bill[0][1] end end diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 12f5780f..5d9cbec7 100644 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -28,11 +28,40 @@ class Origami::SplitBillController < BaseOrigamiController arr_instance_item_sets = Array.new instance_item_sets.each do |instance_item| item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name + item.price = item.price.to_f + instance_item["price"].to_f arr_instance_item_sets.push(item_instance_name) end item.set_menu_items = arr_instance_item_sets end - @order_items.push(item) + + arr_item = Hash.new + if item.qty.to_i > 1 + i = 1 + while i <= item.qty.to_i do + arr_item = {'order_items_id' => item.order_items_id, + 'order_id' => item.order_id, + 'order_item_status' => item.order_item_status, + 'item_order_by' => item.item_order_by, + 'item_code' => item.item_code, + 'item_instance_code' => item.item_instance_code, + 'item_name' => item.item_name, + 'alt_name' => item.alt_name, + 'account_id' => item.account_id, + 'qty' => '1.0', + 'price' => item.price, + 'remark' => item.remark, + 'options' => item.options, + 'set_menu_items' => item.set_menu_items, + 'taxable' => item.taxable, + 'completed_by' => item.completed_by, + 'created_at' => item.created_at, + 'updated_at' => item.updated_at} + i += 1 + @order_items.push({@order.order_id => arr_item}) + end + else + @order_items.push({@order.order_id => item}) + end end end end @@ -186,8 +215,25 @@ class Origami::SplitBillController < BaseOrigamiController order_items.each do |order_item| orderItem = OrderItem.find(order_item["id"]) - orderItem.order_id = order.order_id - orderItem.save! + if orderItem.qty.to_f != order_item['qty'].to_f + OrderItem.processs_item(orderItem.item_code, + orderItem.item_instance_code, + orderItem.item_name, + orderItem.alt_name, + orderItem.account_id, + order_item['qty'], + orderItem.price, + orderItem.options, + orderItem.set_menu_items, + orderItem.order_id, + orderItem.item_order_by, + orderItem.taxable) + + orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f + else + orderItem.order_id = order.order_id + end + orderItem.save! end end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index fe7f9a7f..19f308a1 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -386,9 +386,9 @@ end %> - + <% if !@spit_bill.nil? && @spit_bill == '1' %> - + <% end %> <% end %> <% if @sale_array.size > 1 %> @@ -439,6 +439,11 @@ + <% if !@split_bill.nil? %> + <% if @split_bill == '1' %> + + <% end %> + <% end %> @@ -711,30 +716,6 @@ // Bill Request $('#request_bills').click(function () { - var lookup_split_bill = '<%= @spit_bill %>'; - if(lookup_split_bill == '1'){ - swal({ - title: "Information!", - text: "Do you want to Split bill?", - type: "success", - showCancelButton: true, - confirmButtonColor: "#009900", - confirmButtonText: "Yes, split it!", - closeOnConfirm: false - }, function (isConfirm) { - if (isConfirm) { - var dining_id = "<%= @dining.id %>"; - window.location.href = '/origami/table/' + dining_id + "/split_bills"; - }else{ - requestBillProcess(); - } - }); - }else{ - requestBillProcess(); - } - }); - - function requestBillProcess(){ var order_id = $('#save_order_id').attr('data-order'); var ajax_url = "/origami/" + order_id + "/request_bills"; $.ajax({ @@ -749,8 +730,14 @@ location.reload(); } } - }); - } + }); + }); + + //split bill process + $('#split_bills').click(function(){ + var dining_id = "<%= @dining.id %>"; + window.location.href = '/origami/table/' + dining_id + "/split_bills"; + }); $('#move').on('click', function () { var dining_id = "<%= @dining.id %>"; diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index d98e9bc2..a1a914fd 100755 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -200,7 +200,14 @@ %> <% unless sale_item.price <= 0 %> - <%= sale_item.item_name %> + + <%= sale_item.item_name %> + <% if !sale_item.set_menu_items.nil? + sale_item.set_menu_items.each do |item_instance| %> +
<%= item_instance %> + <% end + end %> + <%= sale_item.qty %> <%= sale_item.price %> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 9c32b914..22affbdc 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -411,6 +411,11 @@ + <% if !@split_bill.nil? %> + <% if @split_bill == '1' %> + + <% end %> + <% end %> @@ -714,30 +719,6 @@ $('#pay').on('click',function() { }); // Bill Request $('#request_bills').click(function() { - var lookup_split_bill = '<%= @spit_bill %>'; - if(lookup_split_bill == '1'){ - swal({ - title: "Information!", - text: "Do you want to Split bill?", - type: "success", - showCancelButton: true, - confirmButtonColor: "#009900", - confirmButtonText: "Yes, split it!", - closeOnConfirm: false - }, function (isConfirm) { - if (isConfirm) { - var dining_id = "<%= @room.id %>"; - window.location.href = '/origami/room/' + dining_id + "/split_bills"; - }else{ - requestBillProcess(); - } - }); - }else{ - requestBillProcess(); - } -}); - -function requestBillProcess(){ var order_id = $('#save_order_id').attr('data-order'); var ajax_url = "/origami/" + order_id + "/request_bills"; $.ajax({ @@ -753,7 +734,13 @@ function requestBillProcess(){ } } }); -} +}); + +//split bill process +$('#split_bills').click(function(){ + var dining_id = "<%= @room.id %>"; + window.location.href = '/origami/room/' + dining_id + "/split_bills"; +}); $('#move').on('click',function(){ var dining_id = "<%= @room.id %>" diff --git a/app/views/origami/split_bill/index.html.erb b/app/views/origami/split_bill/index.html.erb index 4e9dda80..b0a0de04 100755 --- a/app/views/origami/split_bill/index.html.erb +++ b/app/views/origami/split_bill/index.html.erb @@ -59,32 +59,34 @@ - <% if !order.order_items.nil? %> + <% if !@order_items.nil? %> <% sub_total = 0 %> - <% order.order_items.each do |order_item| %> + <% @order_items.each do |order_item| %> + <% if order_item.include? (order.order_id.to_s) %> <% - sub_total += order_item.qty*order_item.price + sub_total += order_item[order.order_id.to_s]['qty'].to_f * order_item[order.order_id.to_s]['price'].to_f %> - > + > - - + + - <%=order_item.item_name%> - <% if !order_item.set_menu_items.nil? - order_item.set_menu_items.each do |item_instance| %> + <%=order_item[order.order_id.to_s]['item_name'] %> + <% if !order_item[order.order_id.to_s]['set_menu_items'].nil? + order_item[order.order_id.to_s]['set_menu_items'].each do |item_instance| %>
<%= item_instance %> <% end end %>
- <%=order_item.qty%> + <%=order_item[order.order_id.to_s]['qty']%> - <%=(order_item.qty*order_item.price)%> + <%=(order_item[order.order_id.to_s]['qty'].to_f * order_item[order.order_id.to_s]['price'].to_f)%> + <% end %> <% end %> @@ -148,9 +150,9 @@
- - - + + +
@@ -417,6 +419,7 @@ function get_selected_order_items(){ order_item.order_id = $(this).find('#item-order-id').text().trim(); order_item.name = $(this).find('#item-name-price').text().split('@')[0]; order_item.account_id = $(this).find('#item-account-type').text(); + order_item.qty = $(this).find('#item-qty').text(); order_item.price = $(this).find('#item-total-price').text(); order_items.push(order_item); }); From 8898ba597a31a121df1fa400fb1046e84abed45e Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 14 Feb 2018 17:07:33 +0630 Subject: [PATCH 3/9] change split bill --- app/controllers/application_controller.rb | 10 +++++----- app/models/license.rb | 6 +++--- app/views/origami/home/index.html.erb | 4 ++-- app/views/origami/split_bill/index.html.erb | 9 ++++----- 4 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4dafef41..3a35a15b 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -38,11 +38,11 @@ class ApplicationController < ActionController::Base end else # check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end diff --git a/app/models/license.rb b/app/models/license.rb index d025e349..cdebdbdd 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -60,9 +60,9 @@ class License return true end else - @license = Marshal.load(cache_license) - assign(aes_key, aes_iv) - Rails.logger.info 'API License' + # @license = Marshal.load(cache_license) + # assign(aes_key, aes_iv) + # Rails.logger.info 'API License' return true end end diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index f40cb3b3..77600370 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -247,8 +247,8 @@ $('#back').on('click',function(){ function warnBeforeRedirect(linkURL) { swal({ - title: "Oops", - text: "Are you sure you want to Logout ?", + title: "Alert!", + text: "Are you sure you want to close cashier?", type: "warning", showCancelButton: true }, function() { diff --git a/app/views/origami/split_bill/index.html.erb b/app/views/origami/split_bill/index.html.erb index b0a0de04..0963b2ca 100755 --- a/app/views/origami/split_bill/index.html.erb +++ b/app/views/origami/split_bill/index.html.erb @@ -26,12 +26,11 @@