Skip to content

Commit

Permalink
Merge pull request #320 from roomorama/feature/fee-percentages-for-hosts
Browse files Browse the repository at this point in the history
Show hosts fee percentage on suppliers#show
  • Loading branch information
Renato Mascarenhas authored Sep 8, 2016
2 parents 937e52b + d903517 commit 7cdea6c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ This file summarises the most important changes that went live on each release
of Concierge. Please check the Wiki entry on the release process to understand
how this file is formatted and how the process works.

## Unreleased
### Added
- fee percentage for hosts on Web app on suppliers#show.

## [0.8.0] - 2016-09-08
### Added
- Kigo and KigoLegacy integration: metadata sync, calendar sync, quoting, booking, cancelling support.
Expand Down
2 changes: 2 additions & 0 deletions apps/web/templates/suppliers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<th>#</th>
<th>Identifier</th>
<th>Roomorama Username</th>
<th>Fees Applied</th>
<th>Access Token</th>
<th># Properties</th>
</tr>
Expand All @@ -24,6 +25,7 @@
<td><%= host.id %></td>
<td><code><%= host.identifier %></code></td>
<td><%= host.username %></td>
<td><%= format_fee_percentage(host.fee_percentage) %></td>
<td><code><%= format_access_token(host) %></code></td>
<td><%= host_properties(host) %></td>
</tr>
Expand Down
11 changes: 11 additions & 0 deletions apps/web/views/suppliers/show.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def host_properties(host)
number_formatter.present(total)
end

# formats the +fee+, given as a float, to a percentage notation, with a single
# digit precision.
#
# Example
#
# host.fee_percentage # => 8.0
# format_fee_percentage(host.fee_percentage) # => "8.0%"
def format_fee_percentage(fee)
sprintf("%.1f%", fee)
end

# in order not to show the access token used by a host in its entirety,
# this extracts the first 5 digits of a +Host+ access token, and appends
# +...+ to indicate the content is just a substring.
Expand Down
4 changes: 3 additions & 1 deletion spec/web/views/suppliers/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

before do
2.times { |n|
create_host(supplier_id: supplier.id, identifier: "host#{n}", access_token: "token#{n}")
create_host(supplier_id: supplier.id, fee_percentage: (n + 2).to_f, identifier: "host#{n}", access_token: "token#{n}")
}
end

Expand All @@ -39,6 +39,8 @@
it "renders a list of hosts for the supplier" do
expect(sanitized).to include %(<td><code>host0</code></td>)
expect(sanitized).to include %(<td><code>host1</code></td>)
expect(sanitized).to include %(<td>2.0%</td>)
expect(sanitized).to include %(<td>3.0%</td>)

expect(sanitized).to include %(<td><code>token...</code></td>)
end
Expand Down

0 comments on commit 7cdea6c

Please sign in to comment.