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 was entitled to 850unid (at 10%) which were his sales. Imagine that in the next period he sold 500 more, so he is entitled to 150unid (10%) and 350unid (12%) but there may also be the case where he sells another 6000 and then he is entitled to 150unid to 10%) 4000unid (at 12%) and 1850unit (at 15%). How can I write this in php so that the percentages can fit into each quantity, respecting already the quantities that have been paid and show this in a table?
| DE | Até | Taxa |
|------------|-------------|--------------|
| 1 | 1000 | 10% |
| 1001 | 5000 | 12% |
| 5001 | 15000 | 15% |