From bbe08585fcf93e57033a3e4b7371c1e90e170e98 Mon Sep 17 00:00:00 2001 From: superuser Date: Wed, 14 Jun 2017 18:57:10 +0630 Subject: [PATCH 01/22] before pull --- config/secrets.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/config/secrets.yml b/config/secrets.yml index 6d442fa9..ce7eb8ba 100644 --- a/config/secrets.yml +++ b/config/secrets.yml @@ -19,4 +19,5 @@ test: # Do not keep production secrets in the repository, # instead read values from the environment. production: - secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> + secret_key_base: c4bc81065013f9a3506d385bcbd49586c42e586488144b0de90c7da36867de9fa880f46b5c4f86f0ce9b7c783bb5a73bdb0e5605a47716567294390e726d3e22 + From d608bd5c300acaf109ed95ac55861937d71b1ee8 Mon Sep 17 00:00:00 2001 From: superuser Date: Thu, 15 Jun 2017 09:43:22 +0630 Subject: [PATCH 02/22] before pull --- config/environments/production.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 5aa66a01..423c7de1 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -8,15 +8,15 @@ Rails.application.configure do # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. - config.eager_load = true + config.eager_load = false # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true - + config.serve_static_assets = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + #config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier From a4211166de5c7d0a2e3864865b86259d1feac080 Mon Sep 17 00:00:00 2001 From: superuser Date: Thu, 15 Jun 2017 11:53:27 +0630 Subject: [PATCH 03/22] before pull --- app/assets/javascripts/origami.js | 1 + config/environments/production.rb | 2 +- config/puma.rb | 56 +++++-------------------------- 3 files changed, 11 insertions(+), 48 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 4a7e3d50..2e354dff 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -11,6 +11,7 @@ // about supported directives. // //= require jquery +//= require tether //= require bootstrap //= require jquery_ujs //= require turbolinks diff --git a/config/environments/production.rb b/config/environments/production.rb index 423c7de1..fc0e6b9a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -23,7 +23,7 @@ Rails.application.configure do # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + config.assets.compile = true # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb diff --git a/config/puma.rb b/config/puma.rb index c7f311f8..b39a4ff2 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,47 +1,9 @@ -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum, this matches the default thread size of Active Record. -# -threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i -threads threads_count, threads_count - -# Specifies the `port` that Puma will listen on to receive requests, default is 3000. -# -port ENV.fetch("PORT") { 3000 } - -# Specifies the `environment` that Puma will run in. -# -environment ENV.fetch("RAILS_ENV") { "development" } - -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked webserver processes. If using threads and workers together -# the concurrency of the application would be max `threads` * `workers`. -# Workers do not work on JRuby or Windows (both of which do not support -# processes). -# -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } - -# Use the `preload_app!` method when specifying a `workers` number. -# This directive tells Puma to first boot the application and load code -# before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. If you use this option -# you need to make sure to reconnect any threads in the `on_worker_boot` -# block. -# -# preload_app! - -# The code in the `on_worker_boot` will be called if you are using -# clustered mode by specifying a number of `workers`. After each worker -# process is booted this block will be run, if you are using `preload_app!` -# option you will want to use this block to reconnect to any threads -# or connections that may have been created at application boot, Ruby -# cannot share connections between processes. -# -# on_worker_boot do -# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) -# end - -# Allow puma to be restarted by `rails restart` command. -plugin :tmp_restart +application_path = '/home/superuser/Application/production/sxrestaurant' +directory application_path +environment 'production' +daemonize true +pidfile "#{application_path}/tmp/pids/puma.pid" +state_path "#{application_path}/tmp/pids/puma.state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +bind 'tcp://0.0.0.0:9292' +workers 2 From 37dd8c9e5af771d121db8e6195a2bfbea26808db Mon Sep 17 00:00:00 2001 From: superuser Date: Thu, 15 Jun 2017 14:07:54 +0630 Subject: [PATCH 04/22] before pull --- app/assets/javascripts/CRM.js | 3 ++- app/assets/javascripts/OQS.js | 1 + config/puma.rb.save | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 config/puma.rb.save diff --git a/app/assets/javascripts/CRM.js b/app/assets/javascripts/CRM.js index ee1c6a41..ff41cfdd 100644 --- a/app/assets/javascripts/CRM.js +++ b/app/assets/javascripts/CRM.js @@ -11,9 +11,10 @@ // about supported directives. // //= require jquery +//= require tether //= require bootstrap //= require jquery_ujs //= require turbolinks //= require cable //= require jquery-ui -//= require bootstrap-datepicker \ No newline at end of file +//= require bootstrap-datepicker diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 3674e235..74ce5eec 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -11,6 +11,7 @@ // about supported directives. // //= require jquery +//= require tether //= require bootstrap //= require jquery_ujs //= require turbolinks diff --git a/config/puma.rb.save b/config/puma.rb.save new file mode 100644 index 00000000..5f82e805 --- /dev/null +++ b/config/puma.rb.save @@ -0,0 +1,9 @@ +lapplication_path = '/home/superuser/Application/production/sxrestaurant' +directory application_path +environment 'production' +daemonize true +pidfile "#{application_path}/tmp/pids/puma.pid" +state_path "#{application_path}/tmp/pids/puma.state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +bind 'tcp://0.0.0.0:9292' +workers 2 From d8a5c2043fc54fbcd4d3be35bda18899184dedc8 Mon Sep 17 00:00:00 2001 From: superuser Date: Thu, 15 Jun 2017 15:06:44 +0630 Subject: [PATCH 05/22] before pull --- config/sidekiq.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config/sidekiq.yml b/config/sidekiq.yml index a5c462c3..fa0b1e15 100644 --- a/config/sidekiq.yml +++ b/config/sidekiq.yml @@ -1,7 +1,6 @@ ---- :concurrency: 25 -:pidfile: ./tmp/pids/sidekiq.pid -:logfile: ./log/sidekiq.log +:pidfile: /home/superuser/Application/production/sxrestaurant/tmp/pids/sidekiq.pid +:logfile: /home/superuser/Application/production/sxrestaurant/log/sidekiq.log :queues: - default - [high_priority, 2] From 64db775dd310f8758c96eaedb028cb7219b310f6 Mon Sep 17 00:00:00 2001 From: superuser Date: Tue, 20 Jun 2017 16:13:13 +0630 Subject: [PATCH 06/22] edited api/bill_controller --- app/controllers/api/bill_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 6b1fb225..94b785f5 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -22,6 +22,7 @@ class Api::BillController < Api::ApiController @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee) end + end From e85f22fb79f2ed5a2bcb5781aa6f840a86e53cd3 Mon Sep 17 00:00:00 2001 From: superuser Date: Tue, 27 Jun 2017 12:11:07 +0630 Subject: [PATCH 07/22] update for bill --- app/controllers/api/bill_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 0408c858..16ebf256 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -32,7 +32,7 @@ class Api::BillController < Api::ApiController #shop detail shop_details = Shop.find(1) - customer= Customer.where('customer_id=' + @sale_data.customer_id) + customer= Customer.find(@sale_data.customer_id) # get member information member_info = Customer.get_member_account(customer) From 44faf2f56e38d776532b437c541dbfd7a86e68de Mon Sep 17 00:00:00 2001 From: superuser Date: Fri, 30 Jun 2017 14:19:30 +0630 Subject: [PATCH 08/22] before pull --- config/.database.yml.swp | Bin 0 -> 1024 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 config/.database.yml.swp diff --git a/config/.database.yml.swp b/config/.database.yml.swp new file mode 100644 index 0000000000000000000000000000000000000000..09f1aac2254ab80602bde572a7cb45dd3e551f06 GIT binary patch literal 1024 zcmYc?$V<%2S1{5u)iY*50$w}}48^4dsYRv5sYOWQ*qCs2x&i*d*c3p;QW8rNlM;(l V^(u37@F*LV8V!Nb5TH{C002=+5nBKN literal 0 HcmV?d00001 From f23bbd69364de1372517f0243ef3bc84d4165a69 Mon Sep 17 00:00:00 2001 From: superuser Date: Fri, 30 Jun 2017 19:33:04 +0630 Subject: [PATCH 09/22] merge with origin master --- app/controllers/api/bill_controller.rb | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index cc9e2f26..a51ce93e 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -24,11 +24,9 @@ class Api::BillController < Api::ApiController @sale = Sale.new @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier) end -<<<<<<< HEAD - - @sale_data = Sale.find_by_sale_id(@sale_id) - @sale_items = SaleItem.where("sale_id=?",@sale_id) -======= + + #@sale_data = Sale.find_by_sale_id(@sale_id) + #@sale_items = SaleItem.where("sale_id=?",@sale_id) # Not Use for these printed bill cannot give customer # @sale_data = Sale.find_by_sale_id(@sale_id) @@ -45,22 +43,16 @@ class Api::BillController < Api::ApiController # # get printer info # print_settings=PrintSetting.find_by_unique_code(unique_code) ->>>>>>> 18094f5a71174d84305cfefd3a39db8123b65cff # # Calculate Price by accounts # item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items) -<<<<<<< HEAD - customer= Customer.find(@sale_data.customer_id) + #customer= Customer.find(@sale_data.customer_id) # get member information - member_info = Customer.get_member_account(customer) -======= ->>>>>>> 18094f5a71174d84305cfefd3a39db8123b65cff + #member_info = Customer.get_member_account(customer) # printer = Printer::ReceiptPrinter.new(print_settings) # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts, member_info, shop_details) - - end From 78adf564e1f91c2ca0ced51c4dc85abe44263b29 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 09:37:19 +0630 Subject: [PATCH 10/22] crong job and close cashier --- Gemfile | 1 + Gemfile.lock | 4 ++ app/controllers/crm/customers_controller.rb | 8 +++- app/models/customer.rb | 42 +++++++++++++++++++++ app/pdf/close_cashier_pdf.rb | 3 ++ config/schedule.rb | 7 ++++ 6 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 config/schedule.rb diff --git a/Gemfile b/Gemfile index 4c544ad6..5344bdc5 100644 --- a/Gemfile +++ b/Gemfile @@ -59,6 +59,7 @@ gem 'jbuilder', '~> 2.5' gem 'bcrypt', '~> 3.1.7' gem 'sidekiq' +gem 'whenever', :require => false # XML parser #gem 'nokogiri', '~> 1.6' diff --git a/Gemfile.lock b/Gemfile.lock index 7e27774a..affb7b95 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -51,6 +51,7 @@ GEM builder (3.2.3) byebug (9.0.6) cancancan (1.17.0) + chronic (0.10.2) coffee-rails (4.2.2) coffee-script (>= 2.2.0) railties (>= 4.0.0) @@ -237,6 +238,8 @@ GEM websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.2) + whenever (0.9.7) + chronic (>= 0.6.3) PLATFORMS ruby @@ -282,6 +285,7 @@ DEPENDENCIES tzinfo-data uglifier (>= 1.3.0) web-console (>= 3.3.0) + whenever BUNDLED WITH 1.15.1 diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 2f5b25d2..6d875a98 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -123,7 +123,8 @@ class Crm::CustomersController < BaseCrmController end # format.json { render :index, status: :created, location: @crm_customers } else - # @crm_customers.destroy + customer = Customer.find(@crm_customers.customer_id) + status = customer.update_attributes(membership_type:member_group_id ) if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '} else @@ -207,7 +208,12 @@ end status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'} + else + + customer = Customer.find(@crm_customer.customer_id) + status = customer.update_attributes(membership_type:member_group_id ) + format.html { redirect_to crm_customers_path, notice: response["error"] } end diff --git a/app/models/customer.rb b/app/models/customer.rb index a26d857e..16d70db7 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -73,6 +73,48 @@ class Customer < ApplicationRecord end + def self.update_membership + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("create_membership_customer") + merchant_uid = memberaction.merchant_account_id.to_s + auth_token = memberaction.auth_token.to_s + url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + + @customers = Customer.where("membership_type IS NOT NULL AND membership_id IS NULL") + + @customers.each do |customer| + begin + response = HTTParty.post(url, + :body => + { name: customer.name,phone: customer.contact_no, + email: customer.email,dob: customer.date_of_birth, + address: customer.address,nrc:customer.nrc_no, + card_no:customer.card_no,member_group_id: customer.membership_type, + merchant_uid:merchant_uid,auth_token:auth_token + }.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json' + }) + rescue Net::OpenTimeout + response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} + end + + puts response.to_json + + if response["status"] == true + status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) + end + + end + end + def self.search(search) if search # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index b3b29914..fc04b6cc 100644 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -168,7 +168,10 @@ class CloseCashierPdf < Prawn::Document text "#{shift_sale.grand_total}", :size => self.item_font_size, :align => :right end + move_down 5 + stroke_horizontal_rule move_down 5 + move_down 5 end diff --git a/config/schedule.rb b/config/schedule.rb new file mode 100644 index 00000000..b21a46e3 --- /dev/null +++ b/config/schedule.rb @@ -0,0 +1,7 @@ +set :environment, "development" +env :PATH, ENV['PATH'] +set :output, 'log/whenever.log' + +every 30.minutes do + runner "Customer.update_membership" +end \ No newline at end of file From 972a7173619a8298c7748a985447595288053168 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 10:04:06 +0630 Subject: [PATCH 11/22] update payper and redeem --- app/models/sale_payment.rb | 4 ++-- app/pdf/receipt_bill_pdf.rb | 32 +++++++++++++++++--------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 59cee9a6..5424e3d5 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -223,7 +223,7 @@ class SalePayment < ApplicationRecord membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) if membership_data["status"]==true - self.payment_method = "paypar" + self.payment_method = "redeem" self.payment_amount = self.received_amount self.payment_reference = self.voucher_no self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f @@ -307,7 +307,7 @@ class SalePayment < ApplicationRecord paypar = sObj.sale_payments payparcost = 0 paypar.each do |pp| - if pp.payment_method == "paypar" + if pp.payment_method == "redeem" payparcost = payparcost + pp.payment_amount end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 60e1203c..a2f3827b 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -265,32 +265,34 @@ class ReceiptBillPdf < Prawn::Document rebate = 0 rebate_amount["data"].each do |res| - if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate" - - rebate = rebate + res["rebate"] - - end if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem" move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Current Redeem Amount", :size => self.item_font_size,:align => :left + text "Redeem Amount", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(res["redeem"], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end + if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate" + + rebate = rebate + res["rebate"] + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Rebate Earn", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(res["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + + end end - move_down 5 - y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Current Rebate Amount", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(rebate, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right - end + end end if member_info["status"] == true && member_info["data"].present? @@ -306,7 +308,7 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Current Balance", :size => self.item_font_size,:align => :left + text "Total Balance", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(balance, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right From 678c37c6b01fe7e5be8aadc1bd1f72dee5a0f679 Mon Sep 17 00:00:00 2001 From: Phyo Date: Sun, 2 Jul 2017 11:00:01 +0630 Subject: [PATCH 12/22] Rebate Bug Fix --- app/models/sale_payment.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 59cee9a6..0bf80955 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -55,7 +55,7 @@ class SalePayment < ApplicationRecord sale_audit = SaleAudit.record_payment(invoice.id, remark, action_by) # update complete order items in oqs - SaleOrder.where("sale_id = '#{ invoice.sale_id }'").find_each do |sodr| + SaleOrder.where("sale_id = '#{ invoice.sale_id }'").find_each do |sodr| AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi| aoi.delivery_status = 1 aoi.save @@ -314,7 +314,7 @@ class SalePayment < ApplicationRecord # overall_dis = SaleItem.get_overall_discount(sObj.id) overall_dis = sObj.total_discount - total_amount = rebate_prices - payparcost + overall_dis + total_amount = rebate_prices - payparcost - overall_dis if total_amount > 0 receipt_no = sObj.receipt_no membership = MembershipSetting.find_by_membership_type("paypar_url") From acca5b5a1d47a0cd86ce056ac1998b16bb16dcc9 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 2 Jul 2017 11:22:49 +0630 Subject: [PATCH 13/22] Update --- app/controllers/api/bill_controller.rb | 33 +++++++++++--------- app/controllers/origami/shifts_controller.rb | 2 ++ app/models/shift_sale.rb | 8 ++++- app/views/origami/home/show.html.erb | 12 +++---- app/views/origami/payments/show.html.erb | 2 ++ 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index cb3b9cc2..bcd9d62b 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -5,26 +5,29 @@ class Api::BillController < Api::ApiController def create @status = false @error_message = "Order ID or Booking ID is require to request for a bill." - + if ShiftSale.current_shift #create Bill by Booking ID - if (params[:booking_id]) - booking = Booking.find(params[:booking_id]) + if (params[:booking_id]) + booking = Booking.find(params[:booking_id]) - if booking - if booking.sale_id.nil? - @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier) - else - @status = true - @sale_id = booking.sale_id + if booking + if booking.sale_id.nil? + @sale = Sale.new + @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee, get_cashier) + else + @status = true + @sale_id = booking.sale_id + end end - end - elsif (params[:order_id]) - @sale = Sale.new - @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier) + elsif (params[:order_id]) + @sale = Sale.new + @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier) + end + else + @status = false + @error_message = "No Current Open Shift" end - # Not Use for these printed bill cannot give customer # @sale_data = Sale.find_by_sale_id(@sale_id) # @sale_items = SaleItem.where("sale_id=?",@sale_id) diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 07d10cf7..e527da46 100644 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -4,6 +4,8 @@ class Origami::ShiftsController < BaseOrigamiController end def show + puts ">>>>>" + puts current_user.id @shift = ShiftSale.current_open_shift(current_user.id) end diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index acf3149c..b9c5aa28 100644 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -16,11 +16,17 @@ class ShiftSale < ApplicationRecord belongs_to :cashier_terminal belongs_to :employee, :foreign_key => 'employee_id' + def self.current_shift + today_date = DateTime.now.strftime("%Y-%m-%d") + shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null",today_date).take + return shift + end + def self.current_open_shift(current_user) #if current_user #find open shift where is open today and is not closed and login by current cashier today_date = DateTime.now.strftime("%Y-%m-%d") - shift = ShiftSale.where("DATE(shift_started_at)= #{ today_date } and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}").take + shift = ShiftSale.where("DATE(shift_started_at)=? and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user}",today_date).take return shift #end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 0d3de391..baad1a0a 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -163,18 +163,18 @@ <% - count = 0 sub_total = 0 if @status_sale == "sale" @sale_array[0].sale_items.each do |sale_item| - count += 1 - sub_total = sub_total + sale_item.price + + sub_total = sub_total + sale_item.price %> <% # Can't check for discount unless sale_item.price == 0 + count += 1 %> <%= count %> @@ -439,7 +439,7 @@ $("#first_bill").on('click', function(){ $.ajax({ type: "GET", url: ajax_url, - success:function(result){ + success:function(result){ location.reload(); } }); @@ -452,11 +452,11 @@ $('#pay').on('click',function() { $.ajax({ type: "POST", url: '/origami/sale/'+ sale_id + "/rounding_adj", - success:function(result){ + success:function(result){ window.location.href = '/origami/sale/'+ sale_id + "/payment"; } }); - + }); // Bill Request diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 292ae5e1..86738c22 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -334,6 +334,7 @@ $( document ).ready(function() { }); $('#pay').click(function() { + $('#pay').text("Processing, Please wait!") if($('#balance').text() > 0){ alert(" Insufficient Amount!") }else{ @@ -351,6 +352,7 @@ $( document ).ready(function() { if($('#balance').text() < 0){ alert("Changed amount " + $('#balance').text() * (-1) ) }else{ + $('#pay').text("Pay") alert("Thank you") } From b78119f848a38c9adfbb06e7e636708a0cf040d8 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 11:41:47 +0630 Subject: [PATCH 14/22] update print --- app/controllers/origami/customers_controller.rb | 1 + app/pdf/receipt_bill_pdf.rb | 4 ++-- app/views/crm/customers/index.html.erb | 10 +++++++--- app/views/origami/customers/index.html.erb | 13 ++++++++----- db/seeds.rb | 1 + 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index e8376fc4..203e5600 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -34,6 +34,7 @@ class Origami::CustomersController < BaseOrigamiController #@crm_customers = Customer.all @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) @crm_customer = Customer.new + @count_customer = Customer.count_customer # if flash["errors"] # @crm_customer.valid? diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index a2f3827b..db913c4a 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -366,10 +366,10 @@ class ReceiptBillPdf < Prawn::Document y_position = cursor bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do - text "#{printed_status}", :size => self.header_font_size,:align => :left + text "#{printed_status}", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width =>self.label_width, :height => self.item_height) do - text "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :right + text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :right end move_down 5 diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index b3c1fce7..a44aed2f 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -47,11 +47,15 @@ <% @i = 0 %> <% @crm_customers.each do |crm_customer| %> - <% if crm_customer.customer_id != "CUS-00001" && crm_customer.customer_id != "CUS-000000000" %> + - <%= @i += 1 %> + + <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <%= @i += 1 %> + <% end %> + <%= crm_customer.name %> <%= crm_customer.card_no rescue '-' %> <%= crm_customer.contact_no %> @@ -59,7 +63,7 @@ <%= link_to 'Show', crm_customer_path(crm_customer) %> - <% end %> + <% end %> diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index 489487ab..72e402e8 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -41,11 +41,15 @@ <% if @crm_customers.count > 0 %> <% @i = 0 %> <% @crm_customers.each do |crm_customer| %> - <% if crm_customer.customer_id != "CUS-00000" && crm_customer.customer_id != "CUS-00000000" %> + - <%= @i += 1 %> + + <% if crm_customer.customer_id != "CUS-000000000001" && crm_customer.customer_id != "CUS-000000000002" %> + <%= @i += 1 %> + <% end %> + <%= crm_customer.name %> <%= crm_customer.company rescue '-' %> <%= crm_customer.contact_no %> @@ -53,7 +57,6 @@ - <% end %> <% end %> <%else%>

There are no record for your search

@@ -155,10 +158,10 @@ <%= f.input :address, :class => "form-control col-md-6 address" %> - +
<%= f.text_field :date_of_birth,:value=>"01-01-1990",:class=>"form-control datepicker"%> diff --git a/db/seeds.rb b/db/seeds.rb index b71418a9..3bff75a0 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -159,6 +159,7 @@ admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "3 order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) +close_cashier_printer=PrintSetting.create({name: "Close Cashier", unique_code: "CloseCashierPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "Cashier", precision: "0", delimiter: "0", heading_space: "5"}) From 58f2ff28e598800da964619f9e99a388d628f8bf Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 2 Jul 2017 11:53:33 +0630 Subject: [PATCH 15/22] update void --- app/models/sale_payment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 0bf80955..1d8a0e99 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -287,7 +287,7 @@ class SalePayment < ApplicationRecord bookings = table.bookings bookings.each do |tablebooking| if tablebooking.booking_status != 'moved' - if tablebooking.sale.sale_status != 'completed' + if tablebooking.sale.sale_status != 'completed' && tablebooking.sale.sale_status != 'void' status = false end end From 7994fcc0c301fa86337306f7cf5192c21d37702a Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 12:06:28 +0630 Subject: [PATCH 16/22] update --- app/models/sale_payment.rb | 4 ++-- app/pdf/receipt_bill_pdf.rb | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 5424e3d5..59cee9a6 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -223,7 +223,7 @@ class SalePayment < ApplicationRecord membership_data = SalePayment.redeem(membership_setting.gateway_url,membership_setting.auth_token,customer_data.membership_id,self.received_amount,self.sale.sale_id) if membership_data["status"]==true - self.payment_method = "redeem" + self.payment_method = "paypar" self.payment_amount = self.received_amount self.payment_reference = self.voucher_no self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f @@ -307,7 +307,7 @@ class SalePayment < ApplicationRecord paypar = sObj.sale_payments payparcost = 0 paypar.each do |pp| - if pp.payment_method == "redeem" + if pp.payment_method == "paypar" payparcost = payparcost + pp.payment_amount end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index db913c4a..4557eadd 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -233,9 +233,16 @@ class ReceiptBillPdf < Prawn::Document SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment| y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + if payment.payment_method == "paypar" + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Redeem Payment", :size => self.item_font_size,:align => :left + end + else + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do text "#{payment.payment_method.capitalize} Payment", :size => self.item_font_size,:align => :left end + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do text "#{number_with_precision(payment.payment_amount, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end @@ -368,8 +375,8 @@ class ReceiptBillPdf < Prawn::Document bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do text "#{printed_status}", :size => self.item_font_size,:align => :left end - bounding_box([self.label_width,y_position], :width =>self.label_width, :height => self.item_height) do - text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :right + bounding_box([self.item_description_width,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Thank You! See you Again", :left_margin => -10, :size => self.item_font_size,:align => :left end move_down 5 From a86ac10e833157cf22582ca7de6239b86a9d1a5c Mon Sep 17 00:00:00 2001 From: Phyo Date: Sun, 2 Jul 2017 13:39:36 +0630 Subject: [PATCH 17/22] Zone OQS bug fix --- app/controllers/settings/order_queue_stations_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index 9fe78de4..dea66941 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -74,10 +74,10 @@ class Settings::OrderQueueStationsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_order_queue_station_params # <<<<<<< HEAD - params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) +# params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) # ======= # Don't Know { zone_ids: [] } -# params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] }) + params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] }) # >>>>>>> b093a993ba002c92659bbb34338c55c031c11d87 end end From a0e16bd48544e2725a3103e98c89144129aa17d2 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sun, 2 Jul 2017 14:06:21 +0630 Subject: [PATCH 18/22] update crm and bill --- app/controllers/crm/customers_controller.rb | 17 ++++++++- app/pdf/receipt_bill_pdf.rb | 42 +++++++++++++++------ app/views/crm/customers/show.html.erb | 25 +++++++----- app/views/transactions/sales/show.html.erb | 37 +++++++++++------- 4 files changed, 87 insertions(+), 34 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 6d875a98..f67d413c 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -48,7 +48,22 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) - @response = Customer.get_membership_transactions(@customer) + @response = Customer.get_membership_transactions(@customer) + # get member information + total = Customer.get_member_account(@customer) + + + @balance = 0.00 + @accountable_type = '' + if total["status"]==true + total["data"].each do |res| + if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" + @balance += res["balance"] + # @accountable_type = res["accountable_type"] + @accountable_type = "Rebate Balance" + end + end + end # @response = "" #end customer amount diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 4557eadd..52cdf586 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -270,21 +270,17 @@ class ReceiptBillPdf < Prawn::Document if rebate_amount["status"] == true stroke_horizontal_rule rebate = 0 + redeem = 0 rebate_amount["data"].each do |res| if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem" - - move_down 5 - y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Redeem Amount", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["redeem"], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end + redeem = redeem + res["redeem"] + end - if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate" + + + if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate" rebate = rebate + res["rebate"] @@ -294,11 +290,35 @@ class ReceiptBillPdf < Prawn::Document text "Rebate Earn", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(res["balance"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + + end + + if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateBonusAccount" && res["status"]== "Rebate" + + rebate = rebate + res["rebate"] + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(res["balance"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end end + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Redeem Amount", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end end end diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 5d36f5c3..21a05d9c 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -32,6 +32,7 @@ NRC/Passport No Address DOB + Membership Type @@ -45,8 +46,16 @@ <%= @customer.nrc_no %> <%= @customer.address%> <%= @customer.date_of_birth %> + <% if @customer.membership_type.to_f > 0%> + <%lookup= Lookup.find_by_value(@customer.membership_type) %> + <%= lookup.name %> + + <%else%> + - + <%end%> + - + @@ -55,21 +64,19 @@
- <% - if @response["data"].present? %> + - <% if @response["status"] == true %> - - <% end %> + + + - <% end %> - + @@ -82,7 +89,7 @@ - + diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index b62289b1..4dd15755 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -39,6 +39,9 @@ + @@ -235,23 +238,31 @@ +
+
+
+
Membership TransactionsCurrent Balance : <%= @response["data"].last["balance"]%>Current Balance : <%= @balance%>
Date Redeem Rebate BalanceFrom Account Status Receipt No
<%= transaction["redeem"]%> <%= transaction["rebate"] %> <%= transaction["balance"] %><%= transaction["account_status"] %> <%= transaction["status"] %> <%= transaction["receipt_no"] %>
+ + + + + + + + + + + + + +
StatusAction AtApproved ByRemark
+
+
+ - From 70668e4264911a57710cb0358cb4c547730fa4ab Mon Sep 17 00:00:00 2001 From: Phyo Date: Sun, 2 Jul 2017 14:20:23 +0630 Subject: [PATCH 19/22] Credit note Rebate Prevent --- app/models/sale_payment.rb | 8 +++++++- lib/tasks/menu_import.rake | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 1d8a0e99..936bc08a 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -306,16 +306,22 @@ class SalePayment < ApplicationRecord if generic_customer_id != nil || generic_customer_id != "" || generic_customer_id != 0 paypar = sObj.sale_payments payparcost = 0 + credit = 0 paypar.each do |pp| if pp.payment_method == "paypar" payparcost = payparcost + pp.payment_amount + elsif pp.payment_method == "creditnote" + credit = 1 end end # overall_dis = SaleItem.get_overall_discount(sObj.id) overall_dis = sObj.total_discount total_amount = rebate_prices - payparcost - overall_dis - if total_amount > 0 + if credit == 1 + total_amount = 0 + end + if total_amount >= 0 receipt_no = sObj.receipt_no membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("rebate") diff --git a/lib/tasks/menu_import.rake b/lib/tasks/menu_import.rake index 5db6231f..11f4fad2 100644 --- a/lib/tasks/menu_import.rake +++ b/lib/tasks/menu_import.rake @@ -67,7 +67,7 @@ menu_category3 = MenuCategory.create({menu: menu, code:"C003", name: "Beef & Mut menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0152", menu_item: menu_category1_menu_item7, price:8000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0151", menu_item: menu_category1_menu_item7, price:16000.00, is_on_promotion:false}]) # Sliced Beef (Thin) - menu_category1_menu_item8 = SimpleMenuItem.create({item_code:"01009", name: "Sliced Beef (Thin)", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_category1_menu_item8 = SimpleMenuItem.create({item_code:"01009", name: "Sliced Beef ( Thin )", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0162", menu_item: menu_category1_menu_item8, price:6000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0161", menu_item: menu_category1_menu_item8, price:12000.00, is_on_promotion:false}]) # Tender Sliced Beef @@ -87,7 +87,7 @@ menu_category3 = MenuCategory.create({menu: menu, code:"C003", name: "Beef & Mut menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II0202", menu_item: menu_category1_menu_item12, price:7000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II0201", menu_item: menu_category1_menu_item12, price:14000.00, is_on_promotion:false}]) # Sliced Beef ( Think ) - menu_category1_menu_item13 = SimpleMenuItem.create({item_code:"01014", name: "Sliced Beef ( Think )", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) + menu_category1_menu_item13 = SimpleMenuItem.create({item_code:"01014", name: "Sliced Beef ( Thick )", alt_name: "Twin Pot",menu_category: menu_category3 , min_selectable_item: 1, max_selectable_item:1, account: food }) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Half Potion",item_instance_code:"II1432", menu_item: menu_category1_menu_item13, price:7000.00, is_on_promotion:false}]) menu_item0_instance = MenuItemInstance.create([{item_instance_name:"Full Potion",item_instance_code:"II1431", menu_item: menu_category1_menu_item13, price:14000.00, is_on_promotion:false}]) # Pork From f06e526ea3001dcb0ed06b759697726daaf6b755 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sun, 2 Jul 2017 14:36:57 +0630 Subject: [PATCH 20/22] menu alt name --- app/controllers/crm/customers_controller.rb | 30 ++- app/models/customer.rb | 19 +- app/models/sale_payment.rb | 8 +- app/views/origami/shifts/show.html.erb | 2 +- lib/tasks/menu_import.rake | 264 ++++++++++---------- 5 files changed, 165 insertions(+), 158 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 2f5b25d2..81e7bb71 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -100,18 +100,22 @@ class Crm::CustomersController < BaseCrmController 'Content-Type' => 'application/json', 'Accept' => 'application/json' }, - :timeout => 10 + :timeout => 100 ) - - rescue Net::OpenTimeout - response = { status: false } - rescue OpenURI::HTTPError - response = { status: false} + rescue HTTParty::Error + response = {status: false, message: "Can't open embership server "} - rescue SocketError - response = { status: false} - end + rescue Net::OpenTimeout + + response = { status: false , message: "Can't open embership server "} + + rescue OpenURI::HTTPError + response = { status: false, message: "Can't open embership server "} + + rescue SocketError + response = { status: false, message: "Can't open embership server "} + end if response["status"] == true customer = Customer.find(@crm_customers.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) @@ -125,14 +129,14 @@ class Crm::CustomersController < BaseCrmController else # @crm_customers.destroy if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '} + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' + response[:message]} else - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' } + format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created.' + response[:message] } end end else if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. '} + format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created. noted'} else format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created. ' } end @@ -231,7 +235,7 @@ end ) rescue Net::OpenTimeout response = { status: false } - + rescue OpenURI::HTTPError response = { status: false} diff --git a/app/models/customer.rb b/app/models/customer.rb index a26d857e..d6ba8bf1 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -27,16 +27,19 @@ class Customer < ApplicationRecord 'Content-Type' => 'application/json', 'Accept' => 'application/json' }, - :timeout => 10 + :timeout => 100 ) + rescue HTTParty::Error + response = {status: false, message: "Server Error"} + rescue Net::OpenTimeout - response = { status: false } + response = { status: false , message: "Server Time out"} rescue OpenURI::HTTPError - response = { status: false} + response = { status: false, message: "Can't connect server"} rescue SocketError - response = { status: false} + response = { status: false, message: "Can't connect server"} end return response; @@ -60,13 +63,13 @@ class Customer < ApplicationRecord :timeout => 10 ) rescue Net::OpenTimeout - response = { status: false } - + response = { status: false , message: "Server Time out"} + rescue OpenURI::HTTPError - response = { status: false} + response = { status: false, message: "Can't connect server"} rescue SocketError - response = { status: false} + response = { status: false, message: "Can't connect server"} end return response; diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 1d8a0e99..6f38d95f 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -331,15 +331,15 @@ class SalePayment < ApplicationRecord :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' - }, :timeout => 10) + }, :timeout => 100) rescue Net::OpenTimeout - response = { status: false } + response = { status: false , message: "Server Time out"} rescue OpenURI::HTTPError - response = { status: false} + response = { status: false, message: "Can't connect server"} rescue SocketError - response = { status: false} + response = { status: false, message: "Can't connect server"} end return response # puts response.to_json diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb index 9fa8020d..225b0036 100644 --- a/app/views/origami/shifts/show.html.erb +++ b/app/views/origami/shifts/show.html.erb @@ -32,7 +32,7 @@