From 919e6f61b3fc5e0913aa9d471b173b6fccba18ac Mon Sep 17 00:00:00 2001 From: Git Code2lab Date: Wed, 28 Aug 2019 11:57:33 +0000 Subject: [PATCH 01/11] Update puma.rb --- config/puma.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/config/puma.rb b/config/puma.rb index fd89392f..dcc85b12 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -8,3 +8,4 @@ stdout_redirect "#{application_path}/log/puma.stdout.log", "#{application_path}/ port ENV.fetch("PORT") { 62158 } workers 2 preload_app! +threads 1,1 \ No newline at end of file From f0be0d19a1ebadf5b2f3cb9552469765b29f89d5 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Fri, 30 Aug 2019 14:03:48 +0630 Subject: [PATCH 02/11] nothing --- .../reports/hourly_saleitem_controller.rb | 3 ++ .../reports/saleitem_controller.rb | 2 +- app/models/printer/printer_worker.rb | 26 +++++++------- app/models/sale.rb | 2 +- .../reports/hourly_saleitem/index.html.erb | 36 ++++++++++--------- config/initializers/action_controller.rb | 10 +++--- config/puma.rb | 20 +++++------ 7 files changed, 52 insertions(+), 47 deletions(-) diff --git a/app/controllers/reports/hourly_saleitem_controller.rb b/app/controllers/reports/hourly_saleitem_controller.rb index 68883c68..893d4d17 100644 --- a/app/controllers/reports/hourly_saleitem_controller.rb +++ b/app/controllers/reports/hourly_saleitem_controller.rb @@ -56,7 +56,10 @@ class Reports::HourlySaleitemController < BaseReportController @shift_data = sh end end + # @hourly_total_qty = @sale_data.group_by {|s| s.date_format }.collect{|key,qty| {"date" => key , "total_qty" => qty.sum{|d| d.qty.to_i}}} + @hourly_total_qty = @sale_data.group_by(&:date_format).map { |k,v|{"date" => k , "total_qty" => v.count }} + puts @hourly_total_qty.to_json respond_to do |format| format.html format.xls diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index f3062d69..b581eae8 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -64,7 +64,7 @@ class Reports::SaleitemController < BaseReportController def show from, to, report_type = get_date_range_from_params @sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) - sale_data = @sale_data + date_arr = Array.new @sale_data.each do |sale| local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p") 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/app/models/sale.rb b/app/models/sale.rb index acbb25b7..68620a1b 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1092,7 +1092,7 @@ def self.get_item_query(type) "i.unit_price,i.price as price,i.product_name as product_name, " + "i.menu_category_name,i.menu_category_code as menu_category_id, " + "date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p') - as date_format") + as date_format") query = query.joins("JOIN sale_items i ON i.sale_id = sales.sale_id" + " JOIN shift_sales sh ON sh.`id` = sales.shift_sale_id") diff --git a/app/views/reports/hourly_saleitem/index.html.erb b/app/views/reports/hourly_saleitem/index.html.erb index f5491203..e98f61a7 100644 --- a/app/views/reports/hourly_saleitem/index.html.erb +++ b/app/views/reports/hourly_saleitem/index.html.erb @@ -11,7 +11,7 @@
<%= render :partial=>'shift_sale_report_filter', - :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_waste_and_spoilage_index_path} %> + :locals=>{ :period_type => true, :shift_name => true,:payments => true, :report_path =>reports_hourly_saleitem_index_path} %>
<%= t("views.btn.exp_to_excel") %> @@ -21,6 +21,7 @@ <% time_arr = Array.new %> + <% sale_item_count =0 %> <% menu_cat_arr = Array.new %> <% footer_arr = Array.new %> <% count = 0 %> @@ -29,6 +30,7 @@ <% time_count = 0 %> <% @sale_data.each do |sale| %> <% if !time_arr.include?(sale.date_format) %> + <% sale_item_count =1 %> <% time_count = time_count + 1 %> @@ -52,6 +54,9 @@ <% time_arr.push(sale.date_format) %> <% menu_cat_arr.clear %> <% count = 0 %> + <% else %> + <%= time_arr %> + <% sale_item_count =sale_item_count +1 %> <% end %> @@ -85,24 +90,21 @@ <% end %> - - <% count = count + 1 %> - <% logger.debug ' normal count+++++++++++++++++++++++++' %> - <% logger.debug sale.sale_items.count %> - <% logger.debug 'time_count count------------------------------------' %> - <% logger.debug time_count %> - <% if sale.sale_items.count == count %> - - - - - - - - <% footer_arr.push(sale.sale_id) %> - <% end %> + <% @hourly_total_qty.each do |hr| %> + <% if hr["date"].to_s == sale.date_format.to_s && hr["total_qty"].to_i ==sale_item_count%> + + + + + + + + <% footer_arr.push(sale.sale_id) %> + <% total_qty =0%> + <% end %> + <% end %> <% end %> diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 205c330a..85f38ec5 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -21,11 +21,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! From aed51eba69715613522192fdab44fa6c2d739500 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Fri, 30 Aug 2019 17:30:59 +0630 Subject: [PATCH 03/11] display message when calling to cloud --- app/controllers/crm/customers_controller.rb | 82 ++++++++++++++------- app/models/customer.rb | 8 +- app/views/crm/customers/index.html.erb | 12 ++- 3 files changed, 70 insertions(+), 32 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index aacfa39f..2f846601 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -5,6 +5,7 @@ class Crm::CustomersController < BaseCrmController # GET /crm/customers # GET /crm/customers.json def index + @no_need_validation =false filter = params[:filter] filter_card_no = params[:filter_card_no] type = params[:type] @@ -39,24 +40,37 @@ class Crm::CustomersController < BaseCrmController @crm_customers.tax_profiles = ["1", "2"] @crm_customers.save @crm_customers = Customer.search(filter) - flash[:notice]='Customer was successfully created.' + flash[:member_notice]='Customer was successfully created.' else - flash[:error]=response["message"] + flash[:member_error]=response["message"] end else - @crm_customers.each do |customer| - if customer.contact_no != response["customer_data"]["phone"] - @customer_update_phone_email_membertype =true + if response["status"] ==true + @crm_customers.each do |customer| + if !response["customer_data"].nil? + if customer.contact_no != response["customer_data"]["phone"] + @customer_update_phone_email_membertype =true + end + if customer.email != response["customer_data"]["email"] + @customer_update_phone_email_membertype =true + end + if customer.name != response["customer_data"]["name"] + @customer_update_phone_email_membertype =true + end + if customer.membership_type.to_i != response["customer_data"]["member_group_id"] + @customer_update_phone_email_membertype =true + end + else + flash[:member_error]=response["message"] + end end - if customer.email != response["customer_data"]["email"] - @customer_update_phone_email_membertype =true - end - if customer.name != response["customer_data"]["name"] - @customer_update_phone_email_membertype =true - end - if customer.membership_type.to_i != response["customer_data"]["member_group_id"] - @customer_update_phone_email_membertype =true + else + if response["message"] =='No internet connection ' + flash[:member_error]=response["message"] + else + flash[:member_error]="Need to press sync button " end + end end end @@ -190,14 +204,18 @@ class Crm::CustomersController < BaseCrmController }, :timeout => 10 ) + + rescue HTTParty::Error + response = {"status" => false, "message" => "No internet connection "} + rescue Net::OpenTimeout - response = { status: false } + response = {"status" => false, "message" => "No internet connection "} rescue OpenURI::HTTPError - response = { status: false} + response = {"status" => false, "message" => "No internet connection "} rescue SocketError - response = { status: false} + response = {"status" => false, "message" => "No internet connection "} end customer = Customer.find(@crm_customer.customer_id) Rails.logger.debug "--------Sync Member response -------" @@ -222,6 +240,9 @@ class Crm::CustomersController < BaseCrmController customer.destroy format.html { redirect_to crm_customers_path } flash[:member_error] ='Member cannot created.Invalid Account.' + else + format.html { redirect_to crm_customers_path } + flash[:member_error] =response["message"] end format.html { redirect_to crm_customers_path } flash[:member_error] =response["message"] @@ -286,16 +307,16 @@ class Crm::CustomersController < BaseCrmController ) rescue HTTParty::Error - response = {"status" => false, "message" => "Can't open membership server "} + response = {"status" => false, "message" => "No internet connection "} rescue Net::OpenTimeout - response = {"status" => false, "message" => "Can't open membership server "} + response = {"status" => false, "message" => "No internet connection "} rescue OpenURI::HTTPError - response = {"status" => false, "message" => "Can't open membership server "} + response = {"status" => false, "message" => "No internet connection "} rescue SocketError - response = {"status" => false, "message" => "Can't open membership server "} + response = {"status" => false, "message" => "No internet connection "} end Rails.logger.debug "--------------Create Member---------" Rails.logger.debug response.to_json @@ -332,6 +353,9 @@ class Crm::CustomersController < BaseCrmController format.html { redirect_to crm_customers_path } flash[:member_error]='Member cannot created.Invalid Account.' end + else + format.html { redirect_to crm_customers_path } + flash[:member_error]=response["message"] end if params[:sale_id] format.html { redirect_to '/origami/'+params[:sale_id]+'/'+params[:type]+'/customers/'+params[:page] } @@ -431,14 +455,17 @@ class Crm::CustomersController < BaseCrmController }, :timeout => 10 ) + rescue HTTParty::Error + response = {"status" => false, "message" => "No internet connection "} + rescue Net::OpenTimeout - response = { status: false } + response = {"status" => false, "message" => "No internet connection "} rescue OpenURI::HTTPError - response = { status: false} + response = {"status" => false, "message" => "No internet connection "} rescue SocketError - response = { status: false} + response = {"status" => false, "message" => "No internet connection "} end customer = Customer.find(@crm_customer.customer_id) Rails.logger.debug "--------Update Member response -------" @@ -493,14 +520,17 @@ class Crm::CustomersController < BaseCrmController }, :timeout => 10 ) + rescue HTTParty::Error + response = {"status" => false, "message" => "No internet connection "} + rescue Net::OpenTimeout - response = { status: false } + response = {"status" => false, "message" => "No internet connection "} rescue OpenURI::HTTPError - response = { status: false} + response = {"status" => false, "message" => "No internet connection "} rescue SocketError - response = { status: false} + response = {"status" => false, "message" => "No internet connection "} end Rails.logger.debug "--------Update Member response -------" Rails.logger.debug response.to_json diff --git a/app/models/customer.rb b/app/models/customer.rb index d69220f3..04d4449c 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -325,16 +325,16 @@ class Customer < ApplicationRecord :timeout => 10 ) rescue HTTParty::Error - response = {status: false, message: "Server Error"} + response = {"status" => false, "message" => "No internet connection "} rescue Net::OpenTimeout - response = { status: false , message: "Server Time out"} + response = {"status" => false, "message" => "No internet connection "} rescue OpenURI::HTTPError - response = { status: false, message: "Can't connect server"} + response = {"status" => false, "message" => "No internet connection "} rescue SocketError - response = { status: false, message: "Can't connect server"} + response = {"status" => false, "message" => "No internet connection "} end Rails.logger.debug "--------Search Paypar Account No response -------" Rails.logger.debug response.to_json diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 55295c9e..5739c6fc 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -29,7 +29,9 @@
- +
<%= form_tag crm_customers_path, :id => "filter_form", :method => :get do %>
@@ -123,7 +125,7 @@
- <% if !cate_arr.include?(sale.menu_category_id) %> - <% cate_arr.push(sale.menu_category_id) %> - <% else %> - - <% end %> <% if sale.status_type != "Discount" %> @@ -143,13 +138,6 @@ sub_qty += sale.total_item end %> <% if count == value %> - - - - - - - <% sub_total = 0.0%> <% sub_qty = 0 %> <% count = 0%> diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 85f38ec5..205c330a 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -21,11 +21,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 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 b00b9fc75c20e5f52eaa1de726cd9808bdeb3497 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Tue, 3 Sep 2019 17:33:27 +0630 Subject: [PATCH 05/11] sync receipt --- app/models/assigned_order_item.rb | 4 +++- app/models/booking.rb | 4 +++- app/models/order.rb | 4 +++- app/models/order_item.rb | 4 +++- app/models/printer/printer_worker.rb | 26 +++++++++++++------------- app/models/sale.rb | 4 +++- app/models/sale_audit.rb | 4 +++- app/models/sale_item.rb | 4 +++- app/models/sale_order.rb | 6 ++++-- app/models/sale_payment.rb | 4 +++- app/models/sale_tax.rb | 4 +++- 11 files changed, 44 insertions(+), 24 deletions(-) diff --git a/app/models/assigned_order_item.rb b/app/models/assigned_order_item.rb index 9359fd66..c1b0162e 100755 --- a/app/models/assigned_order_item.rb +++ b/app/models/assigned_order_item.rb @@ -64,6 +64,8 @@ class AssignedOrderItem < ApplicationRecord private def generate_custom_id - self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI") + if self.assigned_order_item_id.nil? + self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI") + end end end diff --git a/app/models/booking.rb b/app/models/booking.rb index 374dd0cf..e4afb8c7 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -122,6 +122,8 @@ class Booking < ApplicationRecord private def generate_custom_id - self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI") + if self.booking_id.nil? + self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI") + end end end diff --git a/app/models/order.rb b/app/models/order.rb index 26451207..f53eb7e8 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -557,7 +557,9 @@ class Order < ApplicationRecord private def generate_custom_id - self.order_id = SeedGenerator.generate_id(self.class.name, "ODR") + if self.order_id.nil? + self.order_id = SeedGenerator.generate_id(self.class.name, "ODR") + end end def set_order_date diff --git a/app/models/order_item.rb b/app/models/order_item.rb index c5d715f3..0ac03e9b 100755 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -97,6 +97,8 @@ class OrderItem < ApplicationRecord private def generate_custom_id - self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI") + if self.order_items_id.nil? + self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI") + end end end 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/models/sale.rb b/app/models/sale.rb index 56377de5..8f5c7eb0 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2951,6 +2951,8 @@ end private def generate_custom_id - self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") + if self.sale_id.nil? + self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") + end end end diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index 36734ec1..d96034ad 100755 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -176,6 +176,8 @@ class SaleAudit < ApplicationRecord private def generate_custom_id - self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI") + if self.sale_audit_id.nil? + self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI") + end end end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index d8be28b7..b8ada0ed 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -223,6 +223,8 @@ class SaleItem < ApplicationRecord private def generate_custom_id - self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI") + if self.sale_item_id.nil? + self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI") + end end end diff --git a/app/models/sale_order.rb b/app/models/sale_order.rb index ab50e228..bbd68829 100755 --- a/app/models/sale_order.rb +++ b/app/models/sale_order.rb @@ -34,7 +34,9 @@ class SaleOrder < ApplicationRecord private def generate_sale_order_id # self.class.name - saleOrderId = SeedGenerator.generate_id(self.class.name, 'SOI') - self.sale_order_id = saleOrderId + if self.sale_order_id.nil? + self.sale_order_id = SeedGenerator.generate_id(self.class.name, 'SOI') + end + end end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 4808860a..7050eb25 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -1065,6 +1065,8 @@ class SalePayment < ApplicationRecord private def generate_custom_id - self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") + if self.sale_payment_id.nil? + self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") + end end end diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb index bd89ec1b..06c73253 100755 --- a/app/models/sale_tax.rb +++ b/app/models/sale_tax.rb @@ -34,6 +34,8 @@ class SaleTax < ApplicationRecord private def generate_custom_id - self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI") + if self.sale_tax_id.nil? + self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI") + end end end From f3f74db446ffaa0e0ea6c5c4e30dca3c61b1210a Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Tue, 3 Sep 2019 18:29:57 +0630 Subject: [PATCH 06/11] delete puts in employee --- app/controllers/settings/employees_controller.rb | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index baefd752..c416cc87 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -30,9 +30,6 @@ class Settings::EmployeesController < ApplicationController # POST /employees # POST /employees.json def create - puts "puts ssssssssssssssssssssssssss" - puts employee_params.to_json - @employee = Employee.new(employee_params) respond_to do |format| From 34c3dc47ae006dea9836edf946b9d242b08b9982 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Wed, 4 Sep 2019 18:19:06 +0630 Subject: [PATCH 07/11] discount --- app/assets/stylesheets/origami.scss | 7 ------ app/models/printer/printer_worker.rb | 26 +++++++++++----------- app/models/sale_payment.rb | 4 +--- app/views/origami/discounts/index.html.erb | 21 ++++++++++++----- config/initializers/action_controller.rb | 10 ++++----- config/puma.rb | 22 +++++++++--------- 6 files changed, 46 insertions(+), 44 deletions(-) diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 6bbce5a3..64cc2937 100755 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -298,13 +298,6 @@ select.form-control { /* Discount */ -.discount-item-row { - cursor: pointer; -} - -tr.discount-item-row:hover { - background-color: #e3e3e3 !important; -} .required abbr{ color: red !important; } 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/app/models/sale_payment.rb b/app/models/sale_payment.rb index 7050eb25..2574c7f9 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -395,7 +395,6 @@ class SalePayment < ApplicationRecord self.payment_status = "paid" payment_status = self.save! - if !payment_for sale_update_payment_status(self.received_amount,status) end @@ -661,8 +660,7 @@ class SalePayment < ApplicationRecord method_status = true end end - - if (self.sale.grand_total <= all_received_amount) && method_status + if (self.sale.grand_total.round <= all_received_amount) && method_status if is_credit == 0 self.sale.payment_status = "paid" else diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index e23e4e6f..55144c41 100755 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -50,6 +50,7 @@ >
 
