Apply rates according to the number of books sold

Asked

Viewed 47 times

0

I have the following problem:

A publisher pays x% to the author and it has several levels. If the author sells up to 1000unid books he receives 10% of the sale. Between 1000unid and 5000unid receives 12% and between 5001 and 15000unid receives 15%. During the first period of accounts he received what he was entitled to 850unid (at 10%) which were his sales. Imagine that in the next period he sold over 500, then he is entitled to receive 150unid(at 10%) and 350unid(at 12%) but there may also be the case where he sells over 6000 and then he is entitled to receive 150unid(at 10%) 4000unid(at 12%) and 1850unid(at 15%). How can I write this in php so that the percentages can fit each quantity, already respecting the amounts that were paid and show this in a table?

| DE         | Até         |      Taxa    |
|------------|-------------|--------------|
| 1          |        1000 |     10%      | 
| 1001       |        5000 |     12%      |
| 5001       |       15000 |     15%      |
  • Initially put this in a table and post together the question. It is easier to understand. For example: I don’t know the percentage he would receive between 5001 to 14999.

  • I just updated

  • I did not understand why the periods have to be cumulative and why, being cumulative, it receives percentages of all ranges. Imagine that in the first period he sold 6000 units. By the rule he will receive 15% of 6000. Right? Why do you suggest that it will receive percentages of the 3 tracks?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.