From a74573709a1ab038f62ae3a134488f032d3ab05f Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Mon, 22 Apr 2019 14:24:16 +0630 Subject: [PATCH 001/171] - --- config/license.yml | 15 +++++++++++++++ config/puma.rb | 19 +++++++++---------- 2 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 config/license.yml diff --git a/config/license.yml b/config/license.yml new file mode 100644 index 00000000..42f5be11 --- /dev/null +++ b/config/license.yml @@ -0,0 +1,15 @@ +iv_key: 0zVzQvzlcJhc1d1EuA2HRg== +shop_name: aungcafe +email: devops@code2lab.com +telephone: +fax: +address: +dbhost: NGg7s8bJBfbDrkIeQhV+obOyEtgxtI3Dvf+b+eBm0P+r3aT+dBqHnwVEaIwsafXPFNXavhR/C0iyni1Lszkfyw== +dbschema: X+F4yj1eQlGPiMtsgZQCqWi2NIdBLUCEj35vF4XQDZc= +dbusername: 5CSlQR48ZAiRwWlTxzOZcw== +dbpassword: uzPlzsPjbWhJHcbStJSS0A== +api_token: RaZKWQwnKpvbdJvyAiMGGZPUKuJkWbE +app_token: dCKGOGvdFsCzOUrvhdrFqoOaAUzwtEUC +plan_sku: Qy0IoCIrNawRA2WjS3aLPg== +renewable_date: vGwTpixrL9biHkxdRdGctA== +plan_name: E9Njdqdou4eMpPaWDevpT95fpksDti2xvY+0u3PzKp0= diff --git a/config/puma.rb b/config/puma.rb index cd3f0829..1ce2a468 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,11 +1,10 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path +#application_path="#{File.expand_path("../..", __FILE__)}" +#directory application_path #environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! - +#environment "production" +#pidfile "#{application_path}/tmp/puma/pid" +#state_path "#{application_path}/tmp/puma/state" +#stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +#port ENV.fetch("PORT") { 62158 } +#workers 2 +#preload_app! From 8f81eb8e4aec179265ccc716c56c1721c9364a36 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Mon, 22 Apr 2019 17:24:20 +0630 Subject: [PATCH 002/171] customer filter with card no --- app/controllers/crm/customers_controller.rb | 7 ++++++- app/views/crm/customers/index.html.erb | 16 +++++++++++++++- config/initializers/action_controller.rb | 10 +++++----- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 0af08e5d..21c2d373 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -6,8 +6,13 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers.json def index filter = params[:filter] + filter_card_no = params[:filter_card_no] type = params[:type] - if filter.nil? + if filter_card_no=="" + @crm_customers = Customer.all + elsif !filter_card_no.nil? + @crm_customers=Customer.where("card_no=?",filter_card_no) + elsif filter.nil? || filter_card_no=="" @crm_customers = Customer.all else @crm_customers = Customer.search(filter) diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index b949291b..76d1dce8 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -15,7 +15,7 @@
-
+
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
@@ -32,6 +32,20 @@
<% end %>
+
+ <%= form_tag crm_customers_path, :method => :get do %> +
+
+ +
+
+ + + +
+
+ <%end %> +
diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index fb212f13..cab8fe5d 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class 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 From fe08f6854dd7baad2378f1f09497e9be990edad8 Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 24 Apr 2019 13:52:55 +0630 Subject: [PATCH 003/171] menu category code nil case fixed --- app/models/sale.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/sale.rb b/app/models/sale.rb index 47c3790f..e2eb4058 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -259,6 +259,7 @@ class Sale < ApplicationRecord sale_item.menu_category_code = menu_category.code sale_item.menu_category_name = menu_category.name else + sale_item.menu_category_code = '0' sale_item.menu_category_name = "Product" end sale_item.product_code = item.item_code From b18c03551608192f05509e3140f8caaa1b23ec2a Mon Sep 17 00:00:00 2001 From: Git Code2lab Date: Fri, 26 Apr 2019 06:31:23 +0000 Subject: [PATCH 004/171] Update puma.rb --- config/puma.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/config/puma.rb b/config/puma.rb index a50fe4ad..fd89392f 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -# application_path="#{File.expand_path("../..", __FILE__)}" -# directory application_path -# #environment ENV.fetch("RAILS_ENV") { "production" } -# environment "production" -# pidfile "#{application_path}/tmp/puma/pid" -# state_path "#{application_path}/tmp/puma/state" -# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -# port ENV.fetch("PORT") { 62158 } -# workers 2 -# preload_app! +application_path="#{File.expand_path("../..", __FILE__)}" +directory application_path +#environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +port ENV.fetch("PORT") { 62158 } +workers 2 +preload_app! From c98062eb9e1b697a097e062ec94d24a25d1dc7d0 Mon Sep 17 00:00:00 2001 From: Git Code2lab Date: Fri, 26 Apr 2019 06:32:16 +0000 Subject: [PATCH 005/171] Update action_controller.rb --- config/initializers/action_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index cab8fe5d..5abb412e 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class 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 From c85a5f4b101d619b20585e9b49edadea98661e2b Mon Sep 17 00:00:00 2001 From: Git Code2lab Date: Fri, 26 Apr 2019 06:32:49 +0000 Subject: [PATCH 006/171] Delete license.yml --- config/license.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 config/license.yml diff --git a/config/license.yml b/config/license.yml deleted file mode 100644 index 42f5be11..00000000 --- a/config/license.yml +++ /dev/null @@ -1,15 +0,0 @@ -iv_key: 0zVzQvzlcJhc1d1EuA2HRg== -shop_name: aungcafe -email: devops@code2lab.com -telephone: -fax: -address: -dbhost: NGg7s8bJBfbDrkIeQhV+obOyEtgxtI3Dvf+b+eBm0P+r3aT+dBqHnwVEaIwsafXPFNXavhR/C0iyni1Lszkfyw== -dbschema: X+F4yj1eQlGPiMtsgZQCqWi2NIdBLUCEj35vF4XQDZc= -dbusername: 5CSlQR48ZAiRwWlTxzOZcw== -dbpassword: uzPlzsPjbWhJHcbStJSS0A== -api_token: RaZKWQwnKpvbdJvyAiMGGZPUKuJkWbE -app_token: dCKGOGvdFsCzOUrvhdrFqoOaAUzwtEUC -plan_sku: Qy0IoCIrNawRA2WjS3aLPg== -renewable_date: vGwTpixrL9biHkxdRdGctA== -plan_name: E9Njdqdou4eMpPaWDevpT95fpksDti2xvY+0u3PzKp0= From 6fd644d677c18ca7a1f91d3e740a663724ccc2b7 Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 2 May 2019 12:12:16 +0630 Subject: [PATCH 007/171] sale.rb --- app/models/sale.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index e2eb4058..47c3790f 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -259,7 +259,6 @@ class Sale < ApplicationRecord sale_item.menu_category_code = menu_category.code sale_item.menu_category_name = menu_category.name else - sale_item.menu_category_code = '0' sale_item.menu_category_name = "Product" end sale_item.product_code = item.item_code From b2532ce5f3f379e173b7caf5e2f5f94df313dad1 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Wed, 8 May 2019 17:59:57 +0630 Subject: [PATCH 008/171] show response errors,sync and update member --- app/controllers/crm/customers_controller.rb | 200 ++++++++++++++++---- app/views/crm/customers/index.html.erb | 24 ++- app/views/layouts/CRM.html.erb | 14 +- config/routes.rb | 2 + db/seeds.rb | 8 +- 5 files changed, 203 insertions(+), 45 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 21c2d373..5979ce21 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -1,6 +1,6 @@ class Crm::CustomersController < BaseCrmController load_and_authorize_resource except: [:create] - before_action :set_crm_customer, only: [:show, :edit, :update, :destroy] + before_action :set_crm_customer, only: [:show, :edit, :update, :destroy,:sync] # GET /crm/customers # GET /crm/customers.json @@ -8,6 +8,7 @@ class Crm::CustomersController < BaseCrmController filter = params[:filter] filter_card_no = params[:filter_card_no] type = params[:type] + @customer_update_phone_email =false if filter_card_no=="" @crm_customers = Customer.all elsif !filter_card_no.nil? @@ -16,25 +17,44 @@ class Crm::CustomersController < BaseCrmController @crm_customers = Customer.all else @crm_customers = Customer.search(filter) + paymal_customer = Customer.search_paypar_account_no(filter) # search account no from paypar - if !@crm_customers.present? && type == "card" - response = Customer.search_paypar_account_no(filter) - if response["status"] == true - @crm_customers = Customer.new - @crm_customers.name = response["customer_data"]["name"] - @crm_customers.contact_no = response["customer_data"]["phone"] - @crm_customers.email = response["customer_data"]["email"] - @crm_customers.date_of_birth = response["customer_data"]["DOB"] - @crm_customers.nrc_no = response["customer_data"]["NRC"] - @crm_customers.address = response["customer_data"]["address"] - @crm_customers.card_no = response["customer_data"]["customer_card_no"] - @crm_customers.paypar_account_no = filter - @crm_customers.membership_id = response["customer_data"]["id"] - @crm_customers.membership_type = response["customer_data"]["member_group_id"] - @crm_customers.customer_type = "Dinein" - @crm_customers.tax_profiles = ["1", "2"] - @crm_customers.save - @crm_customers = Customer.search(filter) + if type == "card" + + response = Customer.search_paypar_account_no(filter) + if !@crm_customers.present? + if response["status"] == true + @crm_customers = Customer.new + @crm_customers.name = response["customer_data"]["name"] + @crm_customers.contact_no = response["customer_data"]["phone"] + @crm_customers.email = response["customer_data"]["email"] + @crm_customers.date_of_birth = response["customer_data"]["DOB"] + @crm_customers.nrc_no = response["customer_data"]["NRC"] + @crm_customers.address = response["customer_data"]["address"] + @crm_customers.card_no = response["customer_data"]["customer_card_no"] + @crm_customers.paypar_account_no = filter + @crm_customers.membership_id = response["customer_data"]["id"] + @crm_customers.membership_type = response["customer_data"]["member_group_id"] + @crm_customers.customer_type = "Dinein" + @crm_customers.tax_profiles = ["1", "2"] + @crm_customers.save + @crm_customers = Customer.search(filter) + flash[:notice]='Customer was successfully created.' + else + flash[:error]=response["message"] + end + else + @crm_customers.each do |customer| + if customer.contact_no != response["customer_data"]["phone"] + @customer_update_phone_email =true + end + if customer.email != response["customer_data"]["email"] + @customer_update_phone_email =true + end + if customer.name != response["customer_data"]["name"] + @customer_update_phone_email =true + end + end end end end @@ -69,6 +89,7 @@ class Crm::CustomersController < BaseCrmController # if flash["errors"] # @crm_customer.valid? # end + # puts @crm_customers.to_json respond_to do |format| format.html # index.html.erb format.json { render json: @crm_customers } @@ -120,7 +141,91 @@ class Crm::CustomersController < BaseCrmController def edit @customer = Customer.find(params[:id]) end + def sync + @customer = Customer.find(params[:id]) + respond_to do |format| + 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 + paypar_account_no = @customer.paypar_account_no + id = @crm_customer.membership_id + member_group_id = @customer.membership_type + if !id.present? && !member_group_id.nil? + 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 + member_params = { name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc,card_no:card_no, + member_group_id: member_group_id, + id:id, + merchant_uid:merchant_uid,auth_token:auth_token}.to_json + + # Check for paypar account exists + # if paypar_account_no != nil || paypar_account_no != '' + if paypar_account_no.present? + member_params = { name: name,phone: phone,email: email, + dob: dob,address: address,nrc:nrc,card_no:card_no, + paypar_account_no: paypar_account_no, + member_group_id: member_group_id, + id:id, + merchant_uid:merchant_uid,auth_token:auth_token}.to_json + end + + begin + response = HTTParty.post(url, + :body => member_params, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json; version=3' + }, + :timeout => 10 + ) + rescue Net::OpenTimeout + response = { status: false } + + rescue OpenURI::HTTPError + response = { status: false} + + rescue SocketError + response = { status: false} + end + customer = Customer.find(@crm_customer.customer_id) + Rails.logger.debug "--------Sync Member response -------" + Rails.logger.debug response.to_json + if response["status"] == true + + status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) + + format.html { redirect_to crm_customers_path } + flash[:member_notice] ='Member was successfully synced' + else + # Check membership id and bind to user + if response["membership_id"] != nil + status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id ) + format.html { redirect_to crm_customers_path } + flash[:member_notice] ='Member was successfully synced' + else + status = customer.update_attributes(membership_type:member_group_id) + end + # When paypar account no not exist in paypar + if response["message"] == "Account does not exist." + customer.destroy + format.html { redirect_to crm_customers_path } + flash[:member_error] ='Member cannot created.Invalid Account.' + end + format.html { redirect_to crm_customers_path } + flash[:member_error] =response["message"] + end + end + end + end # POST /crm/customers # POST /crm/customers.json def create @@ -196,9 +301,11 @@ class Crm::CustomersController < BaseCrmController status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id ) if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' } + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] } + flash[:member_notice]='Member was successfully created.' else - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Member was successfully created.' end # format.json { render :index, status: :created, location: @crm_customers } else @@ -207,24 +314,28 @@ class Crm::CustomersController < BaseCrmController # Check membership id and bind to user if response["membership_id"] != nil status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id ) + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Member was successfully created.' else status = customer.update_attributes(membership_type:member_group_id) end - # When paypar account no not exist in paypar - if response["message"] == "Account has not exist." + if response["message"] == "Account does not exist." customer.destroy if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer cannot created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] } + flash[:member_error]='Member cannot created.Invalid Account.' else - format.html { redirect_to crm_customers_path, notice: 'Customer cannot created.' + response["message"] } + format.html { redirect_to crm_customers_path } + flash[:member_error]='Member cannot created.Invalid Account.' end end - if params[:sale_id] - format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page], notice: 'Customer was successfully created.' + response["message"]} + format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] } + flash[:member_notice]='Member 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 } + # flash[:member_notice]='Member was successfully created.' end end else @@ -333,16 +444,19 @@ class Crm::CustomersController < BaseCrmController 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'} + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Member was successfully updated' else # Check membership id and bind to user if response["membership_id"] != nil status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id ) + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Member was successfully updated' else status = customer.update_attributes(membership_type:member_group_id) + format.html { redirect_to crm_customers_path } + flash[:member_error]=response["message"] end - - format.html { redirect_to crm_customers_path, notice: response["error"] } end else membership = MembershipSetting.find_by_membership_type("paypar_url") @@ -395,7 +509,8 @@ class Crm::CustomersController < BaseCrmController else status = customer.update_attributes(membership_type:member_group_id ) end - format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' } + format.html { redirect_to crm_customers_path } + flash[:member_notice] ='Member was successfully updated.' format.json { render :show, status: :ok, location: @crm_customer } else customer = Customer.find(@crm_customer.customer_id) @@ -405,7 +520,8 @@ class Crm::CustomersController < BaseCrmController else status = customer.update_attributes(membership_type:member_group_id ) end - format.html { redirect_to crm_customers_path, notice: response["message"] } + format.html { redirect_to crm_customers_path } + flash[:member_error] =response["message"] end end else @@ -438,6 +554,23 @@ class Crm::CustomersController < BaseCrmController end end + def customer_update_phone_email + @customer = Customer.find(params[:id]) + response = Customer.search_paypar_account_no(@customer.paypar_account_no) + if response["status"] == true + @customer.name =response["customer_data"]["name"] + @customer.contact_no =response["customer_data"]["phone"] + @customer.email =response["customer_data"]["email"] + @customer.save + respond_to do |format| + format.html { redirect_to crm_customers_path } + flash[:member_notice]='Membership was successfully updated' + end + end + + + end + private # Use callbacks to share common setup or constraints between actions. def set_crm_customer @@ -452,3 +585,4 @@ class Crm::CustomersController < BaseCrmController end end + diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 76d1dce8..6b9707f5 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -9,12 +9,27 @@
--> -
+
+
+ <% if flash[:member_notice] %> + + <% elsif flash[:member_error] %> + + <% end %> +
+
+
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
@@ -47,6 +62,7 @@ <%end %>
+
<%= paginate @crm_customers %> @@ -107,6 +123,12 @@ <%= crm_customer.card_no rescue '-' %> + <% if crm_customer.membership_id.nil? && !crm_customer.membership_type.nil? %> + <%= link_to t("views.btn.sync"), crm_customer_sync_path(crm_customer), :class => "btn btn-md bg-green waves-effect" %> + <% end %> + <% if @customer_update_phone_email %> + <%= link_to t("views.btn.update"), crm_customer_update_phone_email_path(crm_customer), :class => "btn btn-md bg-green waves-effect" %> + <% end %> <%= link_to t("views.btn.show"), crm_customer_path(crm_customer), :class => "btn btn-md bg-blue waves-effect" %> diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb index 8ba5d9c7..955abc98 100755 --- a/app/views/layouts/CRM.html.erb +++ b/app/views/layouts/CRM.html.erb @@ -46,18 +46,18 @@ <% flash.each do |type, message| %> <% if !flash["errors"]%> <% - if type == "notice" + if type == "notice" color = "alert-success" - elsif type == "error" + end + if type == "error" color = "alert-danger" - else - color = "bg-black" end %> - - +