<%= sale.date_format %>
 Total Qty:<%= total_qty%>Grand Total:
 Total Qty:<%= total_qty%>Grand Total:
<%= crm_customer.card_no rescue '-' %> - <% 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? %> + <% if crm_customer.membership_id.nil? && !crm_customer.membership_type.nil? && !crm_customer.membership_type.blank? && !crm_customer.paypar_account_no.blank? && !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_membertype %> @@ -156,6 +158,7 @@ From 9b0e77674e0c469e4b7b111b1b1281d765b8ff3c Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Mon, 2 Sep 2019 16:22:09 +0630 Subject: [PATCH 04/11] update sale item xls --- .../reports/saleitem_controller.rb | 3 +-- app/views/reports/saleitem/index.xls.erb | 12 ----------- config/initializers/action_controller.rb | 10 +++++----- config/puma.rb | 20 +++++++++---------- 4 files changed, 16 insertions(+), 29 deletions(-) diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index b581eae8..0d339fd6 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -54,8 +54,7 @@ class Reports::SaleitemController < BaseReportController @shift_data = sh end end - - respond_to do |format| + respond_to do |format| format.html format.xls end diff --git a/app/views/reports/saleitem/index.xls.erb b/app/views/reports/saleitem/index.xls.erb index 8f326e27..1b5dd998 100755 --- a/app/views/reports/saleitem/index.xls.erb +++ b/app/views/reports/saleitem/index.xls.erb @@ -108,12 +108,7 @@ <% end %>
 <%= sale.menu_category_name %> <%= sale.item_code rescue '-' %> <%= sale.product_name rescue '-' %>
 Total <%= sale.account_name %> Qty <%= sub_qty %><%= t("views.right_panel.detail.sub_total") %><%= number_with_precision(sub_total , precision:precision.to_i,delimiter:delimiter)%>
