Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Fix Stock cover report stock out calculation #7844
When running the Stock Cover Report from the Back Office > Stock > Stock Cover, the data in the field "Quantity Sold" is displaying either no value ("--") or an incorrect value.
In AdminStockCoverController.php in the getList method the quantity sold is calculated TWICE, in TWO different ways, resulting in two different results.
The first time quantity sold is calculated is getList in the following call:
StockManagerFactory::getManager()->getProductCoverage is used to determine the amount of stock sold over the coverage period specified then uses this value to calculate the amount of coverage required based on the amount of physical stock available.
The second time quantity sold is calculated in getList in the following call:
Unfortunately this method performs a different query compared to that in StockManagerFactory::getManager()->getProductCoverage and yields different results to the value used in the first coverage calculation.
Based on my analysis the results reported by getQuantitySold can be significantly different (reporting no results), close or accurate depending on a variety of situations.
This fix creates a new method in StockManager with the query extracted from getProductCoverage to calculate the Product Out over the coverage period so it can be reused by AdminStockCoverController and hence return a consistent result.
Some small cosmetic changes are needed, but code looks good for me