From 09bbfa377255b0d0ed1a4801362c54256d225157 Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 18 Jan 2018 16:08:22 +0630 Subject: [PATCH 1/5] update readme --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 20e4bfc0..d3eb086b 100755 --- a/README.md +++ b/README.md @@ -70,8 +70,8 @@ For Bank Integration setting 2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 } For checkout time and checkout alert time - 1) checkout time => { type: checkout_time, name: 9:00AM - 12:00 PM, value: 120 } - 2) checkout alert time => { type: checkout_alert_time, name: 8:00AM - 12:00 PM, value: 60 } + 1) checkout time => { type: checkout_time, name: 9:00 AM - 12:00 PM, value: 120 } + 2) checkout alert time => { type: checkout_alert_time, name: 8:00 AM - 12:00 PM, value: 60 } * you can add multiple record for checkout time and checkout alert time * type must be 'checkout_time' and 'checkout_alert_time' * you can change name and value @@ -98,12 +98,12 @@ SQL Update after rake clear:data runned * ToDo list -1. Cloud Sync -2. Action Cable -3. Shop Setup -4. Payment Integation +1. Migration +2. Quick Service +3. Order & Reservation + -* System dependencies +* System Dependencies * Configuration From 384923133b9cb57d3fa3333beb270a2bcf5131cb Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 19 Jan 2018 10:43:08 +0630 Subject: [PATCH 2/5] license flash msg and add set Item price --- app/controllers/application_controller.rb | 10 ++++---- app/controllers/sym_control_controller.rb | 10 ++++---- app/models/license.rb | 14 +++++------ app/models/order.rb | 14 +++++------ app/views/layouts/installation.html.erb | 14 ++++++++++- config/license.yml | 30 +++++++++++------------ config/secrets.yml | 2 +- 7 files changed, 53 insertions(+), 41 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 7fafd6bd..3f789fc4 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/controllers/sym_control_controller.rb b/app/controllers/sym_control_controller.rb index 92d9cedd..9b7a7a66 100644 --- a/app/controllers/sym_control_controller.rb +++ b/app/controllers/sym_control_controller.rb @@ -22,14 +22,14 @@ class SymControlController < BaseController stop_sym = system("service SymmetricDS stop") run_sym = system("service SymmetricDS start") if run_sym - render :text => "

Success!

" + flash[:notice] = 'Success!' end else - render :text => "

Sym Sql file not found!

" + flash[:notice] = 'Sym Sql file not found!' end end else - render :text => "

Sym not running!

" + flash[:notice] = "Sym not running!" end end @@ -37,9 +37,9 @@ class SymControlController < BaseController license = License.new(ENV["SX_PROVISION_URL"]) status = license.get_key if status - render :text => "

Success!

" + flash[:notice] = "Success!" else - render :text => "

Not Get!

