From 900efb3fa68e4dfe8ef6a1e0295923dc580fd37e Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 28 Nov 2017 19:11:19 +0630 Subject: [PATCH] update report --- app/controllers/crm/customers_controller.rb | 7 +------ .../reports/receipt_no_controller.rb | 2 +- app/models/customer.rb | 21 ++++++++++++------- app/models/sale.rb | 2 +- app/views/crm/customers/show.html.erb | 4 ++-- app/views/reports/dailysale/index.html.erb | 6 +++--- app/views/reports/receipt_no/index.html.erb | 6 +++--- 7 files changed, 25 insertions(+), 23 deletions(-) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index f95b54a9..04711cf4 100755 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -235,7 +235,7 @@ end id = @crm_customer.membership_id member_group_id = params[:member_group_id] - if id.nil? && !member_group_id.nil? + 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 @@ -277,8 +277,6 @@ end rescue SocketError response = { status: false} end - puts "ssssssss" - puts response.to_json customer = Customer.find(@crm_customer.customer_id) if response["status"] == true @@ -337,9 +335,6 @@ end rescue SocketError response = { status: false} end - - puts "ssssssss" - puts response.to_json if response["status"] == true customer = Customer.find(@crm_customer.customer_id) diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 6d536ee7..254bb423 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -22,7 +22,7 @@ authorize_resource :class => false @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type) @tax_profiles = TaxProfile.order('order_by asc') -puts @sale_taxes.to_json +puts @sale_data.count puts "sssssss" puts @tax_profiles.to_json @from = from diff --git a/app/models/customer.rb b/app/models/customer.rb index 13e6c277..b30b51c6 100755 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -184,12 +184,17 @@ class Customer < ApplicationRecord # Control for Paypar Cloud begin - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,total_sale_transaction_amount: sObj.grand_total,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, - receipt_no: receipt_no,auth_token:auth_token}.to_json, - :headers => { - 'Content-Type' => 'application/json', - 'Accept' => 'application/json; version=2' - }, :timeout => 10) + response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id , + total_sale_transaction_amount: sObj.grand_total, + merchant_uid:merchant_uid, + total_amount: total_amount, + campaign_type_id: campaign_type_id, + receipt_no: receipt_no, + auth_token:auth_token}.to_json, + :headers => { + 'Content-Type' => 'application/json', + 'Accept' => 'application/json; version=2' + }, :timeout => 10) rescue Net::OpenTimeout response = { "status": false , "message": "Connect To" } @@ -201,7 +206,9 @@ class Customer < ApplicationRecord response = { "status": false, "message": "Can't connect server"} end - return response + return response + puts response.to_json + puts "ttttttttttttttttttttttt" end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 17f49a12..cd067d1f 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -875,7 +875,7 @@ end # end def grand_total_after_rounding - return self.old_grand_total.to_f + self.rounding_adjustment.to_f + return self.grand_total.to_f + self.rounding_adjustment.to_f end def get_cash_amount diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 338aea1d..26ce197a 100755 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -77,7 +77,7 @@ - <% if @response["status"] == true %> + <% if @response["status"] == true && @response["data"].count > 0 %> <% @response["data"].each do |transaction| %> <%= transaction["date"]%> @@ -101,7 +101,7 @@ <%end%> <%else%> -

There is no transaction coz of <%=@response["data"]%> ...

+

There is no transaction coz of <%=@response["message"]%> ...

<% end %> diff --git a/app/views/reports/dailysale/index.html.erb b/app/views/reports/dailysale/index.html.erb index e258f892..f6b8afc2 100755 --- a/app/views/reports/dailysale/index.html.erb +++ b/app/views/reports/dailysale/index.html.erb @@ -90,9 +90,9 @@ <%= number_with_delimiter(sprintf("%.2f",sale[:credit_amount]), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:foc_amount]), :delimiter => ',') rescue '-'%> (<%= number_with_delimiter(sprintf("%.2f",sale[:total_discount]), :delimiter => ',') rescue '-'%>) - <%= number_with_delimiter(sprintf("%.2f",sale[:old_grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%> + <%= number_with_delimiter(sprintf("%.2f",sale[:grand_total].to_f + sale[:rounding_adj].to_f ), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",sale[:rounding_adj].to_f), :delimiter => ',') rescue '-'%> - <%= number_with_delimiter(sprintf("%.2f",sale[:old_grand_total]), :delimiter => ',') rescue '-'%> + <%= number_with_delimiter(sprintf("%.2f",sale[:grand_total]), :delimiter => ',') rescue '-'%> <% count = count + 1 %> <% end %> @@ -110,7 +110,7 @@ (<%= number_with_delimiter(sprintf("%.2f",discount), :delimiter => ',') rescue '-'%>) <%= number_with_delimiter(sprintf("%.2f",total), :delimiter => ',') rescue '-'%> <%= number_with_delimiter(sprintf("%.2f",rounding_adj), :delimiter => ',') rescue '-'%> - <%= number_with_delimiter(sprintf("%.2f",old_grand_total), :delimiter => ',') rescue '-'%> + <%= number_with_delimiter(sprintf("%.2f",grand_total), :delimiter => ',') rescue '-'%> <% total_tax = 0 %> diff --git a/app/views/reports/receipt_no/index.html.erb b/app/views/reports/receipt_no/index.html.erb index 08386eb7..1d613fdf 100755 --- a/app/views/reports/receipt_no/index.html.erb +++ b/app/views/reports/receipt_no/index.html.erb @@ -90,7 +90,7 @@ <%= tax.tax_payable_amount rescue '-' %> <%end%> - <%= result.old_grand_total %> + <%= result.grand_total %> <%= result.rounding_adjustment.to_f rescue '-' %> <%= result.grand_total_after_rounding() rescue '-'%> @@ -103,9 +103,9 @@ <% @sale_taxes.each do |tax| %> <%= tax.st_amount.round(2) %> <% end %> - <%= old_grand_total.to_f.round(2) rescue '-'%> + <%= grand_total.to_f.round(2) rescue '-'%> <%= rounding_adj rescue '-'%> - <%= old_grand_total.to_f.round + rounding_adj %> + <%= grand_total.to_f.round + rounding_adj %>