Show the customer's addresses again; blank missing phones

The customer page's Billing and Shipping Address were always empty: the
controller stopped setting them in March and the view still read them.
The page now formats the QuickBooks addresses itself. A missing phone
number showed as "0", and the balance as "$125.0"; they're now blank
and "$125.00".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-20 18:02:32 -05:00
1 parent 761722bbb1
commit ff9556e728
8 files changed
+27 -5

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 724 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 520 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 269 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 539 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

+7 -5
View File
@@ -1,3 +1,5 @@
<%# Phone numbers as (401) 555-0101, left blank when the customer has none %>
<% phone = ->(number) { digits = number.to_s.gsub(/\D/, ''); digits.present? ? number_to_phone(digits.to_i, area_code: true) : '' } %>
<table> <table>
<tbody> <tbody>
@@ -13,27 +15,27 @@
<tr> <tr>
<th><%= t(:label_primary_phone) %></th> <th><%= t(:label_primary_phone) %></th>
<td><%= number_to_phone(customer&.primary_phone&.gsub(/[^\d]/, '').to_i, area_code: true) %></td> <td><%= phone.call(customer&.primary_phone) %></td>
</tr> </tr>
<tr> <tr>
<th><%= t(:label_mobile_phone) %></th> <th><%= t(:label_mobile_phone) %></th>
<td><%= number_to_phone(customer&.mobile_phone&.gsub(/[^\d]/, '').to_i, area_code: true) %></td> <td><%= phone.call(customer&.mobile_phone) %></td>
</tr> </tr>
<tr> <tr>
<th><%= t(:label_billing_address) %></th> <th><%= t(:label_billing_address) %></th>
<td><pre><%= @billing_address %></pre></td> <td><pre><%= RedmineQboBilling::EstimateWriter.format_address(customer.billing_address) %></pre></td>
</tr> </tr>
<tr> <tr>
<th><%= t(:label_shipping_address) %></th> <th><%= t(:label_shipping_address) %></th>
<td><pre><%= @shipping_address %></pre></td> <td><pre><%= RedmineQboBilling::EstimateWriter.format_address(customer.shipping_address) %></pre></td>
</tr> </tr>
<tr> <tr>
<th><%= t(:label_account_balance) %></th> <th><%= t(:label_account_balance) %></th>
<td>$<%= customer.balance %></td> <td><%= number_to_currency(customer.balance || 0) %></td>
</tr> </tr>
<% if customer.notes.present? %> <% if customer.notes.present? %>
@@ -72,6 +72,26 @@ class CustomersControllerTest < Redmine::IntegrationTest
assert_response :not_found assert_response :not_found
end end
def test_show_details_from_quickbooks
address = Quickbooks::Model::PhysicalAddress.new
address.line1 = '123 Main St'
address.city = 'Springfield'
address.country_sub_division_code = 'RI'
address.postal_code = '02900'
details = Quickbooks::Model::Customer.new(display_name: 'Jane Customer', balance: BigDecimal('125'))
details.billing_address = address
details.primary_phone = Quickbooks::Model::TelephoneNumber.new.tap { |t| t.free_form_number = '401-555-0101' }
@fake.customers['9101'] = details
grant(:view_customers)
get '/customers/9101'
rows = css_select('table tr').to_h { |tr| [tr.at('th')&.text.to_s.strip, tr.at('td')&.text.to_s.strip] }
assert_equal "123 Main St\nSpringfield, RI 02900", rows[I18n.t(:label_billing_address)]
assert_equal '(401) 555-0101', rows[I18n.t(:label_primary_phone)]
# No mobile number: blank, not "0"
assert_equal '', rows[I18n.t(:label_mobile_phone)]
assert_equal '$125.00', rows[I18n.t(:label_account_balance)]
end
def test_autocomplete def test_autocomplete
grant(:view_customers) grant(:view_customers)
get '/customers/autocomplete', params: { q: 'jane custmer' } get '/customers/autocomplete', params: { q: 'jane custmer' }