Calculate miscellaneous percentages

-1

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?

    
asked by anonymous 24.04.2016 / 23:56

1 answer

1

Not possible. If you add up the values of all the products, you do not know that part of the total profits corresponds to the gains of 5% or those of 8%.

At most you can add up all the sales of the users of each subgroup (a subgroup being the set of users who receive 5% or 8% of a sale). In the end you apply the percentage to the sum of each of the subgroups to know how much you have to pay each seller. So you only have to make one calculation per subgroup (in your case 2) instead of one per each user.

    
25.04.2016 / 00:38