+ <% end %> <% end %> <% end %> <%= yield %> diff --git a/config/routes.rb b/config/routes.rb index 89963f1e..f25ff1b8 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -358,6 +358,8 @@ scope "(:locale)", locale: /en|mm/ do namespace :crm do root "home#index" resources :customers + get "/customers/:id/sync" => "customers#sync", as:"customer_sync" + get "/customers/:id/customer_update_phone_email" => "customers#customer_update_phone_email", as:"customer_update_phone_email" resources :dining_queues post "update_booking", to: "bookings#update_booking", as: "update_booking" #assign and cancel get '/print/:id', to: "home#print_order" #print order for crm diff --git a/db/seeds.rb b/db/seeds.rb index 7a139b6e..a2307479 100755 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -209,19 +209,19 @@ queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf zone = Zone.create({id:1, name: "H1", is_active:true, created_by: "SYSTEM DEFAULT"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paypar.ws",merchant_account_id:"pZBHXEFbGNj/G"}) +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.82:3001",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE"}) member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, + {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"}, + {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"}, {membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"} + {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"} ]) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws"}) From 672eaafc4201839ca8ee3566d9b34c40c89dc36a Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 9 May 2019 18:08:25 +0630 Subject: [PATCH 009/171] when delete item options to update in menu items --- 10 | 0 Can't open membership server } | 0 .../settings/menu_item_options_controller.rb | 20 ++++++++++++++++++- .../settings/simple_menu_items_controller.rb | 1 - config/initializers/action_controller.rb | 10 +++++----- config/puma.rb | 20 +++++++++---------- db/seeds.rb | 8 ++++---- false, | 0 member_params, | 0 { | 0 10 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 10 create mode 100644 Can't open membership server } create mode 100644 false, create mode 100644 member_params, create mode 100644 { diff --git a/10 b/10 new file mode 100644 index 00000000..e69de29b diff --git a/Can't open membership server } b/Can't open membership server } new file mode 100644 index 00000000..e69de29b diff --git a/app/controllers/settings/menu_item_options_controller.rb b/app/controllers/settings/menu_item_options_controller.rb index 00791e5d..339039bf 100755 --- a/app/controllers/settings/menu_item_options_controller.rb +++ b/app/controllers/settings/menu_item_options_controller.rb @@ -55,7 +55,25 @@ class Settings::MenuItemOptionsController < ApplicationController # DELETE /settings/menu_item_options/1 # DELETE /settings/menu_item_options/1.json def destroy - @settings_menu_item_option.destroy + item_option_id =@settings_menu_item_option.id + item_option_id_string=""+item_option_id.to_s+"" + if @settings_menu_item_option.destroy + menu_items =MenuItem.all + menu_items.each do |item| + if item.item_options.include?(item_option_id) + item_update =item.item_options.reject { |i| i == item_option_id } + item.item_code =item.item_code + item.item_options =item_update + item.save + end + if item.item_options.include?(item_option_id_string) + item_update =item.item_options.reject { |i| i == item_option_id_string } + item.item_code =item.item_code + item.item_options =item_update + item.save + end + end + end flash[:notice] = 'Menu item option was successfully destroyed.' render :json => {:status=> "Success", :url => settings_menu_item_options_path }.to_json # respond_to do |format| diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index df70f61e..cd1c4507 100755 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -109,7 +109,6 @@ class Settings::SimpleMenuItemsController < ApplicationController @settings_menu_item.item_sets = sets end end - @settings_menu_item.menu_category_id = params[:menu_category_id] respond_to do |format| diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 5abb412e..7a123a02 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class 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/config/puma.rb b/config/puma.rb index fd89392f..6a545bed 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path -#environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! +# application_path="#{File.expand_path("../..", __FILE__)}" +# directory application_path +# #environment ENV.fetch("RAILS_ENV") { "production" } +# environment "production" +# pidfile "#{application_path}/tmp/puma/pid" +# state_path "#{application_path}/tmp/puma/state" +# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +# port ENV.fetch("PORT") { 62158 } +# workers 2 +# preload_app! diff --git a/db/seeds.rb b/db/seeds.rb index a2307479..9d498c2e 100755 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -209,19 +209,19 @@ queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf zone = Zone.create({id:1, name: "H1", is_active:true, created_by: "SYSTEM DEFAULT"}) -member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.82:3001",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE"}) +member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "https://staging.membership.paymal.ws",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) member_actions= MembershipAction.create([{membership_type:"get_account_balance",is_active:1,gateway_url:"/api/membership_campaigns/get_correspond_account_data",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"redeem",is_active:1,gateway_url:"/api/membership_campaigns/redeem",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"}, - {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"}, + {membership_type:"create_membership_customer",is_active:1,gateway_url:"/api/generic_customer/create_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, + {membership_type:"update_membership_customer",is_active:1,gateway_url:"/api/generic_customer/update_membership_customer",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_all_member_group",is_active:1,gateway_url:"/api/member_group/get_all_member_group",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"rebate",is_active:1,gateway_url:"/api/membership_campaigns/rebate",additional_parameter:{campaign_type_id:1},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_all_member_account",is_active:1,gateway_url:"/api/generic_customer/get_member_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_member_transactions",is_active:1,gateway_url:"/api/generic_customer/get_membership_transactions",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"member_discount",is_active:1,gateway_url:"/api/membership_campaigns/discount",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, {membership_type:"get_member_campaign",is_active:1,gateway_url:"/api/membership_campaigns/get_member_campaign",additional_parameter:{campaign_type_id:5},merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"}, - {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"NskNY4j3YxEg6h1Fm9AE",auth_token:"rj0MJ0XI5GsKZehE"} + {membership_type:"search_paypar_account_no",is_active:1,gateway_url:"/api/generic_customer/get_membership_customer_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"pZBHXEFbGNj/G"} ]) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://membership.paypar.ws"}) diff --git a/false, b/false, new file mode 100644 index 00000000..e69de29b diff --git a/member_params, b/member_params, new file mode 100644 index 00000000..e69de29b diff --git a/{ b/{ new file mode 100644 index 00000000..e69de29b From ae94a725164f353d6b260173a89ed8888068d328 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 9 May 2019 18:31:28 +0630 Subject: [PATCH 010/171] update condition for sync --- app/views/crm/customers/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 6b9707f5..3948d86f 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -123,7 +123,7 @@ <%= crm_customer.card_no rescue '-' %> - <% if crm_customer.membership_id.nil? && !crm_customer.membership_type.nil? %> + <% if crm_customer.membership_id.nil? && !crm_customer.membership_type.nil? && !crm_customer.membership_type =="" && !crm_customer.paypar_account_no =="" && !crm_customer.paypar_account_no.nil? %> <%= link_to t("views.btn.sync"), crm_customer_sync_path(crm_customer), :class => "btn btn-md bg-green waves-effect" %> <% end %> <% if @customer_update_phone_email %> From 66a6e5500ce18e6bc2dd6f2d03bbe7aabe11a104 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Mon, 13 May 2019 09:33:32 +0630 Subject: [PATCH 011/171] - --- config/initializers/action_controller.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 7a123a02..214da8ec 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -19,12 +19,12 @@ class ActionController::Base render :json => [{ status: false, message: 'Invalid Access!'}] end else - # check for license file - # if check_license - # current_license(ENV["SX_PROVISION_URL"]) - # else - # redirect_to activate_path - # end + check for license file + if check_license + current_license(ENV["SX_PROVISION_URL"]) + else + redirect_to activate_path + end end end From fe463c62e7a168aa25fcbbee160251c02b09ce04 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Mon, 13 May 2019 11:03:33 +0630 Subject: [PATCH 012/171] close comment print worker --- app/models/printer/printer_worker.rb | 26 ++++++++++++------------ config/initializers/action_controller.rb | 12 +++++------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/app/models/printer/printer_worker.rb b/app/models/printer/printer_worker.rb index fee19a31..8bbf1c6d 100755 --- a/app/models/printer/printer_worker.rb +++ b/app/models/printer/printer_worker.rb @@ -38,20 +38,20 @@ class Printer::PrinterWorker end def print(file_path,printer_destination = nil ) - if printer_destination.nil? - printer_destination = self.printer_destination - end + # if printer_destination.nil? + # printer_destination = self.printer_destination + # end - puts printer_destination - puts '........Printer Destination..........' + # puts printer_destination + # puts '........Printer Destination..........' - copy = self.print_copies - #Print only when printer information is not null - if !self.printer_destination.nil? - (1..copy).each do - page = Cups::PrintJob.new(file_path, printer_destination) - page.print - end - end + # copy = self.print_copies + # #Print only when printer information is not null + # if !self.printer_destination.nil? + # (1..copy).each do + # page = Cups::PrintJob.new(file_path, printer_destination) + # page.print + # end + # end end end diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 214da8ec..bea510a5 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -19,12 +19,12 @@ class ActionController::Base render :json => [{ status: false, message: 'Invalid Access!'}] end else - check for license file - if check_license - current_license(ENV["SX_PROVISION_URL"]) - else - redirect_to activate_path - end + # check for license file + # if check_license + # current_license(ENV["SX_PROVISION_URL"]) + # else + # redirect_to activate_path + # end end end From eb4309355de75979a671a17ffe52de67fabc4bbe Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 16 May 2019 12:09:48 +0630 Subject: [PATCH 013/171] un comment puma --- app/controllers/crm/customers_controller.rb | 2 +- .../menu_item_attributes_controller.rb | 21 ++++++++++++++++++- app/models/sale_payment.rb | 3 ++- config/puma.rb | 20 +++++++++--------- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 5979ce21..8133968a 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -17,7 +17,7 @@ class Crm::CustomersController < BaseCrmController @crm_customers = Customer.all else @crm_customers = Customer.search(filter) - paymal_customer = Customer.search_paypar_account_no(filter) + # paymal_customer = Customer.search_paypar_account_no(filter) # search account no from paypar if type == "card" diff --git a/app/controllers/settings/menu_item_attributes_controller.rb b/app/controllers/settings/menu_item_attributes_controller.rb index 8187d2a9..4ac48542 100755 --- a/app/controllers/settings/menu_item_attributes_controller.rb +++ b/app/controllers/settings/menu_item_attributes_controller.rb @@ -55,7 +55,26 @@ class Settings::MenuItemAttributesController < ApplicationController # DELETE /settings/menu_item_attributes/1 # DELETE /settings/menu_item_attributes/1.json def destroy - @settings_menu_item_attribute.destroy + item_attribute_id =@settings_menu_item_attribute.id + item_attribute_id_string=""+item_attribute_id.to_s+"" + if @settings_menu_item_attribute.destroy + menu_items =MenuItem.all + menu_items.each do |item| + if item.item_attributes.include?(item_attribute_id) + item_update =item.item_attributes.reject { |i| i == item_attribute_id } + item.item_code =item.item_code + item.item_attributes =item_update + item.save + end + if item.item_attributes.include?(item_attribute_id_string) + item_update =item.item_attributes.reject { |i| i == item_attribute_id_string } + item.item_code =item.item_code + item.item_attributes =item_update + item.save + end + end + end + # @settings_menu_item_attribute.destroy flash[:notice] = 'Menu item attribute was successfully destroyed.' render :json => {:status=> "Success", :url => settings_menu_item_attributes_path }.to_json # respond_to do |format| diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 9d418f7b..f3c076ae 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -178,7 +178,8 @@ class SalePayment < ApplicationRecord def self.redeem(paypar_url,token,membership_id,received_amount,sale_id) # membership_actions_data = MembershipAction.find_by_membership_type("redeem"); membership_actions_data = PaymentMethodSetting.find_by_payment_method("Redeem") - + puts "This is membership_actions_data" + puts membership_actions_data.to_json if !membership_actions_data.nil? url = paypar_url.to_s + membership_actions_data.gateway_url.to_s diff --git a/config/puma.rb b/config/puma.rb index 6a545bed..fd89392f 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -# application_path="#{File.expand_path("../..", __FILE__)}" -# directory application_path -# #environment ENV.fetch("RAILS_ENV") { "production" } -# environment "production" -# pidfile "#{application_path}/tmp/puma/pid" -# state_path "#{application_path}/tmp/puma/state" -# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -# port ENV.fetch("PORT") { 62158 } -# workers 2 -# preload_app! +application_path="#{File.expand_path("../..", __FILE__)}" +directory application_path +#environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +port ENV.fetch("PORT") { 62158 } +workers 2 +preload_app! From acb81aa2ab0cbcf57faa1de2faaddc01004009c3 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 16 May 2019 12:11:53 +0630 Subject: [PATCH 014/171] comment --- config/initializers/action_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 214da8ec..5abb412e 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -19,7 +19,7 @@ class ActionController::Base render :json => [{ status: false, message: 'Invalid Access!'}] end else - check for license file + # check for license file if check_license current_license(ENV["SX_PROVISION_URL"]) else From da7c3441794bbcac25bce34bcffa74d62f4f8a4a Mon Sep 17 00:00:00 2001 From: Zoey Date: Thu, 16 May 2019 14:10:57 +0630 Subject: [PATCH 015/171] foc error --- app/controllers/crm/customers_controller.rb | 2 +- app/models/sale_item.rb | 4 ++-- app/pdf/order_item_pdf.rb | 1 + app/pdf/order_item_slim_pdf.rb | 1 + app/pdf/receipt_bill_pdf.rb | 11 ++++++----- config/initializers/action_controller.rb | 10 +++++----- config/puma.rb | 18 +++++++++--------- dump.rdb | Bin 908 -> 1084 bytes 8 files changed, 25 insertions(+), 22 deletions(-) mode change 100755 => 100644 dump.rdb diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 21c2d373..52149abb 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -165,7 +165,7 @@ class Crm::CustomersController < BaseCrmController paypar_account_no: paypar_account_no, member_group_id: member_group_id, merchant_uid:merchant_uid,auth_token:auth_token}.to_json - end + end begin response = HTTParty.post(url, diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 13f295a9..c69e3626 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -180,10 +180,10 @@ class SaleItem < ApplicationRecord def self.get_all_sale_items(sale_id) sale_items = SaleItem.select("sale_id,product_code,item_instance_code, product_name,product_alt_name,account_id,status,remark, - (CASE WHEN (qty > 0 AND remark IS NULL) OR (qty < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty, + (CASE WHEN (qty > 0 AND remark IS NULL) OR (qty < 0 AND status = 'foc') OR (qty < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(qty) ELSE qty END) as qty, unit_price, taxable_price, - (CASE WHEN (price > 0 AND remark IS NULL) OR (price < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price, + (CASE WHEN (price > 0 AND remark IS NULL) OR (qty < 0 AND status = 'foc') OR (price < 0 AND status='Discount') OR (status='promotion' AND (remark='promotion' OR remark = 'promotion nett price' OR remark= 'promotion discount')) THEN SUM(price) ELSE price END) as price, is_taxable") .where("sale_id = ?",sale_id) .order("product_name asc") diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index f3883627..f872d608 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -1,6 +1,7 @@ class OrderItemPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(print_settings,order_item, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb index 83df19da..33e1e314 100755 --- a/app/pdf/order_item_slim_pdf.rb +++ b/app/pdf/order_item_slim_pdf.rb @@ -1,6 +1,7 @@ class OrderItemSlimPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width + def initialize(print_settings,order_item_slim, print_status, options, alt_name, before_updated_qty) self.page_width = print_settings.page_width self.page_height = print_settings.page_height diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 573dd1ee..fbb15b1b 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -408,13 +408,13 @@ class ReceiptBillPdf < Prawn::Document sale_payments.each do |payment| y_position = cursor if payment.payment_method == "paypar" - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + 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 + end else - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + 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 end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do @@ -432,7 +432,7 @@ class ReceiptBillPdf < Prawn::Document text "#{number_with_precision(sale_data.amount_changed, :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end # move_down line_move - end + end end # show member information @@ -538,6 +538,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ customer_name }" , :size => self.item_font_size,:align => :right end move_down line_move + stroke_horizontal_rule end diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 5abb412e..cab8fe5d 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class 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/config/puma.rb b/config/puma.rb index fd89392f..fbe48c81 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path +#application_path="#{File.expand_path("../..", __FILE__)}" +#directory application_path #environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! +#environment "production" +#pidfile "#{application_path}/tmp/puma/pid" +#state_path "#{application_path}/tmp/puma/state" +#stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +#port ENV.fetch("PORT") { 62158 } +#workers 2 +#preload_app! diff --git a/dump.rdb b/dump.rdb old mode 100755 new mode 100644 index 7d7b359cf467d72ccdedbb6c289ac7f4a3c49f3d..87e22f1d49653abdc6c0f99faa01b9c718bc686f GIT binary patch literal 1084 zcmaJ=L5tHs7@d@~tL|E44~h%YGI)|snM{&q5-$}LT*ZqXJgC&9nQkLV(>u!7qCM!`}#CHm&D9P0SgZA{@McBmK_ezIAV6-_$&p-;OEW; zsK?yq);J3LEEd(X&(i$u_jeCoNdSPWr!k9Q#Y9*~n9g1Uu$iL++w+;5R>0*GpNmQZ zVFM{N1w{xu$@Ku#l_Vw!;nE~Vu?Yo$FGR_0%jdjIUvjFc4_7RtiYfByQk%Uq0N z+Z3t7_WVcv35%r-mksR1=Oq&@o0fp9pw?ZAaD`E&G{O~FKoe@^ zG>R}urTOD)_ddK3cO&ogLzfZXb}W?=)6yKQ(~jvnL^I^-B=H!Rd6Y2O8x6vv?)&ah z<0Tx1F(26hgBJYDhAk*=D&oxTHEa$oMb`~#Vy#2ls)i|{S__Un7cNw)W(#tAuX*#L z8^k@A?fc<4U?bkV)#!(#eiB7&)Sp6&=q#)Ept&h|ZgaPL<(u^8c~n0&3p|h=X7lZZFOy(m8f`5LZ7*1-obz3YbY{gTTu?G)Hm`t+f!-E0!;8joJN0}t=b_cS_c4ktIB6#vI z^x(mIQv44>sQWZ|QWb7FtvkJO!)>mItJ z`UXBJspWWstn`03C)CSNS(dVFHYsy6&10GdWJLT?U{l9UA`2qV_uG_~1~yL*QLVN8 zb&W+$?V~k|uB`4CP=HX^5*X7Wl^qj%M!nVQ_s2(Xu02u}Mf)H7nidtJtQ3u9E7_h z8S#X}(9sG`GdaAz9_LwHa1L2qhF8w(sELPy`=|*R?hGbuZ?Ze%Eayy?=%J2M8bKQF z3^z2EKqkYBU;3|Kl$)ovK+k*o1q0a|(^P;K0hJeOgATDh-?2>B@;uieKVQ9n@bd7j GdiV?6cOB9I From 7c58a5a662067ab16c644c654800f202830189b2 Mon Sep 17 00:00:00 2001 From: Zoey Date: Mon, 20 May 2019 14:50:01 +0630 Subject: [PATCH 016/171] update --- 10 | 0 Can't open membership server } | 0 app/pdf/close_cashier_pdf.rb | 1 + app/pdf/crm_order_pdf.rb | 2 +- config/initializers/action_controller.rb | 10 +++++----- config/puma.rb | 20 ++++++++++---------- dump.rdb | Bin 1084 -> 810 bytes false, | 0 member_params, | 0 { | 0 10 files changed, 17 insertions(+), 16 deletions(-) delete mode 100644 10 delete mode 100644 Can't open membership server } delete mode 100644 false, delete mode 100644 member_params, delete mode 100644 { diff --git a/10 b/10 deleted file mode 100644 index e69de29b..00000000 diff --git a/Can't open membership server } b/Can't open membership server } deleted file mode 100644 index e69de29b..00000000 diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 2a42a98d..541c6df4 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -175,6 +175,7 @@ class CloseCashierPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right end + #start other payment details if shift_sale.other_sales > 0 other_payment.each do |other| diff --git a/app/pdf/crm_order_pdf.rb b/app/pdf/crm_order_pdf.rb index f9367907..978f7137 100755 --- a/app/pdf/crm_order_pdf.rb +++ b/app/pdf/crm_order_pdf.rb @@ -35,7 +35,7 @@ class CrmOrderPdf < Prawn::Document end header( printer_settings.printer_name, printer_settings.name) - stroke_horizontal_rule + stroke_horizontal_rule cashier_info(booking) line_items(order_items) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index cab8fe5d..fb212f13 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class 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/config/puma.rb b/config/puma.rb index fbe48c81..6f7c4941 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -#application_path="#{File.expand_path("../..", __FILE__)}" -#directory application_path -#environment ENV.fetch("RAILS_ENV") { "production" } -#environment "production" -#pidfile "#{application_path}/tmp/puma/pid" -#state_path "#{application_path}/tmp/puma/state" -#stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -#port ENV.fetch("PORT") { 62158 } -#workers 2 -#preload_app! +application_path="#{File.expand_path("../..", __FILE__)}" +directory application_path +# environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +port ENV.fetch("PORT") { 62158 } +workers 2 +preload_app! diff --git a/dump.rdb b/dump.rdb index 87e22f1d49653abdc6c0f99faa01b9c718bc686f..3ad69d64503187cb2dcd180818e6aa49d528061d 100644 GIT binary patch delta 258 zcmdnPv5IYip+@+;dojN_N{drdbaPX44=J$lF#O_4%umxTC`wJtP0C3G6IcD<%sgnbk#3e0sjVuqaG4K_aB$ike6y+zU z76Tn}@H8VxcJe$XHV_RnOmeaT6Whcbjmde8QY^DxZT6kq!zj&YG4Z3=#0zY!f4=eU vFPvB?D`IGR@B{+`H`vIu#LS%3lmkp)<32FUOg_NK!ukKA9dmq+_18@R*PvJS delta 529 zcmY+9Pm9w)7>8#{n(ne|@o&4WtSy5GEA5(0nr0?m;!Oq59#m@5Ot+DwNt20CWZ9!P zG0Z{q=GBXW7eT?)y$F5*!HZ`V;Du9U{tSS% zBVc5EK6A6fnz#Zhq6E*0Hzg@c>cWG~ENDrX=CXJV>ypt`iFgdR3g(P#ba6ii*-N^r zDLGjFtbUvphc|1gKK~3#@-$^BOJK!iBRlnZ(QiO4i<&|y$pXT&674E#Hf_j%XAX+! ze8xBS6r985?aiC-A3y-4<}h>__HD=12&QJwQFPL$u7i7qRGy|D;}VZkCV7)lxNp6) z_FIq8I86A&4j3}g|2FENLNw;g9kgtYOjXwnLX}>hY->G*VAAWL$a9gY?Gaq29mMUO z_SF+^kPKY*&<~@4O?dlSYZy+3X&kf3aE45*chEmcWZpqXn!vX%o*a8S<3SXAVeIi4 zy4OMNUC4?>dkuPS`-WBj4xitTtH)%}uH-PApH^$dXA~=#8rz0SDAtJNq{&RArArxa Thz(fJzHY4^YHD(Dxg3B$uAHa^ diff --git a/false, b/false, deleted file mode 100644 index e69de29b..00000000 diff --git a/member_params, b/member_params, deleted file mode 100644 index e69de29b..00000000 diff --git a/{ b/{ deleted file mode 100644 index e69de29b..00000000 From 647517b27c37931f4c41fc737095982900bb4121 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Wed, 22 May 2019 13:47:23 +0630 Subject: [PATCH 017/171] add close cashier print setting --- README.md | 71 +++++----- app/controllers/origami/shifts_controller.rb | 34 +++-- .../reports/shiftsale_controller.rb | 68 +++++++++- app/models/printer/cashier_station_printer.rb | 10 +- app/models/sale.rb | 119 +++++++++-------- app/views/reports/shiftsale/index.html.erb | 126 ++++++++++-------- config/routes.rb | 27 ++-- 7 files changed, 270 insertions(+), 185 deletions(-) diff --git a/README.md b/README.md index 0621cc43..6ccf5e80 100755 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Osaka => Campaign Id => {"campaign_type_id": 5} BITP - Auth Token => pZBHXEFbGNj/G => New => V3 + Auth Token => pZBHXEFbGNj/G => New => V3 iua0SjUHzRaQw => rj0MJ0XI5GsKZehE => Old => V2 => code2lab => Old @@ -34,11 +34,11 @@ Person and Extra Time 2) must create Adult and Child in settings/item_attributes 3) must be PSA_[a-z/0-9] for Adult and PSC_[a-z/0-9] for Child in settings/menu_categories/[cat_id]/simple_menu_items 3) must be PSAI_[a-z/0-9] for Adult and PSCI_[a-z/0-9] for Child in settings/simple_menu_items/[item_id]/menu_item_instances - -For Extra Time - item_instance_code + +For Extra Time + item_instance_code * must start with 'Ext'[a..z]'_'[1..100] - * note : don't add character after '_' + * note : don't add character after '_' For Order Printing 1)) ********* Order Pdf ********* @@ -50,18 +50,18 @@ For Order Printing 1) settings/print_settings (a) Unique Code => OrderSetItemPdf & OrderSummarySetPdf (b) Font is present => {Header font size:11, Item Font Size:9} - Font is blank => {Header font size:12, Item Font Size:10} + Font is blank => {Header font size:12, Item Font Size:10} 3)) ********* Order Slim Pdf ********* 1) settings/print_settings (a) Unique Code => OrderItemSlimPdf & OrderSummarySlimPdf (b) Font is present => {Header font size:11, Item Font Size:9} Font is blank => {Header font size:12, Item Font Size:10} 4)) ********* Order Customise PDF ********* - 1) settings/print_settings + 1) settings/print_settings (a) Unique Code => OrderItemCustomisePdf & OrderSummaryCustomisePdf - (b) Can change Header font size and Item Font Size as you like + (b) Can change Header font size and Item Font Size as you like 5)) ********* Order Set Pdf ********* - 1) settings/print_settings + 1) settings/print_settings (a) Unique Code => OrderSetItemCustomisePdf & OrderSummarySetCustomisePdf (b) Can change Header font size and Item Font Size as you like 6)) ********* Order Slim Customise PDF @@ -100,20 +100,20 @@ For call waiter pdf i) Name : Calling Waiter ii) Unique Code: CallWaiterPdf iii)Template: ... - iv) Font: Zawgyi-One + iv) Font: Zawgyi-One v) Printer: #printer name Membership Actions SQL * update membership_actions set additional_parameter='{\"campaign_type_id\":5}' where id=10; SQL Update after rake clear:data runned - * update seed_generators + * update seed_generators i) TableBooking, Order, OrderItem, sale, SaleOrder, SaleItem, SaleTax, SalePayment, SaleAudit, AssignedOrderItem => { current:0, next:0 } - ** Note :: do not update Customer + ** Note :: do not update Customer 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 TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for table => ALTER DATABASE [database_name] CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database For split bill @@ -124,9 +124,9 @@ For Sidekiq => Create New Lookups => lookup_type = sidekiq, Name = sidekiq , Value = 1 or 0 For Clear Menu - 1) rake clear:menu # menu,menu item,menu category,menu item instance,account,item option,item attribute,item set - -For Check CUp status + 1) rake clear:menu # menu,menu item,menu category,menu item instance,account,item option,item attribute,item set + +For Check CUp status ###please open sudo cat /etc/sudoers ### cope and parse @@ -177,16 +177,16 @@ For CloseCashierCustomisePdf in lookups 1) settings/print_settings 2) settings/lookups => { type:print_settings, name: CloseCashierCustomisePdf, value:1 } -<---- Extra Fields Script -----> -For MoveTablePdf in lookups +<---- Extra Fields Script -----> +For MoveTablePdf in lookups *** Both Table and Room Moving *** 1) settings/lookups => { type:print_settings, name: MoveTablePdf, value:1 } -For MoveTablePdf in print settings - * Backend > Printer > Print Settings > New - i) Name : Move Table - ii) Unique Code: MoveTablePdf - iii)Template: ... +For MoveTablePdf in print settings + * Backend > Printer > Print Settings > New + i) Name : Move Table + ii) Unique Code: MoveTablePdf + iii)Template: ... iv) Font: Zawgyi-One v) Printer: #printer name /* Tax Profile Group Types in lookups */ @@ -200,7 +200,7 @@ For MoveTablePdf in print settings 1) settings/lookups => { type:ReceiptPdfView, name: Receipt Pdf View, value:1 or 0 } => 1 is active and 0 is in-active -Add Kitchen Role of Employee +Add Kitchen Role of Employee => 1) settings/lookups => { type:employee_roles, name: Kitchen, value:kitchen } Add Base URL for DOEMAL @@ -235,12 +235,12 @@ For Login expiry time Menu Image (Import guideline) - => First, check shop_code, is there in shops table and prefix shop_code in image name? + => First, check shop_code, is there in shops table and prefix shop_code in image name? => You all must do this step * If there is shop_code in shops table (mark in one place/ note and set NULL for this record for a while) and prefix shop_code for image name (like (121_ABC.png)), and copy and paste images into Application/[sxrestaurant]/public/image/menu_images. * If there is shop_code/ no shop_code in shops table but no prefix in image name (* skip set NULL step) , copy and paste images into Application/…./image/menu_images. => Second, import [menu].xlsx file in /settings/menus and then checked image is uploaded into Application/[sxrestaurant]/public/image/menu_images and insert into menu_items table in database. - => Last, if shop has shop_code, update marked/noted shop_code into shops table again. + => Last, if shop has shop_code, update marked/noted shop_code into shops table again. For Edit Order Open & Close 1) settings/lookups => {type:edit_order, name:EditOrderOrigami, value: {1 or 0}} @@ -273,13 +273,16 @@ For Online Order Receipt Setting 1) settings/lookups => { type:order_reservation, name:ReceiptBill, value: {0 or 1} } 2) settings/print_settings => {name: ReceiptBillOrder, unique_code: ReceiptBillOrderPdf, ....} +For Close Cashier Print Settings +settings/lookups => {type:close_cashier_print, name:CloseCashierPrint, value: {0 or 1} } + * ToDo list 1. Migration 2. Quick Service 3. Order & Reservation - + * System Dependencies * Configuration @@ -299,7 +302,7 @@ For Online Order Receipt Setting 1. OQS - 1. Filter + 1. Filter 2. Order Item to each Stations 3. Edit Order Item @@ -313,12 +316,12 @@ For Online Order Receipt Setting 3. CRM - 1. Customer Management + 1. Customer Management 2. Queue Management - + 4. Backend - + 1. Dining Setup 2. Queue Station Setup @@ -355,19 +358,17 @@ For Online Order Receipt Setting 1. 2-Column => Main Content - col-9, Information - col-3 2. 3-Column => Sub Lint - col-2, Main Content - col-7, Information - col-3 - > Pixel + > Pixel Main Header Bar - height => 50 px Side Navigation - Weight => 230 px Main Content Padding => 15 px 2. Color - + > BUTTON 1. Submit/Add/Edit/Confirm buttons => btn-primary (theme color) 2. Show/Detail Buttons => btn-info 3. Delete => btn-delete 4. Cancel/Back => btn-default - - diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 52ac1571..58b68ddb 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -26,7 +26,7 @@ class Origami::ShiftsController < BaseOrigamiController cashier_terminal = CashierTerminal.find(cashier_terminal_param) if cashier_terminal.is_currently_login respond_to do |format| - format.html { redirect_to settings_order_queue_stations_url, notice: 'Cashier Terminal already signin!' } + format.html { redirect_to settings_order_queue_stations_url, notice: 'Cashier Terminal already signin!' } end end @@ -38,17 +38,19 @@ class Origami::ShiftsController < BaseOrigamiController @shift_sale.create(opening_balance,cashier_terminal_param, current_user) end + + def update_shift closing_balance = params[:closing_balance] shift_id = params[:shift_id] @shift = ShiftSale.find_by_id(shift_id) if @shift @shift.shift_closed_at = DateTime.now.utc - @shift.closing_balance = closing_balance.to_f + @shift.closing_balance = closing_balance.to_f @shift.save # Multiple Cashier - cashier_terminal = @shift.cashier_terminal + cashier_terminal = @shift.cashier_terminal cashier_terminal.is_currently_login = 0 cashier_terminal.save @@ -56,7 +58,7 @@ class Origami::ShiftsController < BaseOrigamiController bank_integration = Lookup.find_by_lookup_type('bank_integration') if !bank_integration.nil? card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL']) - + card_settle_trans.each do |data| card_sett_trans = CardSettleTran.find(data.id) card_sett_trans.shift_sale_id = @shift.id @@ -66,12 +68,17 @@ class Origami::ShiftsController < BaseOrigamiController if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + + + # if !close_cashier_print[0].nil? + # @close_cashier_print = close_cashier_print[0][1] + # end close_cashier_pdf = Lookup.collection_of("print_settings") unique_code = "CloseCashierPdf" if !close_cashier_pdf.empty? close_cashier_pdf.each do |close_cashier| - if close_cashier[0] == 'CloseCashierCustomisePdf' + if close_cashier[0] == 'CloseCashierCustomisePdf' if close_cashier[1] == '1' unique_code="CloseCashierCustomisePdf" else @@ -101,12 +108,21 @@ class Origami::ShiftsController < BaseOrigamiController # get printer info print_settings = PrintSetting.find_by_unique_code(unique_code) printer = Printer::CashierStationPrinter.new(print_settings) - - printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + + # print close cashier setting + close_cashier_print = Lookup.collection_of('close_cashier_print') + if close_cashier_print.empty? + @settings_lookup = Lookup.new(lookup_type: "close_cashier_print", name: "CloseCashierPrint", value: "1") + @settings_lookup.save + end + find_close_cashier_print = Lookup.collection_of('close_cashier_print') + if find_close_cashier_print[0][1].to_i > 0 + printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + end end end Employee.logout(session[:session_token]) - session[:session_token] = nil + session[:session_token] = nil end def edit @@ -128,7 +144,7 @@ class Origami::ShiftsController < BaseOrigamiController @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') @total_member_discount = ShiftSale.get_total_member_discount(@shift) end - + end end diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 300e1079..206159b3 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -1,6 +1,6 @@ class Reports::ShiftsaleController < BaseReportController authorize_resource :class => false - + def index from, to = get_date_range_from_params @@ -8,7 +8,7 @@ class Reports::ShiftsaleController < BaseReportController if params[:shift_name].to_i != 0 @shift = ShiftSale.find(params[:shift_name]) end - @sale_data = Sale.get_by_shiftsales(from,to,@shift) + @sale_data = Sale.get_by_shiftsales(from,to,@shift) @from = from @to = to if @shift.present? @@ -24,7 +24,7 @@ class Reports::ShiftsaleController < BaseReportController format.xls end end - + def show from, to = get_date_range_from_params @@ -42,11 +42,69 @@ class Reports::ShiftsaleController < BaseReportController end out = {:status => 'ok', :message => date_arr} - + respond_to do |format| format.json { render json: out } end end -end + def print_close_receipt + shift_id = params[:id] + @shift = ShiftSale.find_by_id(shift_id) + shift_obj = ShiftSale.where('id =?',shift_id) + puts "shift obj!!!!!" + puts shift_obj.to_json + if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + + close_cashier_pdf = Lookup.collection_of("print_settings") + puts "close !!!!" + puts close_cashier_pdf + + unique_code = "CloseCashierPdf" + + if !close_cashier_pdf.empty? + close_cashier_pdf.each do |close_cashier| + if close_cashier[0] == 'CloseCashierCustomisePdf' + if close_cashier[1] == '1' + unique_code="CloseCashierCustomisePdf" + else + unique_code="CloseCashierPdf" + end + end + end + end + + + shop_details = shop_detail + cashier_terminal = @shift.cashier_terminal + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') + @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total) + @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total) + #other payment details for mpu or visa like card + @other_payment = ShiftSale.get_by_shift_other_payment(@shift) + + # Calculate price_by_accounts + @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') + @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') + @total_member_discount = ShiftSale.get_total_member_discount(@shift) + @total_dinein = ShiftSale.get_total_dinein(@shift).total_dinein_amount + @total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount + @total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount + @total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments + + # get printer info + print_settings = PrintSetting.find_by_unique_code(unique_code) + printer = Printer::CashierStationPrinter.new(print_settings) + + printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + + respond_to do |format| + format.html { redirect_to '/en/reports/shiftsale/', notice: 'Printing Completed.'} + format + end + end + end + + +end diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb index c83a161e..214e4e9c 100755 --- a/app/models/printer/cashier_station_printer.rb +++ b/app/models/printer/cashier_station_printer.rb @@ -9,7 +9,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker pdf = CashierStationOpening.new pdf.render_file "tmp/cashier_station_#{order_id}_closing_#{time}.pdf" #no print in cloud server - if ENV["SERVER_MODE"] != "cloud" + if ENV["SERVER_MODE"] != "cloud" self.print("tmp/cashier_station_#{order_id}_closing_#{time}.pdf") end end @@ -33,11 +33,11 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker # shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") # pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges) - # filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf" + # filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf" # pdf.render_file filename # self.print(filename, cashier_terminal.printer_name) # end - + def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) #Use CUPS service @@ -48,7 +48,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf" pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf - + if !close_cashier_pdf.empty? close_cashier_pdf.each do |close_cashier| if close_cashier[0] == 'CloseCashierCustomisePdf' @@ -63,7 +63,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker pdf.render_file filename #no print in cloud server - if ENV["SERVER_MODE"] != "cloud" + if ENV["SERVER_MODE"] != "cloud" self.print(filename, cashier_terminal.printer_name) end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 47c3790f..7ce7e11e 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -49,7 +49,7 @@ class Sale < ApplicationRecord # dining charges charges = DiningCharge.where('dining_facility_id=?',booking.dining_facility_id).take - if !charges.nil? + if !charges.nil? block_count, diningprice = DiningCharge.amount_calculate(charges, booking.checkin_at, booking.checkout_at) if charges.charge_type =='hr' dining_time = booking.checkin_at.strftime('%H:%M %p').to_s + " - " + booking.checkout_at.strftime('%H:%M %p').to_s @@ -84,7 +84,7 @@ class Sale < ApplicationRecord # current cashier login open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") current_shift = ShiftSale.current_shift - # shift with terminal zone + # shift with terminal zone # set cashier if order_source.downcase == "emenu" @@ -112,7 +112,7 @@ class Sale < ApplicationRecord self.cashier_name = cashier.name self.shift_sale_id = shift.id else - if open_cashier.count>0 # if we have two open cashier + if open_cashier.count>0 # if we have two open cashier # table and terminal in multiple shift self.cashier_id = open_cashier[0].id self.cashier_name = open_cashier[0].name @@ -171,9 +171,9 @@ class Sale < ApplicationRecord else booking.checkout_at = Time.now.utc.getlocal end - + booking.checkout_by = requested_by.name - booking.save + booking.save # InventoryJob.perform_now(self.id) saleObj = Sale.find(self.id) @@ -195,7 +195,7 @@ class Sale < ApplicationRecord order_id = order.order_id # order_id bk_order = BookingOrder.find_by_order_id(order_id) check_booking = Booking.find_by_booking_id(bk_order.booking_id) - + if check_booking.sale_id.nil? # Create Sale if it doesn't exist # puts "current_login_employee" @@ -234,7 +234,7 @@ class Sale < ApplicationRecord if !item.set_menu_items.nil? 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 @@ -253,7 +253,7 @@ class Sale < ApplicationRecord #save sale_audit sale_item = SaleItem.new - + #pull if !menu_category.nil? sale_item.menu_category_code = menu_category.code @@ -326,7 +326,7 @@ class Sale < ApplicationRecord sale_item.price = diningprice sale_item.save - # Re-calc + # Re-calc sale = Sale.find(self.id) self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount, nil, order_source) end @@ -481,7 +481,7 @@ class Sale < ApplicationRecord if order_source.to_s == "emenu" order_source = "cashier" end - + if sale.payment_status != 'foc' tax_profiles.each do |tax| if tax.group_type.to_s == order_source.to_s @@ -548,7 +548,7 @@ class Sale < ApplicationRecord # Tax Calculate def apply_tax(total_taxable, order_source = nil, tax_type = nil) shop = Shop.first - + #if tax is not apply create new record # SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax| # #delete existing and create new @@ -669,7 +669,7 @@ class Sale < ApplicationRecord end def adjust_rounding - shop_details = Shop.first + shop_details = Shop.first # rounding adjustment if shop_details.is_rounding_adj a = self.grand_total % 25 # Modulus @@ -685,11 +685,11 @@ class Sale < ApplicationRecord else self.rounding_adjustment = 0.00 end - + end def compute_adjust_rounding(grand_total) - shop_details = Shop.first + shop_details = Shop.first # rounding adjustment if shop_details.is_rounding_adj a = grand_total % 25 # Modulus @@ -786,7 +786,7 @@ class Sale < ApplicationRecord .joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id") .joins(" JOIN orders ON orders.order_id=booking_orders.order_id") .where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and (CASE WHEN (sales.grand_total + sales.amount_changed)=(select SUM(sale_payments.payment_amount) - FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}", from,to) + FROM sale_payments WHERE sale_payments.sale_id=sales.sale_id AND sale_payments.payment_method!='creditnote') THEN NULL ELSE payment_method='creditnote' END) #{keyword} #{custo} #{source}", from,to) else sale = Sale.select("sales.*,#{order_source_query} as source").joins(" JOIN sale_payments sp on sp.sale_id = sales.sale_id") .joins(" JOIN bookings ON bookings.sale_id=sales.sale_id") @@ -922,7 +922,7 @@ def self.get_by_range_by_saleitems(from,to,status,report_type) .group('i.product_code') .order("sale_items.menu_category_code") - query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id + query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN employees ea ON ea.id = sales.cashier_id") @@ -944,13 +944,14 @@ def self.get_by_shiftsales(from,to,shift) .joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id") .where("sales.shift_sale_id=? and sp.payment_method='foc'",shift_sale.id) .first() - + if !foc_data.foc_sales.nil? && foc_data.foc_sales > 0 shift_sale.other_sales -= foc_data.foc_sales foc = foc_data.foc_sales end shift_sale_data[shift_sale.id] = { + :shift_id => shift_sale.id, :cashier_terminal_name => shift_sale.cashier_terminal.name, :employee_name => shift_sale.employee.name, :shift_started_at => shift_sale.shift_started_at, @@ -1037,7 +1038,7 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou end query = self.get_item_query(type) - + discount_query = 0 total_card_amount = 0 total_cash_amount = 0 @@ -1098,12 +1099,12 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou else query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed'",from,to) - + if type.nil? || type == 'all' || type == "other" other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) end product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) - + discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, @@ -1138,17 +1139,17 @@ end #product sale report query def self.get_menu_item_query(order_by) - query = MenuItem.unscoped.select("acc.id as account_id, - acc.title as account_name, + query = MenuItem.unscoped.select("acc.id as account_id, + acc.title as account_name, mii.item_instance_code as item_code, " + "(CASE WHEN si.qty IS NOT NULL THEN SUM(si.qty) ELSE 0 END) as total_item," + "(CASE WHEN si.unit_price != mii.price THEN si.unit_price ELSE mii.price END) as unit_price," + "(CASE WHEN si.qty IS NOT NULL THEN (SUM(si.qty) * si.unit_price) ELSE 0 END) as grand_total," + - "mii.price as unit_price, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END) as product_name, + "mii.price as unit_price, (CASE WHEN si.product_name IS NOT NULL THEN si.product_name ELSE CONCAT(menu_items.name,' - ',mii.item_instance_name) END) as product_name, mc.name as" + - " menu_category_name,mc.id as menu_category_id, si.status as status_type, + " menu_category_name,mc.id as menu_category_id, si.status as status_type, si.price as price ") - .joins(" LEFT JOIN menu_item_instances mii ON menu_items.id = mii.menu_item_id" + + .joins(" LEFT JOIN menu_item_instances mii ON menu_items.id = mii.menu_item_id" + " LEFT JOIN menu_categories mc ON mc.id = menu_items.menu_category_id" + " LEFT JOIN accounts acc ON acc.id = menu_items.account_id" + " LEFT JOIN sale_items si ON si.item_instance_code = mii.item_instance_code" + @@ -1194,7 +1195,7 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay query = Sale.select("sales.*,bookings.dining_facility_id as table_id") .where("sale_status= 'completed' and sale_payments.payment_amount != 0 #{payment_type}") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .joins("join bookings on bookings.sale_id = sales.sale_id") + .joins("join bookings on bookings.sale_id = sales.sale_id") .group("sales.sale_id") if shift.present? query = query.where("sales.shift_sale_id in (?)", shift.to_a) @@ -1207,13 +1208,13 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay end def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter,order_source) - sub_query = "SELECT (CASE WHEN SUM(payment_amount) > 0 + sub_query = "SELECT (CASE WHEN SUM(payment_amount) > 0 THEN DATE_FORMAT(CONVERT_TZ(sale_payments.created_at,'+00:00','+06:30'),'%d %b %y %h:%i%p') ELSE '-' END) FROM `sale_payments` INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id WHERE sale_audits.sale_id = s.sale_id" - sub_query1 = "SELECT (CASE WHEN SUM(payment_amount) > 0 THEN SUM(payment_amount) - + sub_query1 = "SELECT (CASE WHEN SUM(payment_amount) > 0 THEN SUM(payment_amount) - (SUM(payment_amount) - (SELECT SUM(payment_amount) FROM sale_payments WHERE payment_method='creditnote' AND sale_id=s.sale_id)) ELSE 0 END) FROM `sale_payments` INNER JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id @@ -1244,7 +1245,7 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter, WHERE sale_audits.sale_id = s.sale_id) = 0" end order_source_query = "(select orders.source FROM orders JOIN sale_orders so ON so.order_id=orders.order_id WHERE so.sale_id=s.sale_id GROUP BY so.sale_id)" - + if order_source.blank? source = "" else @@ -1336,7 +1337,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type ON SUBSTRING_INDEX(sa.remark,'||',1)=sale_payments.sale_payment_id INNER JOIN sales ON sa.sale_id = sales.sale_id WHERE sales.sale_status='completed' " - + if shift.present? shift_ids = shift.map(&:id).join(",") sub_query += " AND sales.shift_sale_id in (#{shift_ids})" @@ -1380,7 +1381,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type (CASE WHEN (SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end)) > 0 THEN (SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) - (#{sub_query})) ELSE 0 END) as credit_amount, SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount, SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount") - .joins("join sales on sales.sale_id = sale_payments.sale_id") + .joins("join sales on sales.sale_id = sale_payments.sale_id") if shift.present? @@ -1388,7 +1389,7 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type # .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')") if payment_type.blank? sale_type = sale_payment.where(" s.sale_status = 'completed' and payment_amount != 0 and s.shift_sale_id in (?)",shift.to_a) - .order("payment_method") + .order("payment_method") else sale_type = sale_payment.where(" payment_method= '#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift.to_a) end @@ -1399,20 +1400,20 @@ def self.get_payment_method_by_shift(shift_sale_range,shift,from,to,payment_type # .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')") if payment_type.blank? sale_type = sale_payment.where(" s.sale_status = 'completed' and payment_amount != 0 and s.shift_sale_id in (?)",shift_sale_range.to_a) - .order("payment_method") + .order("payment_method") else sale_type = sale_payment.where(" payment_method='#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.shift_sale_id in (?)",shift_sale_range.to_a) end - + else all_total = payments_total.where("sales.receipt_date between ? and ? and sales.sale_status= 'completed' and sale_payments.payment_amount != 0", from,to) # .group("DATE_FORMAT((CONVERT_TZ(sales.receipt_date,'+00:00','+06:30')),'%Y-%m-%d')") if payment_type.blank? sale_type = sale_payment.where(" s.sale_status = 'completed' and payment_amount != 0 and s.receipt_date between ? and ? ",from,to) - .order("payment_method") + .order("payment_method") else - sale_type = sale_payment.where(" payment_method='#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to) + sale_type = sale_payment.where(" payment_method='#{payment_type}' and payment_amount != 0 and s.sale_status = 'completed' and s.receipt_date between ? and ? ",from,to) end end @@ -1585,12 +1586,12 @@ end def self.employee_sales(today,current_user,from,to,from_time,to_time) #sub query for credit payment - outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END + outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END FROM sale_payments JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id JOIN sales ON sale_payments.sale_id = sales.sale_id WHERE sale_payments.outstanding_amount LIKE '%-%' AND sales.sale_status='completed'" - + if (!from.nil? && !to.nil?) && (from != "" && to!="") if !from_time.nil? && !to_time.nil? outstanding_query += " AND DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'" @@ -1756,12 +1757,12 @@ end end def self.credit_payment(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil) - outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END + outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END FROM sale_payments JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id JOIN sales ON sale_payments.sale_id = sales.sale_id WHERE sale_payments.outstanding_amount LIKE '%-%' AND sales.sale_status='completed'" - + if (!from.nil? && !to.nil?) && (from != "" && to!="") if !from_time.nil? && !to_time.nil? outstanding_query += " AND DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'" @@ -1963,12 +1964,12 @@ end time_query = " and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'" end - outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END + outstanding_query = "SELECT CASE WHEN SUM(sale_payments.outstanding_amount) < 0 THEN SUM(sale_payments.outstanding_amount) ELSE 0 END FROM sale_payments JOIN sale_audits ON SUBSTRING_INDEX(sale_audits.remark,'||',1)=sale_payments.sale_payment_id JOIN sales ON sale_payments.sale_id = sales.sale_id WHERE sale_payments.outstanding_amount LIKE '%-%' AND sales.sale_status='completed'" - + if (!from.nil? && !to.nil?) && (from != "" && to!="") if !from_time.nil? && !to_time.nil? outstanding_query += " AND DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%Y-%m-%d') between '#{from}' and '#{to}' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, '+00:00', '+06:30'),'%H:%i') between '#{from_time}' and '#{to_time}'" @@ -2153,7 +2154,7 @@ end if !shift.nil? if !from_time.nil? && !to_time.nil? query = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id).first() - else + else query = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and sales.shift_sale_id=?',from,to,shift.id).first() end end @@ -2369,14 +2370,14 @@ end if current_user.nil? if !from_time.nil? && !to_time.nil? query = query.where("DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) - else + else query = query.where("DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) end else if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor' if !from_time.nil? && !to_time.nil? query = query.where("DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time) - else + else query = query.where("DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ?",from,to) end else @@ -2459,12 +2460,12 @@ end query = Sale.select("cst.res_date,cst.res_time,cst.trace,cst.pan,cst.batch_no,cst.exp_date,cst.app,cst.res_type,cst.ref_no,cst.terminal_id,cst.merchant_id,cst.app_code") .joins("JOIN card_sale_trans as cst on cst.sale_id = sales.sale_id") .where("sales.sale_id=? and status = 'Approved'",sale_id) - + return query end def self.add_to_existing_pending_invoice(dining,sale_id,booking) - + existing_booking = Booking.find_by_sale_id(sale_id) if dining.to_i > 0 table = DiningFacility.find(dining) @@ -2474,7 +2475,7 @@ end # end if booking.sale_id.nil? booking.booking_orders.each do |booking_order| - + booking.booking_status = 'moved' order = Order.find(booking_order.order_id) order.status = 'billed' @@ -2493,7 +2494,7 @@ end order.save booking.save end - + booking_order = BookingOrder.where('booking_id=?',booking) booking_order.each do |bo| bo.booking_id = existing_booking.booking_id @@ -2504,7 +2505,7 @@ end else if booking.sale_id.nil? booking.booking_orders.each do |booking_order| - + booking.booking_status = 'moved' order = Order.find(booking_order.order_id) order.status = 'billed' @@ -2523,7 +2524,7 @@ end order.save booking.save end - + booking_order = BookingOrder.where('booking_id=?',booking) booking_order.each do |bo| bo.booking_id = existing_booking.booking_id @@ -2568,17 +2569,17 @@ end SUM(case when (sale_payments.payment_method='mpu') then sale_payments.payment_amount else 0 end) as mpu_amount, SUM(case when (sale_payments.payment_method='master') then sale_payments.payment_amount else 0 end) as master_amount, SUM(case when (sale_payments.payment_method='visa') then sale_payments.payment_amount else 0 end) as visa_amount, - SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount, - SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount, - SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount, - SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount, - SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount, - SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount, + SUM(case when (sale_payments.payment_method='jcb') then sale_payments.payment_amount else 0 end) as jcb_amount, + SUM(case when (sale_payments.payment_method='unionpay') then sale_payments.payment_amount else 0 end) as unionpay_amount, + SUM(case when (sale_payments.payment_method='alipay') then sale_payments.payment_amount else 0 end) as alipay_amount, + SUM(case when (sale_payments.payment_method='paymal') then sale_payments.payment_amount else 0 end) as paymal_amount, + SUM(case when (sale_payments.payment_method='dinga') then sale_payments.payment_amount else 0 end) as dinga_amount, + SUM(case when (sale_payments.payment_method='JunctionPay') then sale_payments.payment_amount else 0 end) as junctionpay_amount, SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount, SUM(case when (sale_payments.payment_method='giftvoucher') then sale_payments.payment_amount else 0 end) as giftvoucher_amount, SUM(case when (sale_items.status='foc') then sale_items.price else 0 end) as item_foc, - SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount, + SUM(case when (sale_items.status='Discount') then sale_items.price else 0 end) as item_discount, SUM(sale_items.qty) as qty, sales.cashier_name as cashier_name, surveys.child as child, @@ -2588,7 +2589,7 @@ end .joins("join sale_items on sale_items.sale_id = sales.sale_id") .joins("join sale_audits on sale_audits.sale_id = sales.sale_id") .joins("left join surveys on surveys.receipt_no = sales.receipt_no") - + query = query.where("sales.sale_status != 'new' && sale_payments.payment_amount > 0") query = query.where("sales.created_at between ? and ?", '2017-11-01 00:00:00 +0630','2018-11-16 13:59:59 +0630') .group("sales.sale_id") diff --git a/app/views/reports/shiftsale/index.html.erb b/app/views/reports/shiftsale/index.html.erb index f9b4e233..6068347b 100755 --- a/app/views/reports/shiftsale/index.html.erb +++ b/app/views/reports/shiftsale/index.html.erb @@ -20,7 +20,7 @@ +
@@ -33,33 +33,34 @@ - <% if @shift_from %> - <% if @shift_data.employee %> + <% if @shift_data.employee %> <% cashier_name = !@shift_data.nil? ? @shift_data.employee.name : '-' %> - <% end %> + <% end %> - <% end %> + <% end %> - + - + - + + @@ -74,27 +75,27 @@ else delimiter = "" end - %> - <% void = 0%> - <% cash = 0%> - <% credit = 0%> - <% accept_credit = 0%> - <% foc = 0%> + %> + <% void = 0%> + <% cash = 0%> + <% credit = 0%> + <% accept_credit = 0%> + <% foc = 0%> <% card = 0%> - <% total = 0%> - <% rounding_adj = 0%> + <% total = 0%> + <% rounding_adj = 0%> <% g_total = 0 %> <% @sale_data.each do |result|%> - + - @@ -102,23 +103,25 @@ - + --> + - - + + + - <% grand_total = result[:grand_total].to_f %> - + <% grand_total = result[:grand_total].to_f %> + <% cash += result[:cash_sales].to_f %> <% credit += result[:credit_sales].to_f %> - <% card += result[:other_sales].to_f %> - <% foc += result[:foc_sales].to_f %> + <% card += result[:other_sales].to_f %> + <% foc += result[:foc_sales].to_f %> - <% total += result[:grand_total].to_f %> + <% total += result[:grand_total].to_f %> <% g_total += grand_total.to_f %> <% end %> @@ -133,8 +136,8 @@ - - + +
<%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> + <%= t("views.right_panel.detail.from_date") %> : <%= @from.utc.getlocal.strftime("%Y-%b-%d") rescue '-' %> - <%= t("views.right_panel.detail.to_date") %> : <%= @to.utc.getlocal.strftime("%Y-%b-%d") rescue '-'%>
<%= t("views.right_panel.detail.shift_name") %> = <%= @shift_from %> - <%= @shift_to %> ( <%= cashier_name %> )
<%= t("views.right_panel.detail.cashier_station") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %><%= t("views.right_panel.detail.shift_name") %><%= t("views.right_panel.detail.shift_name") %> <%= t("views.right_panel.detail.cash_payment") %> <%= t("views.right_panel.detail.credit_payment") %> <%= t("views.btn.other_payment") %> <%= t("views.btn.foc") %> <%= t :payment %> <%= t("views.right_panel.detail.grand_total") %><%= t("views.right_panel.detail.grand_total") %>Print
- <%= result[:cashier_terminal_name] rescue '-'%> + <%= result[:cashier_terminal_name] rescue '-'%> <%= result[:shift_id].to_i %> <%= result[:employee_name] rescue '-'%> <%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> - + <%= result[:shift_started_at].strftime("%e %b %I:%M%p") rescue '-' %> - <%= result[:shift_closed_at] ? result[:shift_closed_at].strftime("%e %b %I:%M%p") : '-' %> <%= number_with_precision(result[:credit_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%> <%= number_with_precision(result[:other_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%><%= sprintf "%.2f",result.card_amount.to_f.to_d rescue '-'%><%= number_with_precision(result[:other_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%> <%= number_with_precision(result[:foc_sales].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%> - <%= number_with_precision(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%><%= number_with_precision(result[:grand_total].to_f, precision:precision.to_i,delimiter:delimiter) rescue '-'%> + <%= link_to "Print", reports_get_shift_id_path(result[:shift_id].to_i), class:"btn btn-info wave-effects" %> +
<%= number_with_precision(card, precision:precision.to_i,delimiter:delimiter) rescue '-'%> <%= number_with_precision(foc, precision:precision.to_i,delimiter:delimiter) rescue '-'%> <%= number_with_precision(g_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%><%= number_with_precision(g_total, precision:precision.to_i,delimiter:delimiter) rescue '-'%>
@@ -142,25 +145,32 @@
- - diff --git a/config/routes.rb b/config/routes.rb index f25ff1b8..e9594cce 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -12,7 +12,7 @@ scope "(:locale)", locale: /en|mm/ do # if ENV["SERVER_MODE"] != "cloud" mount ActionCable.server => "/cable" # end - + #--------- SmartSales Activation ------------# get 'activate' => 'install#index' @@ -92,7 +92,7 @@ scope "(:locale)", locale: /en|mm/ do post "callback/:id" => "order_reservation#update_status" get "get_tax_profile" => "order_reservation#get_tax_profile" end - + post "sound_effect" => "sound_effect#sound_effect" #API for cashier app @@ -105,16 +105,16 @@ scope "(:locale)", locale: /en|mm/ do end #--------- Cashier ------------# - namespace :origami do + namespace :origami do root "home#index" post '/check_emp_access_code/:code' => 'home#check_emp_access_code', :defaults => { :format => 'json' } - get "dashboard" => "dashboard#index" - get "get_all_menu" => "dashboard#get_all_menu" + get "dashboard" => "dashboard#index" + get "get_all_menu" => "dashboard#get_all_menu" get "quick_service" => "quick_service#index" - + get ":type/pending_order" => "pending_order#index" get ":type/pending_order/:sale_id" => "pending_order#show" get ":type/completed_sale/:sale_id" => "pending_order#completed_sale" @@ -122,7 +122,7 @@ scope "(:locale)", locale: /en|mm/ do get "quick_service/modify_order/:id/:sale_id" => "quick_service#modify_order" get "quick_service/modify_order/:sale_id" => "quick_service#modify_order" post 'quick_service/update_modify_order' => "quick_service#update_modify_order", :defaults => { :format => 'json' } - + get ":type/cash_ins" => "pending_order#cash_ins" get ":type/cash_outs" => "pending_order#cash_outs" @@ -135,7 +135,7 @@ scope "(:locale)", locale: /en|mm/ do resources :cash_ins, only: [:new, :create] resources :cash_outs, only: [:new, :create] - + get "table/:dining_id" => "home#show" do #origami/:booking_id will show # resources :discounts, only: [:index,:new, :create ] #add discount type resources :customers #add customer type @@ -268,10 +268,10 @@ scope "(:locale)", locale: /en|mm/ do get '/:addorders/:id' => "addorders#detail" post '/:addorders/create' => "addorders#create",:as => "addorder_create", :defaults => { :format => 'json' } - + get '/addorders/get_item_instance/:id' => "addorders#get_item_instance",:as => "get_item_instance", :defaults => { :format => 'json' } - + resources :commissions resources :commissioners @@ -341,7 +341,7 @@ scope "(:locale)", locale: /en|mm/ do get 'sale/:sale_id/:type/credit_payment/others_payment/Alipay' => "alipay#index" # get 'sale/:sale_id/:type/credit_payment/others_payment/DINGA' => "dinga#index" # get 'sale/:sale_id/:type/credit_payment/others_payment/GiftVoucher' => "gift_voucher#index" - + #------------- Start Reservation -------------------# resources :reservation #------------- End Reservation -------------------# @@ -402,8 +402,8 @@ scope "(:locale)", locale: /en|mm/ do collection do post :import end - resources :menu_categories, only: [:new, :create, :edit, :delete] - end + resources :menu_categories, only: [:new, :create, :edit, :delete] + end get '/menus/:id/export' => 'menus#export' @@ -524,6 +524,7 @@ scope "(:locale)", locale: /en|mm/ do get "receipt_no/get_shift_by_date", to: "receipt_no#get_shift_by_date", as: "get_shift_by_date" get "order_reservation/get_shift_by_date", to: "order_reservation#show", as: "get_shift_by_order_reservation" get "induty/get_shift_by_date", to: "induty#show", as: "get_shift_by_induty" + get "shiftsale_print/:id" , to: "shiftsale#print_close_receipt", as: "get_shift_id" end From ae1779adf37390d8e7c7c5754db8f46fc1bdd56a Mon Sep 17 00:00:00 2001 From: Zoey Date: Wed, 22 May 2019 13:51:55 +0630 Subject: [PATCH 018/171] sale_items pdf --- app/controllers/origami/shifts_controller.rb | 19 ++- app/controllers/print_settings_controller.rb | 6 + .../reports/saleitem_controller.rb | 3 +- app/models/lookup.rb | 27 +++++ app/models/printer/cashier_station_printer.rb | 19 ++- app/models/sale.rb | 9 ++ app/pdf/close_cashier_pdf.rb | 113 +++++++++++++++++- app/views/origami/shifts/show.html.erb | 12 +- app/views/print_settings/_form.html.erb | 30 ++++- app/views/print_settings/show.html.erb | 10 ++ config/initializers/action_controller.rb | 10 +- config/puma.rb | 20 ++-- dump.rdb | Bin 810 -> 810 bytes 13 files changed, 246 insertions(+), 32 deletions(-) diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 52ac1571..1437dd83 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -11,6 +11,7 @@ class Origami::ShiftsController < BaseOrigamiController if !bank_integration[0].nil? @bank_integration = bank_integration[0][1] end + end def new @@ -83,6 +84,11 @@ class Origami::ShiftsController < BaseOrigamiController shop_details = shop_detail #get tax shift_obj = ShiftSale.where('id =?',@shift.id) + sale_items = '' + @lookup = Lookup.shift_sale_items_lookup_value + if @lookup.to_i == 1 + @sale_items = Sale.get_shift_sale_items(@shift.id) + end @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total) @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total) @@ -98,11 +104,14 @@ class Origami::ShiftsController < BaseOrigamiController @total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount @total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments - # get printer info - print_settings = PrintSetting.find_by_unique_code(unique_code) - printer = Printer::CashierStationPrinter.new(print_settings) - - printer.print_close_cashier(print_settings,cashier_terminal,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + # close_cashier = Lookup.is_print_close_cashier + # if close_cashier + # get printer info + print_settings = PrintSetting.find_by_unique_code(unique_code) + printer = Printer::CashierStationPrinter.new(print_settings) + + printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) + # end end end Employee.logout(session[:session_token]) diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index db6c8848..c1e13727 100755 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -11,6 +11,7 @@ class PrintSettingsController < ApplicationController # GET /print_settings/1 # GET /print_settings/1.json def show + @lookup = Lookup.shift_sale_items_lookup_value end # GET /print_settings/new @@ -21,6 +22,7 @@ class PrintSettingsController < ApplicationController # GET /print_settings/1/edit def edit + @lookup = Lookup.shift_sale_items_lookup_value @server_mode = ENV["SERVER_MODE"] end @@ -45,6 +47,10 @@ class PrintSettingsController < ApplicationController def update respond_to do |format| if @print_setting.update(print_setting_params) + if @print_setting.unique_code == 'CloseCashierPdf' + Lookup.save_shift_sale_items_settings(params[:shift_sale_items]) + end + format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' } format.json { render :show, status: :ok, location: @print_setting } else diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index aff7f3c2..5dea45b8 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -31,10 +31,9 @@ class Reports::SaleitemController < BaseReportController @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) @account_cate_count = Hash.new {|hash, key| hash[key] = 0} - - @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} + @menu_cate_count = Hash.new {|hash, key| hash[key] = 0} @sale_data.each {|cate| @menu_cate_count[cate.account_id] += 1} diff --git a/app/models/lookup.rb b/app/models/lookup.rb index 5434cedd..989f9d08 100755 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -25,4 +25,31 @@ class Lookup < ApplicationRecord Lookup.select("name, value").where("lookup_type" => type ).map { |l| [l.name, l.value] } end + + def self.create_shift_sale_lookup + @lookup = Lookup.new + @lookup.lookup_type = 'shift_sale_items' + @lookup.name = 'Shift Sale Items' + @lookup.value = 0 + @lookup.save + + return @lookup + end + + def self.save_shift_sale_items_settings(val) + @lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last + if @lookup.nil? + @lookup = Lookup.create_shift_sale_lookup + end + @lookup.value = val + @lookup.save + end + + def self.shift_sale_items_lookup_value + @lookup = Lookup.where('lookup_type=?', 'shift_sale_items').last + if @lookup.nil? + @lookup = Lookup.create_shift_sale_lookup + end + return @lookup.value + end end diff --git a/app/models/printer/cashier_station_printer.rb b/app/models/printer/cashier_station_printer.rb index c83a161e..5eef742e 100755 --- a/app/models/printer/cashier_station_printer.rb +++ b/app/models/printer/cashier_station_printer.rb @@ -38,7 +38,20 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker # self.print(filename, cashier_terminal.printer_name) # end - def print_close_cashier(printer_settings,cashier_terminal,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + + if !sale_items.blank? or !sale_items.nil? + @account_cate_count = Hash.new {|hash, key| hash[key] = 0} + sale_items.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} + + + @menu_cate_count = Hash.new {|hash, key| hash[key] = 0} + sale_items.each {|cate| @menu_cate_count[cate.account_id] += 1} + + + @totalByAccount = Hash.new {|hash, key| hash[key] = 0} + sale_items.each {|acc| @totalByAccount[acc.account_id] += acc.grand_total} + end #Use CUPS service #Generate PDF @@ -46,7 +59,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker cashier = shift_sale.employee.name shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf" - pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf if !close_cashier_pdf.empty? @@ -55,7 +68,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker if close_cashier[1] == '1' pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) else - pdf = CloseCashierPdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 47c3790f..6be8bb5a 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1125,6 +1125,15 @@ def self.get_by_shift_items(shift_sale_range, shift, from, to, status,type,accou return query,other_charges, product, discount_query , total_cash_amount , total_card_amount , total_credit_amount , total_foc_amount , total_grand_total , change_amount end +def self.get_shift_sale_items(sh_id) + query = Sale.select("sales.shift_sale_id as shift_sale_id, i.account_id as account_id, acc.title as account_name, i.item_instance_code as item_code, i.menu_category_name, i.menu_category_code as menu_category_id, i.product_name as product_name, i.unit_price, i.price as price, i.qty as qty, SUM(i.qty) as total_item, SUM(i.qty * i.unit_price) as grand_total, i.status as status_type, i.remark as remark") + .joins("JOIN sale_items i on i.sale_id = sales.sale_id") + .joins("JOIN accounts acc on acc.id = i.account_id") + .where("sales.shift_sale_id=?", sh_id) + .group("acc.title,i.account_id,i.menu_category_code,i.item_instance_code,i.product_name,i.unit_price") + .order("acc.title desc, i.account_id desc, i.menu_category_code desc, i.unit_price asc") +end + def self.get_product_sale() query = Sale.select("i.account_id as account_id, " + "SUM(i.qty * i.unit_price) as grand_total,SUM(i.qty) as total_item," + diff --git a/app/pdf/close_cashier_pdf.rb b/app/pdf/close_cashier_pdf.rb index 541c6df4..2e48776d 100755 --- a/app/pdf/close_cashier_pdf.rb +++ b/app/pdf/close_cashier_pdf.rb @@ -2,7 +2,7 @@ class CloseCashierPdf < Prawn::Document include ActionView::Helpers::NumberHelper attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width - def initialize(printer_settings, shift_sale,shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) + def initialize(printer_settings, shift_sale, sale_items, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments) self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -55,6 +55,10 @@ class CloseCashierPdf < Prawn::Document stroke_horizontal_rule shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,printer_settings.precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments) + + if !sale_items.nil? or !sale_items.blank? + sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc) + end end def header (shop_details) @@ -175,7 +179,7 @@ class CloseCashierPdf < Prawn::Document bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do text "#{number_with_precision(shift_sale.credit_sales, :precision => precision.to_i, :delimiter => delimiter) }", :size => self.item_font_size, :align => :right end - + #start other payment details if shift_sale.other_sales > 0 other_payment.each do |other| @@ -395,9 +399,9 @@ class CloseCashierPdf < Prawn::Document text "#{ number_with_precision(@member_discount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right end else - @overall = shift_sale.total_discounts + @overall = shift_sale.total_discounts end - + y_position = cursor bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do text "Total Discount :", :size => self.item_font_size, :align => :right @@ -497,6 +501,107 @@ class CloseCashierPdf < Prawn::Document move_down 5 stroke_horizontal_rule move_down 5 + + end + + def sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc) + self.item_width = 73 + self.price_width = 60 + item_label_qty_front_width = (self.item_width+self.price_width) + 2 + item_label_qty_end_width = 32 + item_label_total_front_width = (self.item_width+self.price_width) + 2 + item_label_total_end_width = 64 + + y_position = cursor + bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do + text "Sale Items Summary", :size => self.header_font_size, :align => :center + end move_down 5 + + total_items = 0 + total_amount = 0 + + if !acc_cate_count.nil? + acc_cate_count.each do |key, value| + + account = Account.find(key) + + y_position = cursor + bounding_box([0,y_position], :width =>self.page_width - 10, :height => 20) do + text "#{account.title}", :size => self.header_font_size, :align => :left + end + move_down 5 + + stroke_horizontal_rule + move_down 2 + y_position = cursor + pad_top(15) { + # @item_width.to_i + @half_qty.to_i + text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix + text_box "Price", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "Qty", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "Total", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + } + move_down 2 + stroke_horizontal_rule + + total_qty = 0 + sub_total = 0 + + sale_items.each do |item| + + if item.account_id == key + total_qty += item.total_item.to_i + sub_total += item.grand_total.to_i + + + move_down 5 + + y_position = cursor + pad_top(15) { + # @item_width.to_i + @half_qty.to_i + text_box "#{item.product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix + text_box "#{item.unit_price.to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{item.total_item.to_i}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{item.grand_total.to_i}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + } + # move_down 3 + end + end + stroke_horizontal_rule + move_down 5 + + # item_label_qty_front_width = (self.item_width+self.price_width) + 2 + # item_label_qty_end_width = 32 + # item_label_total_front_width = (self.item_width+self.price_width) + 2 + # item_label_total_end_width = 64 + total_items += total_qty + total_amount += sub_total + + y_position = cursor + pad_top(15) { + # @item_width.to_i + @half_qty.to_i + text_box "Sub Total", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix + # text_box "#{item.unit_price.to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{total_qty}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{sub_total}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + } + move_down 10 + end + + stroke_horizontal_rule + move_down 5 + + y_position = cursor + pad_top(15) { + # @item_width.to_i + @half_qty.to_i + text_box "Total Amount", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix + # text_box "#{item.unit_price.to_i}", :at =>[(self.item_width),y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{total_items}", :at =>[item_label_qty_front_width,y_position], :width => item_label_qty_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{total_amount}", :at =>[item_label_total_front_width,y_position], :width => item_label_total_end_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + } + + move_down 10 + end end end \ No newline at end of file diff --git a/app/views/origami/shifts/show.html.erb b/app/views/origami/shifts/show.html.erb index f9e923e8..a752e5b5 100755 --- a/app/views/origami/shifts/show.html.erb +++ b/app/views/origami/shifts/show.html.erb @@ -26,7 +26,7 @@
-
+

@@ -59,6 +59,13 @@
\ No newline at end of file diff --git a/app/views/print_settings/show.html.erb b/app/views/print_settings/show.html.erb index 32445b95..0278cfd2 100755 --- a/app/views/print_settings/show.html.erb +++ b/app/views/print_settings/show.html.erb @@ -58,6 +58,16 @@ <%= t("views.right_panel.detail.print_copies") %> <%= @print_setting.print_copies %> + + Include Shift Sale Items + + <% if @lookup == '1' %> + <%= 'True' %> + <% else %> + <%= 'False' %> + <% end %> + + <%= link_to t("views.btn.edit"), edit_print_setting_path(@print_setting),:class => 'btn btn-info btn-sm waves-effect' %> diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index fb212f13..cab8fe5d 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class 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/config/puma.rb b/config/puma.rb index 6f7c4941..6ee2721b 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -application_path="#{File.expand_path("../..", __FILE__)}" -directory application_path -# environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" -pidfile "#{application_path}/tmp/puma/pid" -state_path "#{application_path}/tmp/puma/state" -stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -port ENV.fetch("PORT") { 62158 } -workers 2 -preload_app! +# application_path="#{File.expand_path("../..", __FILE__)}" +# directory application_path +# # environment ENV.fetch("RAILS_ENV") { "production" } +# environment "production" +# pidfile "#{application_path}/tmp/puma/pid" +# state_path "#{application_path}/tmp/puma/state" +# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +# port ENV.fetch("PORT") { 62158 } +# workers 2 +# preload_app! diff --git a/dump.rdb b/dump.rdb index 3ad69d64503187cb2dcd180818e6aa49d528061d..d1adde0cb6060d38f9ffece6a9b4342bb3a2d338 100644 GIT binary patch delta 177 zcmZ3*wu)_n5!18B6HP3cEp&}17D!DtU}Brh$SA^QscT?(fC0putk1|k`3{rnW0YkvG(C7?av-Dp#1aV>1ET|sK&4`nH!!hGES6>cGwao6U!W?v$&pMF zlSLV2CTBBBOw5&KG1oP;n0QBR@&-l;CS${ih0>ExFp3K@u@#o4mZlanvZth`C6?xt cfXretFq&M-q&jh-GUtEElPj-1OR81`02sA6sQ>@~ delta 192 zcmZ3*wu)_n5!1YT6HP29%QDG|Tj&}a9AIE#D=bYdO)X|*Pf1NnEX^sI{Eta_@TS*NjpV53o)w5o58`H87l5C^MOjNqpifoyij!B`42h5(m*N21W-MfedjL zb6rD=iG}i$*D+cH*+yoQZ!)O@jT7TBvOK`>=NsSt!hS}E$rBhw#et@o>Kd9JJi)-g lU0jk_VwIMdnUk6_Igv?W@&`s?eu(@2U$kS6&$0fx2>>0YK575} From 8012bf89683073500149e033cabe1b803e75789e Mon Sep 17 00:00:00 2001 From: Git Code2lab Date: Fri, 24 May 2019 06:47:45 +0000 Subject: [PATCH 019/171] Update puma.rb --- config/puma.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/config/puma.rb b/config/puma.rb index 6ee2721b..6f7c4941 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,10 +1,10 @@ -# application_path="#{File.expand_path("../..", __FILE__)}" -# directory application_path -# # environment ENV.fetch("RAILS_ENV") { "production" } -# environment "production" -# pidfile "#{application_path}/tmp/puma/pid" -# state_path "#{application_path}/tmp/puma/state" -# stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" -# port ENV.fetch("PORT") { 62158 } -# workers 2 -# preload_app! +application_path="#{File.expand_path("../..", __FILE__)}" +directory application_path +# environment ENV.fetch("RAILS_ENV") { "production" } +environment "production" +pidfile "#{application_path}/tmp/puma/pid" +state_path "#{application_path}/tmp/puma/state" +stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" +port ENV.fetch("PORT") { 62158 } +workers 2 +preload_app! From c1d36536125e83981318a55f12f76e4b40737b3f Mon Sep 17 00:00:00 2001 From: Git Code2lab Date: Fri, 24 May 2019 06:48:24 +0000 Subject: [PATCH 020/171] Update action_controller.rb --- config/initializers/action_controller.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index cab8fe5d..5abb412e 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -20,11 +20,11 @@ class 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 From 7d105b27897a3d11d5999c52bc7cca4bbe68c617 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Fri, 24 May 2019 14:56:08 +0630 Subject: [PATCH 021/171] fixed grand total at receipt no report --- app/models/sale.rb | 1 + .../_shift_sale_report_filter.html.erb | 34 ++--- app/views/reports/receipt_no/index.html.erb | 136 +++++++++--------- app/views/reports/shiftsale/index.html.erb | 2 +- config/initializers/action_controller.rb | 61 ++++---- config/puma.rb | 3 +- 6 files changed, 120 insertions(+), 117 deletions(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 7ce7e11e..ef38e8b2 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -879,6 +879,7 @@ def self.daily_sales_list(from,to) total_sale.each do |sale| grand_total = sale.grand_total + amount_received = sale.amount_received old_grand_total = sale.old_grand_total total_discount = sale.total_discount void_amount = sale.void_amount diff --git a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb index 6cf8ce02..a54afb7f 100755 --- a/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb +++ b/app/views/reports/receipt_no/_shift_sale_report_filter.html.erb @@ -19,10 +19,10 @@
<% if not defined? payments %> - +
- + -
+
<% end %> -
+
@@ -47,36 +47,36 @@
-
-
+
+ -
-
+
+
<% end %> - <% end %> -
+ <% end %> +
\ No newline at end of file + diff --git a/app/views/reports/shiftsale/index.html.erb b/app/views/reports/shiftsale/index.html.erb index 6068347b..529636b9 100755 --- a/app/views/reports/shiftsale/index.html.erb +++ b/app/views/reports/shiftsale/index.html.erb @@ -90,7 +90,7 @@ - <%= result[:cashier_terminal_name] rescue '-'%> <%= result[:shift_id].to_i %> + <%= result[:cashier_terminal_name] rescue '-'%> <%= result[:employee_name] rescue '-'%> diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index fb212f13..196f8751 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -3,45 +3,45 @@ class ActionController::Base private - def lookup_domain - if request.subdomain.present? && request.subdomain != "www" - from = request.subdomain.downcase + "." + request.domain.downcase + def lookup_domain + if request.subdomain.present? && request.subdomain != "www" + from = request.subdomain.downcase + "." + request.domain.downcase @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase if (!@license.nil?) - logger.info "Location - " + @license.dbschema - ActiveRecord::Base.establish_connection(website_connection(@license)) - # authenticate_session_token + logger.info "Location - " + @license.dbschema + ActiveRecord::Base.establish_connection(website_connection(@license)) + # authenticate_session_token # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema else # reconnect_default_db logger.info 'License is nil' # redirect_to root_url(:host => request.domain) + "store_error" render :json => [{ status: false, message: 'Invalid Access!'}] - end - else - # check for license file + end + else + check for license file if check_license current_license(ENV["SX_PROVISION_URL"]) else redirect_to activate_path - end - end + end + end end - def current_license(url) + def current_license(url) @license = License.new(url) flag = @license.detail_with_local_file() if (flag == 0) - flash[:notice] = 'Expired or No License!' + flash[:notice] = 'Expired or No License!' elsif (flag == 2) - flash[:notice] = 'Expiring! Please, License extend...' + flash[:notice] = 'Expiring! Please, License extend...' else puts "RUN SAY BYAR" end end - def cache_license(url, lookup) - @license = License.new(url, lookup) + def cache_license(url, lookup) + @license = License.new(url, lookup) if (@license.detail_with_local_cache(lookup) == true) return @license @@ -51,7 +51,7 @@ class ActionController::Base end def check_license - License.check_license_file + License.check_license_file end def check_installation @@ -83,7 +83,7 @@ class ActionController::Base # RESTful url for localize def default_url_options { locale: I18n.locale } - end + end end @@ -92,26 +92,26 @@ class ActionController::API private - def lookup_domain - if request.subdomain.present? && request.subdomain != "www" - from = request.subdomain.downcase + "." + request.domain.downcase + def lookup_domain + if request.subdomain.present? && request.subdomain != "www" + from = request.subdomain.downcase + "." + request.domain.downcase @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase if (!@license.nil?) - logger.info "Location - " + @license.dbschema - ActiveRecord::Base.establish_connection(website_connection(@license)) - # authenticate_session_token + logger.info "Location - " + @license.dbschema + ActiveRecord::Base.establish_connection(website_connection(@license)) + # authenticate_session_token # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema else # reconnect_default_db logger.info 'License is nil' # redirect_to root_url(:host => request.domain) + "store_error" render :json => [{ status: false, message: 'Invalid Access!'}] - end - end - end + end + end + end - def cache_license(url, lookup) - @license = License.new(url, lookup) + def cache_license(url, lookup) + @license = License.new(url, lookup) if (@license.detail_with_local_cache(lookup) == true) return @license @@ -143,7 +143,6 @@ class ActionController::API # RESTful url for localize def default_url_options { locale: I18n.locale } - end + end end - diff --git a/config/puma.rb b/config/puma.rb index 6f7c4941..7a12c8c2 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,7 +1,6 @@ application_path="#{File.expand_path("../..", __FILE__)}" directory application_path -# environment ENV.fetch("RAILS_ENV") { "production" } -environment "production" +#environment "production" pidfile "#{application_path}/tmp/puma/pid" state_path "#{application_path}/tmp/puma/state" stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/log/puma.stderr.log" From 83aa0a4f4c5db9bd1d18f1bac3361b08128837ed Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Fri, 24 May 2019 15:33:35 +0630 Subject: [PATCH 022/171] update addorder view --- app/assets/javascripts/addorder.js | 241 ++++++++++++++------ app/assets/stylesheets/addorder.scss | 45 +++- app/assets/stylesheets/sx_font.css | 2 +- app/models/printer/printer_worker.rb | 26 +-- app/views/origami/addorders/detail.html.erb | 1 - config/initializers/action_controller.rb | 12 +- config/puma.rb | 20 +- 7 files changed, 240 insertions(+), 107 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 6ab73e7a..1b1f1170 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1,3 +1,4 @@ +//middle edit $(function() { var role = $('#role').val(); var second_display_lookup = $("#display_type").val(); @@ -54,28 +55,16 @@ $(function() { if (type ==-1 && modify_order == -1){ image_path = product[field].image_path.url; } - }else{ - image_path = "/image/logo.png"; - } + - row = '
' + row = '
' +'
' +'
' +'
'+ product[field].name +'
' - +"' + +'
' - +"
" - - // +"
" - // +"" - // +"
" - - +'' + +'
' + +'' + +'
'; + } + else + { + row = '
' + +'
' + +'
' + +"
" + +'
'+ product[field].name +'
' + +'
' + + + +'
' + + +"
" + + +'
' + + +'' + + +'
'; + } $('.menu_items_list').append(row); } } @@ -499,7 +543,6 @@ $(function() { //click item row for add order $(document).on('click', '.menu_item_box', function(event){ - $('.attributes-list').empty(); $('.options-list').empty(); $('#modal_box_img').empty(); @@ -1379,6 +1422,7 @@ $(function() { var menu_list = $('.menu_items_list'); menu_list.empty(); for(var field in menu_items) { + console.log(menu_items[field].instances); if (menu_items[field].is_sub_item == false) { instances = menu_items[field].instances ; @@ -1439,52 +1483,109 @@ $(function() { }else{ image_path = menu_items[field].image; } - - }else{ - if (modify_order) { - image_path = "../../image/logo.png"; - }else{ - image_path = "image/logo.png"; - } - } + row = '
' + +'
' + +'
' + +'
'+ menu_items[field].name +'
' + + +'
' + +"
" + +'
' + +'' + +'
'; ; + }else{ + row = '
' + +'
' + +'
" + + +'
'+ menu_items[field].name +'
' + +'
' + +"
" + +'
' + +'' + + + +'
' + +'
'; + } - row = '
' - +'
' - +'
' - +'
'+ menu_items[field].name +'
' - +"
" - +"" - +add+ '' - +'
' - +'
' - +"
" - - // +"
" - // +"" - // +"
" - - +'' - +'
' - +'
'; ; $('.menu_items_list').append(row); } //end instances in menu-items alest 1 instance diff --git a/app/assets/stylesheets/addorder.scss b/app/assets/stylesheets/addorder.scss index 1ffdb8f0..1cda9286 100755 --- a/app/assets/stylesheets/addorder.scss +++ b/app/assets/stylesheets/addorder.scss @@ -3,12 +3,12 @@ section .content{ } .custom-card-head{ height: 40px; - #background-color: #54A5AF; - background-color: #a1aade; + background-color: #79D0F2; + color :#fff; + #background-color: #a1aade; opacity: 0.8; padding:5px; - color :#000000; - + font-weight:400; } .custom-card { border: 2px solid rgba(0, 0, 0, 0.125) !important; @@ -16,6 +16,10 @@ section .content{ } .custom-card-footer{ padding:0.35rem 1.25rem !important; + bottom:0; + position: absolute; + width: 100%; + font-weight:900; } .custom-card-block { @@ -192,7 +196,7 @@ section.content{ } .menu_item_box{ - cursor: pointer; + cursor: pointer; } /*Logout Icon*/ @@ -300,4 +304,33 @@ i.logout_icon{ .ls-closed section.content { margin-left: 15px !important; margin-right: 15px !important; -} \ No newline at end of file +} +.product_box{ + position:relative; + text-align:center; + font-weight:900; + color:#fff; + font-size:1.5em; + margin:auto; +} +.custom-card-no-img-head{ + #background-color: #54A5AF; + opacity: 0.8; + padding:5px; + color :#273040; + min-height:100px; + height: 150px; + background-color:#79D0F2; + +} +.menu_item_no_img_box{ + cursor: pointer; + +} +.custom-card-no-img-footer{ + padding:0.35rem 1.25rem !important; + +} +.custom-flex-footer{ + display:flex; +} diff --git a/app/assets/stylesheets/sx_font.css b/app/assets/stylesheets/sx_font.css index b8b08f2a..b08657e5 100755 --- a/app/assets/stylesheets/sx_font.css +++ b/app/assets/stylesheets/sx_font.css @@ -39,4 +39,4 @@ /* Support for IE. */ font-feature-settings: 'liga'; -} \ No newline at end of file +} diff --git a/app/models/printer/printer_worker.rb b/app/models/printer/printer_worker.rb index 8bbf1c6d..fee19a31 100755 --- a/app/models/printer/printer_worker.rb +++ b/app/models/printer/printer_worker.rb @@ -38,20 +38,20 @@ class Printer::PrinterWorker end def print(file_path,printer_destination = nil ) - # if printer_destination.nil? - # printer_destination = self.printer_destination - # end + if printer_destination.nil? + printer_destination = self.printer_destination + end - # puts printer_destination - # puts '........Printer Destination..........' + puts printer_destination + puts '........Printer Destination..........' - # copy = self.print_copies - # #Print only when printer information is not null - # if !self.printer_destination.nil? - # (1..copy).each do - # page = Cups::PrintJob.new(file_path, printer_destination) - # page.print - # end - # end + copy = self.print_copies + #Print only when printer information is not null + if !self.printer_destination.nil? + (1..copy).each do + page = Cups::PrintJob.new(file_path, printer_destination) + page.print + end + end end end diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 50f25902..80fba22e 100644 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -4,7 +4,6 @@ <% type = request.path_info.include?('quick_service') || request.path_info.include?('food_court')%> <% modify_order = request.path_info.include?('modify_order')%> -
From 58755b00c97a562ccca2a8eced5263a0e94f2e15 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Tue, 28 May 2019 15:03:14 +0630 Subject: [PATCH 028/171] - --- app/controllers/crm/customers_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 50c0da09..c895c4b6 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -122,7 +122,6 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) @response = Customer.get_membership_transactions(@customer) - puts @response.to_json Rails.logger.debug "get membership transactions response" Rails.logger.debug @response.to_json From 90141e33a08c4c64b08c3b3625ffd6df582cef4f Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Wed, 29 May 2019 16:15:28 +0630 Subject: [PATCH 029/171] - --- app/assets/javascripts/addorder.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 1b1f1170..b563294c 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -75,7 +75,7 @@ $(function() { +'
' +'