EH
Asked
I want to ask how this feature work. Can i get more explanation about this one, because i tried to purchase a product from 2 supplier with 2 different price. The first price is "5" and the second is "8". After that i tried to make a pos sale for that product, i sold it one by one and see my daily sales report. The cost, profit, revenue is correct. But when i check the "sma_warehouses_product" table with that product id the avg cost is 5.7500, shouldnt it be 6.5 because of the 2 number 5 and 8 ?
Attachments
- MSAnsweredHello,
Not only cost but the quantity purchased matters too. Please check the `updateAVCO` method of the `app/models/admin/Purchases_model.php`
```
avg cost = ((old quantity * old avg cost) + (new quantity * new cost)) / (old quantity + new quantity)
```
Thank you - EHAnsweredI have checked that file and my line was
```
$avg_cost = ($total_cost / $total_quantity);
```
Should i change it like you write ? - MSAnsweredNo. The `$total_cost` & `$total_quantity` already calculated above that line. You don't have to change any thing unless you know what you doing. The method is provided just for reference. Thank you
- EHAnsweredDoes that mean it will make my profit become inaccurate? Or if I don't use over selling the avg method doesn't matter at all?
- MSAnsweredDoesn't the profit calculated correct? Why are you saying that the avg cost should be `6.5`? How much quantity did you purchase on each order with 5 and 8? Did you calculated the avg cost with above shared formula?
I don't understand, what is the issue actually? - EHAnsweredOh nvm, I misunderstood your reply. My bad, everything is working fine.
- Login to Reply