diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 6d875a98..f67d413c 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -48,7 +48,22 @@ class Crm::CustomersController < BaseCrmController #get customer amount @customer = Customer.find(params[:id]) - @response = Customer.get_membership_transactions(@customer) + @response = Customer.get_membership_transactions(@customer) + # get member information + total = Customer.get_member_account(@customer) + + + @balance = 0.00 + @accountable_type = '' + if total["status"]==true + total["data"].each do |res| + if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount" + @balance += res["balance"] + # @accountable_type = res["accountable_type"] + @accountable_type = "Rebate Balance" + end + end + end # @response = "" #end customer amount diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 4557eadd..52cdf586 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -270,21 +270,17 @@ class ReceiptBillPdf < Prawn::Document if rebate_amount["status"] == true stroke_horizontal_rule rebate = 0 + redeem = 0 rebate_amount["data"].each do |res| if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Redeem" - - move_down 5 - y_position = cursor - bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do - text "Redeem Amount", :size => self.item_font_size,:align => :left - end - bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["redeem"], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right - end + redeem = redeem + res["redeem"] + end - if res["receipt_no"]== sale_data.receipt_no && res["status"]== "Rebate" + + + if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateAccount" && res["status"]== "Rebate" rebate = rebate + res["rebate"] @@ -294,11 +290,35 @@ class ReceiptBillPdf < Prawn::Document text "Rebate Earn", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "#{number_with_precision(res["rebate"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + text "#{number_with_precision(res["balance"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right + end + + end + + if res["receipt_no"]== sale_data.receipt_no && res["account_status"]== "RebateBonusAccount" && res["status"]== "Rebate" + + rebate = rebate + res["rebate"] + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Rebate Earn Bonus", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(res["balance"], :precision => precision.to_i, :delimiter => delimiter)}" , :size => self.item_font_size,:align => :right end end end + + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "Redeem Amount", :size => self.item_font_size,:align => :left + end + bounding_box([self.item_description_width,y_position], :width =>self.label_width) do + text "#{number_with_precision(redeem, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right + end end end diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 5d36f5c3..21a05d9c 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -32,6 +32,7 @@ NRC/Passport No Address DOB + Membership Type @@ -45,8 +46,16 @@ <%= @customer.nrc_no %> <%= @customer.address%> <%= @customer.date_of_birth %> + <% if @customer.membership_type.to_f > 0%> + <%lookup= Lookup.find_by_value(@customer.membership_type) %> + <%= lookup.name %> + + <%else%> + - + <%end%> + - + @@ -55,21 +64,19 @@
- <% - if @response["data"].present? %> + - <% if @response["status"] == true %> - - <% end %> + + + - <% end %> - + @@ -82,7 +89,7 @@ - + diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index b62289b1..4dd15755 100644 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -39,6 +39,9 @@ + @@ -235,23 +238,31 @@ +
+
+
+
Membership TransactionsCurrent Balance : <%= @response["data"].last["balance"]%>Current Balance : <%= @balance%>
Date Redeem Rebate BalanceFrom Account Status Receipt No
<%= transaction["redeem"]%> <%= transaction["rebate"] %> <%= transaction["balance"] %><%= transaction["account_status"] %> <%= transaction["status"] %> <%= transaction["receipt_no"] %>
+ + + + + + + + + + + + + +
StatusAction AtApproved ByRemark
+
+ + -