/** * This function generates and return the rotation by family * (This function generate the math of Claculo ABC x Sfam in new_rotation workset Excel Document) * * @author Erick Guevara Mart�nez * @param InventoryRotationCollection $inventory * @param ProductCollection $products */ public function generateRotationByFamily(InventoryRotationCollection $inventory, ProductCollection $products) { // Init a new stock $stockByFamily = new FamilyStock(); // Read all inventory lines to get the family stock rotation $inventory->rewind(); while ($inventory->valid()) { $productInventory = $inventory->read(); $product = $products->getByPK($productInventory->getItemCode()); // If the product exist in own catalog then constinue if ($product instanceof Product && $product->isLine()) { // If the family product exist in the stock then get the family line and increment the total sale if ($stockByFamily->existIndex(substr($product->getItemCode(), 0, 3))) { $familyLine = $stockByFamily->getByIndex(substr($product->getItemCode(), 0, 3)); $familyLine->setTotalSale($familyLine->getTotalSale() + $productInventory->getTVTA()); // If the family product not exist in the stock, then create it } else { $familyLine = new FamilyLine(); $familyLine->setIdFamily(substr($product->getItemCode(), 0, 3))->setTotalSale($productInventory->getTVTA()); } // Add the family line into stock $stockByFamily->addStockable($familyLine); } } // Create a ABC classification by sale and return the stock return $stockByFamily->ABCClassmentBySale(); }
/** * This function calculates the ABC Mix of a stock line * * @author Erick Guevara Martínez * @param FamilyLine $familyLine * @param KeyMotherLine $keyMotherLine * @return RestockAbcClass */ private function getABCMix(FamilyLine $familyLine, KeyMotherLine $keyMotherLine) { if ($keyMotherLine->isRescue()) { return $this->getABCClass()->getR(); } if ($familyLine->isClass($this->getABCClass()->getA()) || $keyMotherLine->isClass($this->getABCClass()->getA())) { return $this->getABCClass()->getA(); } if ($familyLine->isClass($this->getABCClass()->getB()) || $keyMotherLine->isClass($this->getABCClass()->getB())) { return $this->getABCClass()->getB(); } if ($familyLine->isClass($this->getABCClass()->getC()) || $keyMotherLine->isClass($this->getABCClass()->getC())) { return $this->getABCClass()->getC(); } if ($familyLine->isClass($this->getABCClass()->getD()) || $keyMotherLine->isClass($this->getABCClass()->getD())) { return $this->getABCClass()->getD(); } if ($familyLine->isClass($this->getABCClass()->getE()) || $keyMotherLine->isClass($this->getABCClass()->getE())) { return $this->getABCClass()->getE(); } }