" + flash[:notice] = "Not Get!" end end diff --git a/app/models/license.rb b/app/models/license.rb index b8604b20..869abe59 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -106,7 +106,7 @@ class License redis = Redis.new cache_license = redis.get(cache_key) - # Rails.logger.info "Cache key - " + cache_key.to_s + Rails.logger.info "Cache key - " + cache_key.to_s if cache_license.nil? cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] } @@ -114,7 +114,7 @@ class License redis.set(cache_key, Marshal.dump(cache)) end - # Rails.logger.info "License - " + response.parsed_response.to_s + Rails.logger.info "License - " + response.parsed_response.to_s response = create_license_file(@activate) if(response[:status]) @@ -136,9 +136,9 @@ class License response = self.class.get("/verify", @params) @varified = response.parsed_response - # Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s + Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s if (@varified["status"]) - if (!check_expired(@varified["plan_next_renewal_date"])) + if (!check_expired(@varified["renewable_date"])) return true end else @@ -247,10 +247,10 @@ class License redis = Redis.new cache_license = redis.get(cache_key) - # Rails.logger.info "Cache key - " + cache_key.to_s + Rails.logger.info "Cache key - " + cache_key.to_s if cache_license.nil? - cache = {"shop" => shop_name, "key" => @data["secret_key"], "iv" => @data["iv_key"], "renewable_date" => @data["plan_next_renewable_date"] } + cache = {"shop" => shop_name, "key" => @data["secret_key"], "iv" => @data["iv_key"], "renewable_date" => @data["renewable_date"] } redis = Redis.new redis.set(cache_key, Marshal.dump(cache)) end @@ -358,7 +358,7 @@ class License f.write("db.user=#{dbusername}\n") f.write("db.password=#{dbpassword}\n") f.write("registration.url=http://#{db_host}:31415/sync/sx\n") - f.write("group.id=store\n") + f.write("group.id=cloud\n") f.write("external.id=001\n") f.write("job.routing.period.time.ms=5000\n") f.write("job.push.period.time.ms=10000\n") diff --git a/app/models/order.rb b/app/models/order.rb index ef21b7ff..e0bee492 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -137,13 +137,13 @@ class Order < ApplicationRecord Rails.logger.debug menu_item set_order_items = Array.new ##If menu Item set item - must add child items to order as well, where price is only take from menu_item - # if (menu_item[:type] == "SetMenuItem") - # set_order_items = - # end - - if (item.include? 'sub_items') || (item.include? :sub_items) - item[:sub_items].each do |si| - set_order_items.push({"item_instance_code"=>si[:item_instance_code], "quantity"=>si[:quantity]}) + if (menu_item[:type] == "SetMenuItem") + if (item.include? 'sub_items') || (item.include? :sub_items) + item[:sub_items].each do |si| + # Retrive instance's Price + set_item = MenuItem.search_by_item_code(si[:item_instance_code]) + set_order_items.push({"item_instance_code"=>si[:item_instance_code], "quantity"=>si[:quantity]}, "price"=>set_item[:price]) + end end end diff --git a/app/views/layouts/installation.html.erb b/app/views/layouts/installation.html.erb index 35b99bd3..542b7d5a 100755 --- a/app/views/layouts/installation.html.erb +++ b/app/views/layouts/installation.html.erb @@ -29,9 +29,21 @@ + <% flash.each do |type, message| %> + <% if type == "notice" + color = "alert-success" + elsif type == "error" + color = "alert-danger" + else + color = "bg-black" + end %> + + + <% end %>
<%= yield %> -
diff --git a/config/license.yml b/config/license.yml index bddfeafd..5bfb4703 100644 --- a/config/license.yml +++ b/config/license.yml @@ -1,15 +1,15 @@ -iv_key: TP8dIx4nBGzr+tYyKn5+Xw== -shop_name: Osaka -email: wathonaun9@gmail.com -telephone: 09979204288 -fax: 09979204288 -address: Yangon -dbhost: nk57NaR38B2eSYyron3Nbw== -dbschema: 3orxFaTi0uQhatBqZGiitQ== -dbusername: EtMle9Gr0/PE3NFHHfwo5A== -dbpassword: 86h61/O38GGo64nekz6oeA== -api_token: RZbpyAZlwOYFZfzbWmFhZgwCzRwJTBnPKIHrfM -app_token: IoXPdqzbnQWbHsnxLAjMjimnjEJNySOeIo -plan_sku: PyQJ2sk5NZTudqQ2YIU16A== -renewable_date: d/Fk1deU/iPbZFDOdyKsjA== -plan_name: weWOqr1tZ61Av6YKth1lDw== +iv_key: A8Uxeyvc6mY067XO/5Umjg== +shop_name: bitp3 +email: devops@code2lab.com +telephone: 9999999 +fax: 99999999 +address: Perl Condo +dbhost: 1OfAgD6VvftELNwb/IXwKA== +dbschema: DNhCHbEx6nj0Pq5YTjziSA== +dbusername: 4+m9wVXQJauQ4Xxd3R6TIQ== +dbpassword: r8oU0diSouVBz0XHb9FAFA== +api_token: FcOPyXQiYTVEhFrYPelEDoarJEcRsTsllJmA +app_token: ujxyNlgorGQDYjscjzRZEzkUnZqtJaYy +plan_sku: GDlJuYljNJOxTynA7Fckgg== +renewable_date: cTHhQxIkmFMWggtkJzI58Q== +plan_name: RXtwhw7JUC1P0UZdoBuwYP4ECviwyfS7LL6cBHkSU2E= diff --git a/config/secrets.yml b/config/secrets.yml index e2697d03..a0220639 100755 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -12,7 +12,7 @@ development: secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61 - sx_provision_url: 192.168.1.182:3002/api #connect.smartsales.asia/api #provision.zsai.ws/api + sx_provision_url: connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api server_mode: application cipher_type: AES-256-CBC sx_key: Wh@t1$C2L From 3e92becfb67cbb2c5231a1953a990d7e10bb4ba1 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 19 Jan 2018 11:34:53 +0630 Subject: [PATCH 3/5] update price in set item --- app/models/order.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/order.rb b/app/models/order.rb index e0bee492..5b696e20 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -142,7 +142,7 @@ class Order < ApplicationRecord item[:sub_items].each do |si| # Retrive instance's Price set_item = MenuItem.search_by_item_code(si[:item_instance_code]) - set_order_items.push({"item_instance_code"=>si[:item_instance_code], "quantity"=>si[:quantity]}, "price"=>set_item[:price]) + set_order_items.push({"item_instance_code"=>si[:item_instance_code], "quantity"=>si[:quantity], "price"=>set_item[:price]}) end end end From 57425a6bc971497665056b970777f3dbf8440ca6 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 19 Jan 2018 11:44:30 +0630 Subject: [PATCH 4/5] update sale item for set menu --- app/models/sale.rb | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 33ef6149..c5b5fa8b 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -98,6 +98,9 @@ class Sale < ApplicationRecord order.order_items.each do |item| add_item(item) + if item.set_menu_items != "[]" + add_sub_item(item.set_menu_items) + end end link_order_sale(order.id) @@ -144,7 +147,10 @@ class Sale < ApplicationRecord items.each do |item| add_item(item) - + if item.set_menu_items != "[]" + add_sub_item(item.set_menu_items) + end + #this will result in multiple orders belonging in multiple invoices - because of spilt invoices. link_order_sale(item.order_id, taxable) end @@ -181,6 +187,35 @@ class Sale < ApplicationRecord self.sale_items << sale_item end + def add_sub_item (item) + #check if the item is on promotion + JSON.parse(item).each do |item| + + #save sale item + sale_item = SaleItem.new + + #pull + instance = MenuItemInstance.find_by_item_instance_code(item["item_instance_code"]) + menu_item = instance.menu_item + + sale_item.product_code = menu_item.item_code + sale_item.item_instance_code = item["item_instance_code"] + sale_item.product_name = instance.item_instance_name + sale_item.product_alt_name = menu_item.alt_name + sale_item.account_id = menu_item.account_id + sale_item.remark = nil + + sale_item.qty = item["quantity"] + sale_item.unit_price = item["price"] + sale_item.taxable_price = sale_item.qty * sale_item.unit_price + sale_item.is_taxable = menu_item.taxable + + sale_item.price = sale_item.qty * sale_item.unit_price + + self.sale_items << sale_item + end + end + def create_saleitem_diningcharges(chargeObj, block_count, diningprice, dining_name, dining_time) sale_item = SaleItem.new sale_item.product_code = chargeObj.item_code From 9de47cc5daf5e4e77f1fa015a975a857a9595f8a Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 19 Jan 2018 11:47:46 +0630 Subject: [PATCH 5/5] update check for license file --- app/controllers/application_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 3f789fc4..7fafd6bd 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