I have a sales system, where each user has an X percentage on their sale, at the moment I have 15 users, 10 of them with 5% profit on each sale, and the other 5 have 8% profit on each sale.
I then have my administration page where I see how much I will have to pay them all if I add up all the percentages of gain, the problem is that I have to do the sales calculation per sale, that is, if the user has a 5% profit and the other has 8%, I have to script
do the following:
$Valor += $ValorDoProduto * ($GanhoDoUsuario / 100);
So, if I add up all the users, I will have an X value that represents the amount that I will pay if I add up all the gains of each user.
But I would like to make it simpler, so that I calculate all sales, then returning an X value, that X value is the sales without taking the gain from the seller, so when I have the value X that is the sum of all products sold I would add up all percentages, and then subtract and have the same value as I would have using the calculation up there.
Explaining better:
I have a user table in MySQL
, each user has a percentage gain for each sale, is there the possibility of 'adding' all the percentages and then do a single calculation to determine how much commission I will have to pay to all of them?