From 45b60cfea1f33cd027ccb90e8a05f328ed389ddf Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sun, 20 Feb 2022 14:52:11 -0500 Subject: [PATCH] PhysicalAddress to_s --- app/controllers/customers_controller.rb | 16 ++++++++++++++++ app/views/customers/_details.html.erb | 9 ++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb index 471e513..6950ccc 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -90,6 +90,8 @@ class CustomersController < ApplicationController @customer = Customer.find_by_id(params[:id]) @vehicles = @customer.vehicles.paginate(:page => params[:page]) @issues = @customer.issues + @billing_address = address_to_s(@customer.billing_address) + @shipping_address = address_to_s(@customer.shipping_address) rescue ActiveRecord::RecordNotFound render_404 end @@ -189,4 +191,18 @@ class CustomersController < ApplicationController found_non_zero end + # format a quickbooks address to a human readable string + def address_to_s (address) + return if address.nil? + string = a.line1 + string << "\n" + address.line2 if address.line2 + string << "\n" + address.line3 if address.line3 + string << "\n" + address.line4 if address.line4 + string << "\n" + address.line5 if address.line5 + string << " " + address.city + string << ", " + address.country_sub_division_code + string << " " + address.postal_code + return string + end + end diff --git a/app/views/customers/_details.html.erb b/app/views/customers/_details.html.erb index e269716..3e72bae 100644 --- a/app/views/customers/_details.html.erb +++ b/app/views/customers/_details.html.erb @@ -17,12 +17,12 @@ <%=t(:label_billing_address)%> - <%= customer.billing_address %> + <%= @billing_address %> <%=t(:label_shipping_address)%> - <%= customer.shipping_address %> + <%= @shipping_address %> @@ -35,11 +35,6 @@ $<%= customer.balance %> - - <%=t(:label_balance_with_jobs)%> - $<%= customer.balance_with_jobs %> - - <%=t(:field_notes)%> <%= customer.notes %>