+ <%=sale_item.product_name%>@<%=sale_item.unit_price%> @@ -313,10 +314,13 @@ var cashier_type = "<%= @cashier_type %>"; // Select Sale Item $('.item-row').on('click',function(){ if($(this).hasClass('selected-item') == true){ - $(this).removeClass('selected-item'); + $(this).removeClass('selected-item'); } else { - $(this).addClass('selected-item'); + if(parseInt($(this).children().find("#item-account-qty").text()) >0 && parseInt($(this).children().find("#item-total-price").text()) >0){ + + $(this).addClass('selected-item'); + } } }); @@ -326,14 +330,16 @@ var cashier_type = "<%= @cashier_type %>"; $(this).removeClass('selected-item'); } else { - $(this).addClass('selected-item'); + if(parseInt($(this).children().find("#item-account-qty").text()) >0 && parseInt($(this).children().find("#item-total-price").text()) >0){ + + $(this).addClass('selected-item'); + } } }); // Select for account types $(".accounts-type").on('click', function(e){ var account_id = $(this).attr('id').substr(8); - if($(this).hasClass('selected-account') == true){ $(this).removeClass('selected-account'); $(".item-row").each(function(i){ @@ -346,7 +352,12 @@ var cashier_type = "<%= @cashier_type %>"; $(this).addClass('selected-account'); $(".item-row").each(function(i){ if($(this).children().find("#item-account-type").text() == account_id){ - $(this).addClass("selected-item"); + if(parseInt($(this).children().find("#item-account-qty").text()) >0 && parseInt($(this).children().find("#item-total-price").text()) >0){ + $(this).addClass("selected-item"); + } + else{ + console.log("discount item"); + } } }); } diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 205c330a..85f38ec5 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -21,11 +21,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 dcc85b12..66214eff 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,11 +1,11 @@ -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! -threads 1,1 \ No newline at end of file +# 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! +# threads 1,1 \ No newline at end of file From 1ced4a3d6dc991f0f75cde34cd29751bc026f504 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 5 Sep 2019 11:57:26 +0630 Subject: [PATCH 08/11] discount --- app/models/printer/printer_worker.rb | 26 ++++++++++++------------ app/models/sale_payment.rb | 2 +- config/initializers/action_controller.rb | 10 ++++----- config/puma.rb | 22 ++++++++++---------- 4 files changed, 30 insertions(+), 30 deletions(-) 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/models/sale_payment.rb b/app/models/sale_payment.rb index 2574c7f9..42a4452c 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -660,7 +660,7 @@ class SalePayment < ApplicationRecord method_status = true end end - if (self.sale.grand_total.round <= all_received_amount) && method_status + if (self.sale.grand_total <= all_received_amount) && method_status if is_credit == 0 self.sale.payment_status = "paid" else diff --git a/config/initializers/action_controller.rb b/config/initializers/action_controller.rb index 85f38ec5..205c330a 100644 --- a/config/initializers/action_controller.rb +++ b/config/initializers/action_controller.rb @@ -21,11 +21,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 66214eff..dcc85b12 100755 --- a/config/puma.rb +++ b/config/puma.rb @@ -1,11 +1,11 @@ -# 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! -# threads 1,1 \ No newline at end of file +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! +threads 1,1 \ No newline at end of file From 258aba669bdf32a954371897e0967bb04d683bf9 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Thu, 5 Sep 2019 18:12:17 +0630 Subject: [PATCH 09/11] precision --- .../origami/discounts_controller.rb | 2 ++ app/controllers/origami/home_controller.rb | 3 ++- app/models/sale.rb | 15 +++++++++++ app/views/origami/discounts/index.html.erb | 26 ++++++++++++++----- app/views/origami/home/show.html.erb | 24 +++++++++++++---- 5 files changed, 58 insertions(+), 12 deletions(-) diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 22092a50..cd73d174 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -3,6 +3,8 @@ class Origami::DiscountsController < BaseOrigamiController #discount page show from origami index with selected order def index + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() @webview = false if check_mobile @webview = true diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 2ba8cd3e..fe074210 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -17,7 +17,8 @@ class Origami::HomeController < BaseOrigamiController # origami table detail def show - + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile @tables = Table.unscoped.all.active.order('status desc') diff --git a/app/models/sale.rb b/app/models/sale.rb index 8f5c7eb0..2c451b5b 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -452,6 +452,7 @@ class Sale < ApplicationRecord self.total_amount = subtotal_price self.total_discount = total_discount self.grand_total = (self.total_amount - self.total_discount) + self.total_tax + self.grand_total_round #compute rounding adjustment adjust_rounding @@ -461,6 +462,7 @@ class Sale < ApplicationRecord #compute - invoice total def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil) + shop = Shop.first sale = Sale.find(sale_id) sales_items = sale_itemss @@ -484,6 +486,7 @@ class Sale < ApplicationRecord sale.total_amount = subtotal_price sale.total_discount = total_discount sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax + sale.grand_total_round if discount_type == "member_discount" sale.discount_type = discount_type end @@ -519,6 +522,7 @@ class Sale < ApplicationRecord self.total_amount = subtotal_price self.total_discount = total_discount self.grand_total = (self.total_amount - self.total_discount) + self.total_tax + self.grand_total_round #compute rounding adjustment adjust_rounding @@ -2948,6 +2952,17 @@ end # End hourly sale item report + +#not to show decimal in grand total +def grand_total_round + shop =Shop.first + print_settings = PrintSetting.get_precision_delimiter() + if !print_settings.nil? + self.grand_total =self.grand_total.round(print_settings.precision.to_i) + puts self.grand_total + puts "Hello grand_total_round" + end +end private def generate_custom_id diff --git a/app/views/origami/discounts/index.html.erb b/app/views/origami/discounts/index.html.erb index 55144c41..cb7fe255 100755 --- a/app/views/origami/discounts/index.html.erb +++ b/app/views/origami/discounts/index.html.erb @@ -2,6 +2,20 @@ + <% if !@print_settings.nil? %> + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> + <% end %>
@@ -72,7 +86,7 @@ - +
@@ -350,7 +364,7 @@
Sub Total:<%=sub_total%><%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
- + <%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%> @@ -359,7 +373,7 @@ <%end%> - + <% if @status_sale == "sale" %> @@ -382,15 +396,15 @@ <% end %> - + - + - + <% end %> From ac2449931925a75d13d415f5a300c29793b1f2ed Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Tue, 10 Sep 2019 13:12:41 +0630 Subject: [PATCH 10/11] foc --- Gemfile.lock | 23 +++++++++---------- app/controllers/origami/void_controller.rb | 2 +- app/models/sale.rb | 26 +++++++++++----------- app/models/sale_item.rb | 6 +++-- app/models/sale_payment.rb | 3 ++- app/views/layouts/_left_sidebar.html.erb | 8 +++---- 6 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 1b1180a1..4c36f330 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -47,7 +47,7 @@ GEM minitest (~> 5.1) tzinfo (~> 1.1) aescrypt (1.0.0) - airbrussh (1.3.2) + airbrussh (1.3.3) sshkit (>= 1.6.1, != 1.7.0) arel (8.0.0) axlsx (2.0.1) @@ -62,7 +62,7 @@ GEM builder (3.2.3) byebug (11.0.1) cancancan (1.17.0) - capistrano (3.11.0) + capistrano (3.11.1) airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) @@ -99,8 +99,8 @@ GEM factory_girl_rails (4.9.0) factory_girl (~> 4.9.0) railties (>= 3.0.0) - faker (2.1.0) - i18n (>= 0.7) + faker (2.2.2) + i18n (~> 1.6.0) ffi (1.11.1) filterrific (5.2.1) font-awesome-rails (4.7.0.5) @@ -148,9 +148,9 @@ GEM material_icons (2.2.1) railties (>= 3.2) method_source (0.9.2) - mime-types (3.2.2) + mime-types (3.3) mime-types-data (~> 3.2015) - mime-types-data (3.2019.0331) + mime-types-data (3.2019.0904) mini_magick (4.9.5) mini_mime (1.0.2) mini_portile2 (2.4.0) @@ -163,8 +163,8 @@ GEM net-scp (2.0.0) net-ssh (>= 2.6.5, < 6.0.0) net-ssh (5.2.0) - nio4r (2.4.0) - nokogiri (1.10.3) + nio4r (2.5.1) + nokogiri (1.10.4) mini_portile2 (~> 2.4.0) pdf-core (0.7.0) pdfjs_viewer-rails (0.3.1) @@ -183,7 +183,7 @@ GEM puma (3.12.1) rack (2.0.7) rack-cors (1.0.3) - rack-protection (2.0.5) + rack-protection (2.0.7) rack rack-test (1.1.0) rack (>= 1.0, < 3) @@ -202,7 +202,7 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.1.0) + rails-html-sanitizer (1.2.0) loofah (~> 2.2, >= 2.2.2) railties (5.1.7) actionpack (= 5.1.7) @@ -251,9 +251,8 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sassc (2.0.1) + sassc (2.2.0) ffi (~> 1.9) - rake schema_to_scaffold (0.8.0) activesupport (>= 3.2.1) shoulda-matchers (3.1.3) diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 980fd6bd..0523023e 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -8,7 +8,7 @@ class Origami::VoidController < BaseOrigamiController access_code = params[:access_code] if Sale.exists?(sale_id) sale = Sale.find_by_sale_id(sale_id) - + puts sale.to_json if sale.discount_type == "member_discount" sale.update_attributes(total_discount: 0) sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source) diff --git a/app/models/sale.rb b/app/models/sale.rb index 2c451b5b..95bbe525 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -461,7 +461,7 @@ class Sale < ApplicationRecord end #compute - invoice total - def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil) + def compute_by_sale_items(sale_id, sale_itemss, total_discount,discount_type=nil,order_source=nil,tax_type=nil,type=nil) shop = Shop.first sale = Sale.find(sale_id) sales_items = sale_itemss @@ -473,20 +473,23 @@ class Sale < ApplicationRecord sales_items.each do |item| #compute each item and added to total - subtotal_price = subtotal_price + item.price + subtotal_price = subtotal_price + item.price # check for item is taxable and calculate if item.is_taxable total_taxable = total_taxable + item.taxable_price end end - compute_tax(sale, total_taxable, total_discount, order_source, tax_type) - sale.total_amount = subtotal_price sale.total_discount = total_discount - sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax - sale.grand_total_round + if type =="foc" + sale.grand_total = 0 + else + sale.grand_total = (sale.total_amount - sale.total_discount) + sale.total_tax + sale.grand_total_round + end + if discount_type == "member_discount" sale.discount_type = discount_type end @@ -2955,13 +2958,10 @@ end #not to show decimal in grand total def grand_total_round - shop =Shop.first - print_settings = PrintSetting.get_precision_delimiter() - if !print_settings.nil? - self.grand_total =self.grand_total.round(print_settings.precision.to_i) - puts self.grand_total - puts "Hello grand_total_round" - end + print_settings = PrintSetting.get_precision_delimiter() + if !print_settings.nil? + self.grand_total =self.grand_total.round(print_settings.precision.to_i) + end end private diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index b8ada0ed..bd97e5c5 100755 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -85,8 +85,10 @@ class SaleItem < ApplicationRecord # sale_item.is_taxable = 1 # sale_item.sale_id = sale_id # sale_item.save - sale = Sale.find(sale_id) - sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount) + if type != "foc" + sale = Sale.find(sale_id) + sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount) + end end def self.get_order_items_details(sale_id) diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 42a4452c..2e1700f8 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -82,7 +82,6 @@ class SalePayment < ApplicationRecord amount_due = amount_due - payment.payment_amount end end - if (amount_due >= 0) payment_status = false membership_data = nil @@ -419,6 +418,8 @@ class SalePayment < ApplicationRecord sale_items.each do|item| SaleItem.update_existing_item(item.qty, item, self.sale.sale_id, "foc", item.unit_price, item.price) end + sale = Sale.find(self.sale.sale_id) + sale.compute_by_sale_items(sale.id, sale.sale_items, sale.total_discount,'','','',"foc") self.payment_method = "foc" self.payment_amount = self.received_amount diff --git a/app/views/layouts/_left_sidebar.html.erb b/app/views/layouts/_left_sidebar.html.erb index 4fee71b1..c948964d 100644 --- a/app/views/layouts/_left_sidebar.html.erb +++ b/app/views/layouts/_left_sidebar.html.erb @@ -103,9 +103,9 @@
  • Sale Items
  • -
  • + <% if order_reservation %>
  • <%= t("views.right_panel.detail.order_reservation") %> @@ -289,9 +289,9 @@
  • Hourly Sale Items
  • -
  • + <% if order_reservation %>
  • <%= t("views.right_panel.detail.order_reservation") %> From a4e88692341b0d544808b1d6fc6c2410524e43d4 Mon Sep 17 00:00:00 2001 From: Myat Zin Wai Maw Date: Wed, 11 Sep 2019 17:12:15 +0630 Subject: [PATCH 11/11] add foc amount in saleitem report --- app/controllers/origami/void_controller.rb | 1 - app/views/reports/saleitem/index.html.erb | 18 ++++++++++++--- app/views/reports/saleitem/index.xls.erb | 27 +++++++++++++++++++++- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 0523023e..6af6c275 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -8,7 +8,6 @@ class Origami::VoidController < BaseOrigamiController access_code = params[:access_code] if Sale.exists?(sale_id) sale = Sale.find_by_sale_id(sale_id) - puts sale.to_json if sale.discount_type == "member_discount" sale.update_attributes(total_discount: 0) sale.compute_by_sale_items(sale_id, sale.sale_items,0,order_source) diff --git a/app/views/reports/saleitem/index.html.erb b/app/views/reports/saleitem/index.html.erb index a56d6808..5abe8a0b 100644 --- a/app/views/reports/saleitem/index.html.erb +++ b/app/views/reports/saleitem/index.html.erb @@ -95,7 +95,6 @@ total_qty += sale.total_item*(-1) end %> - <% if sale.status_type == "foc" && sale.grand_total < 0 total_item_foc += sale.grand_total*(-1) end %> @@ -249,9 +248,21 @@
  • - - + + + <% if @type =="" || @type =="all" || @type.nil? %> + + + + + + + + + + + <% end %> <% end %> <% if @type == "other"%> @@ -296,6 +307,7 @@ \ No newline at end of file
    Sub Total:<%= sub_total %><%= number_with_precision(sub_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
    Discount:(<%= @obj_sale.total_discount rescue 0%>)(<%= number_with_precision(@obj_sale.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)
    <%= @obj_sale.total_tax rescue 0%><%= number_with_precision(@obj_sale.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%>
    Rounding Adj:<%= @obj_sale.rounding_adjustment rescue 0%><%= number_with_precision(@obj_sale.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%>
    Grand Total:<%= @obj_sale.grand_total rescue 0%><%= number_with_precision(@obj_sale.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
      <%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.item") %> <%= total_qty%><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.amount") %><%= number_with_precision(grand_total , precision:precision.to_i,delimiter:delimiter)%>
     Total FOC Amount<%= number_with_precision(@foc_data , precision:precision.to_i,delimiter:delimiter)%>
     <%= t("views.right_panel.detail.net_amount") %><%= number_with_precision(grand_total -@foc_data , precision:precision.to_i,delimiter:delimiter)%>