PhysicalAddress to_s

This commit is contained in:
2022-02-20 14:52:11 -05:00
parent 09313ad471
commit 45b60cfea1
2 changed files with 18 additions and 7 deletions

View File

@@ -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

View File

@@ -17,12 +17,12 @@
<tr>
<th><%=t(:label_billing_address)%></th>
<td><%= customer.billing_address %></td>
<td><%= @billing_address %></td>
</tr>
<tr>
<th><%=t(:label_shipping_address)%></th>
<td><%= customer.shipping_address %></td>
<td><%= @shipping_address %></td>
</tr>
<tr>
@@ -35,11 +35,6 @@
<td>$<%= customer.balance %></td>
</tr>
<tr>
<th><%=t(:label_balance_with_jobs)%></th>
<td>$<%= customer.balance_with_jobs %></td>
</tr>
<tr>
<th><%=t(:field_notes)%></th>
<td><%= customer.notes %></td>