コード例 #1
0
 public function getTotalByIdFreigthFare($idFreightFare)
 {
     $idFreightFare = (array) $idFreightFare;
     $totalByIdFreightFare = 0;
     if (count($idFreightFare) > 0) {
         $products = $this->products->filterByIdFreightFare($idFreightFare);
         $restockEntries = $this->restockEntries->filterByArrayIdProduct($products->getPrimaryKeys());
         while ($restockEntries->valid()) {
             $restockEntry = $restockEntries->read();
             $totalByIdFreightFare += $this->getPurchaseSettedByIdRestockEntry($restockEntry->getIdRestockEntry());
         }
     }
     return $totalByIdFreightFare;
 }
コード例 #2
0
 public function getTotalPurchaseSettedByABC(RestockAbcClass $restockAbcClass)
 {
     $totalPurchaseSetted = 0;
     $restockEntries = $this->restockEntries->filterByABCMix($restockAbcClass->getIdRestockAbcClass());
     while ($restockEntries->valid()) {
         $restockEntry = $restockEntries->read();
         $totalPurchasePercent += $this->getSettedImportUSDByIdRestockEntry($restockEntry->getIdRestockEntry());
     }
     return $totalPurchasePercent;
 }
コード例 #3
0
ファイル: RestockController.php プロジェクト: Eximagen/sochi
 /**
  *
  * @return array
  */
 public function createAction()
 {
     $inventory = InventoryRotationQuery::create()->find()->filterByStatus(array(Product::$Status["Line"], Product::$Status["Manual"], Product::$Status["Hold"]));
     $products = ProductQuery::create()->whereAdd(Product::ITEM_CODE, $inventory->getDistinctItemCodes(), BaseQuery::IN)->addAscendingOrderBy(Product::ITEM_CODE)->find();
     if ($products->validateRestockRequiredData()) {
         $catalogYear = ProductQuery::create()->distinct()->addColumns(array(Product::CATALOG_YEAR))->addDescendingOrderBy(Product::CATALOG_YEAR)->find();
         $idFreightFares = $products->getDistinctDefaultFreightFare();
         $freightFares = new FreightFareCollection();
         if (count($idFreightFares) > 0) {
             $freightFares = FreightFareQuery::create()->whereAdd(FreightFare::ID_FREIGHT_FARE, $idFreightFares, BaseQuery::IN)->find();
         }
         $rotationGenerator = new RotationGeneratorManager();
         $rotationByFamily = $rotationGenerator->generateRotationByFamily($inventory, $products);
         $rotationByKeyMother = $rotationGenerator->generateRotationByKeyMother($inventory, $products);
         $minMaxPurchaseGenerator = new MinMaxPurchaseGeneratorManager();
         $minMaxPurchaseList = $minMaxPurchaseGenerator->generateMinMaxPurchase($inventory, $rotationByKeyMother, $rotationByFamily, $products, $freightFares);
         try {
             $this->getRestockCatalog()->beginTransaction();
             $restock = RestockFactory::createFromArray(array(Restock::RESTOCK_TYPE => Restock::$restockTypes["Min"], Restock::CURRENT_PRODUCT_CATALOG => $catalogYear->getLastCatalogYear(), Restock::PERCENT_A => 100, Restock::PERCENT_B => 100, Restock::PERCENT_C => 100, Restock::PERCENT_D => 100, Restock::PERCENT_E => 100, Restock::PERCENT_R => 100));
             $this->getRestockCatalog()->create($restock);
             $restockEntries = new RestockEntryCollection();
             while ($minMaxPurchaseList->valid()) {
                 $minMaxPurchaseLine = $minMaxPurchaseList->read();
                 $product = $products->getByPK($minMaxPurchaseLine->getIdProduct());
                 $restockEntry = RestockEntryFactory::createFromArray(array(RestockEntry::ID_RESTOCK_ENTRY => $product->getItemCode(), RestockEntry::ID_RESTOCK => $restock->getIdRestock(), RestockEntry::ID_PRODUCT => $product->getItemCode(), RestockEntry::ABC_MIX => $minMaxPurchaseLine->getABCMix(), RestockEntry::INV_RELAT => $inventory->getByPK($product->getItemCode())->getINVRELAT(), RestockEntry::VIM_MAX => $minMaxPurchaseLine->getVIMMax(), RestockEntry::VIM_MIN => $minMaxPurchaseLine->getVIMMin(), RestockEntry::MANUAL_RESTOCK => $minMaxPurchaseLine->getManualRestock(), RestockEntry::QUANTITY => 0));
                 $restockEntries->append($restockEntry);
             }
             $currencies = CurrencyQuery::create()->find();
             $currencyExchanges = CurrencyExchangeQuery::create()->addAscendingOrderBy(CurrencyExchange::RATEDATE)->find();
             $productCosts = $this->getCostLogByIdProducts();
             $restockCalculatorManager = new RestockCalculatorManager($restock, $restockEntries, $products, $productCosts, $currencies, $currencyExchanges);
             $restockEntries->rewind();
             while ($restockEntries->valid()) {
                 $restockEntry = $restockEntries->read();
                 RestockEntryFactory::populate($restockEntry, array(RestockEntry::DESITION => $restockCalculatorManager->getDesitionByIdRestockEntry($restockEntry->getIdRestockEntry()), RestockEntry::NEW_QUANTITY_MIN => $restockCalculatorManager->getNewQuantityMinByIdRestockEntry($restockEntry->getIdRestockEntry()), RestockEntry::PRICE_MIN => $restockCalculatorManager->getNewImportMinByIdRestockEntry($restockEntry->getIdRestockEntry()), RestockEntry::NEW_QUANTITY_MAX => $restockCalculatorManager->getNewQuantityMaxByIdRestockEntry($restockEntry->getIdRestockEntry()), RestockEntry::PRICE_MAX => $restockCalculatorManager->getNewImportMaxByIdRestockEntry($restockEntry->getIdRestockEntry()), RestockEntry::PURCHASE_PRICE => $restockCalculatorManager->getPurchaseByIdRestockEntry($restockEntry->getIdRestockEntry()), RestockEntry::PURCHASE_PRICE_PERCENT => $restockCalculatorManager->getPurchasePercentByIdRestockEntry($restockEntry->getIdRestockEntry()), RestockEntry::PURCHASE_QUANTITY => $restockCalculatorManager->getQuantityByIdRestockEntry($restockEntry->getIdRestockEntry()), RestockEntry::PURCHASE_QUANTITY_PERCERNT => $restockCalculatorManager->getQuantityPercentByIdRestockEntry($restockEntry->getIdRestockEntry()), RestockEntry::MIN_TARGET_PRICE => $restockCalculatorManager->getMinTargetPriceUSDByIdProduct($restockEntry->getIdProduct())));
                 $this->getRestockEntryCatalog()->create($restockEntry->unsetIdRestockEntry());
             }
             $this->getRestockCatalog()->commit();
             $this->setFlash('ok', $this->i18n->_("The Restock was created"));
         } catch (Exception $e) {
             $this->getRestockCatalog()->rollBack();
             $this->setFlash('error', $this->i18n->_($e->getMessage()));
         }
         $this->_redirect('restock/edit');
     } else {
         return $this->_redirect('restock/data');
     }
 }