Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change host_fee calculation #506

Closed
keang opened this issue Nov 2, 2016 · 9 comments
Closed

Change host_fee calculation #506

keang opened this issue Nov 2, 2016 · 9 comments

Comments

@keang
Copy link
Contributor

keang commented Nov 2, 2016

We need to change the way we calculate the "host fee" value.

Currently we use this formula:

net_rate = price / (1 + host_fee_percentage)

But we now need to change it to:

net_rate = price * host_fee_percentage

This applies to all the suppliers and all the hosts.

@kkolotyuk
Copy link
Contributor

One more bug there, we tried to find property by property_id

  def property
    @property ||= PropertyRepository.identified_by(property_id).first
  end

But property_id is not unique in our DB (((

@keang
Copy link
Contributor Author

keang commented Nov 2, 2016

oh man

@kkolotyuk
Copy link
Contributor

Also I don't get the point of this issue. Why do we need to change the formula? Looks like it really calculate the price without host_fee:

2.3.1 :001 > q = ::Quotation.new({total: 1000, property_id: '147347|1444666941|whereinrio'})
2.3.1 :007 > q.host_fee_percentage
 => 5.0
2.3.1 :008 > q.net_rate
 => 952.38

@kkolotyuk
Copy link
Contributor

Ahhhh I see, the right answer is 1000 - 5% = 950

@kkolotyuk
Copy link
Contributor

Here is the right formula:

  # The quotation without host fee
  def net_rate
    coefficient = 1 - host_fee_percentage.to_f / 100
    (total * coefficient).round(2)
  end

Test:

2.3.1 :001 > q = ::Quotation.new({total: 1000, property_id: '147347|1444666941|whereinrio'})
2.3.1 :007 > q.host_fee_percentage
 => 5.0
2.3.1 :008 > q.net_rate
 => 950.0

@kkolotyuk
Copy link
Contributor

Can I fix this?

@keang
Copy link
Contributor Author

keang commented Nov 2, 2016

Not this week =)

@keang
Copy link
Contributor Author

keang commented Nov 2, 2016

Actually yes sure!

@kkolotyuk
Copy link
Contributor

kkolotyuk commented Nov 2, 2016

Fixed net_rate calculation and add new issue #509 for wrong property bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants