Esempio n. 1
0
 protected function setUp()
 {
     // Products
     $taxCat = new TaxCat("Tax");
     $tax = new Tax(null, "Tax", stdtimefstr("2001-01-01 00:00:00"), 0.1);
     $taxCat->addTax($tax);
     $taxCat->id = TaxesService::createCat($taxCat);
     $cat = new Category(null, "Category", false, 1);
     $cat->id = CategoriesService::createCat($cat);
     $prd1 = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, true, 0.3, null, "12345", false, true, 0.2);
     $prd1->id = ProductsService::create($prd1);
     $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 3, $taxCat->id, true, false);
     $prd2->id = ProductsService::create($prd2);
     $this->products = array($prd1, $prd2);
     // Locations
     $locSrv = new LocationsService();
     $loc1 = new Location("Location1");
     $loc1->id = $locSrv->create($loc1);
     $loc2 = new Location("Location2");
     $loc2->id = $locSrv->create($loc2);
     $this->locations = array($loc1, $loc2);
     // Stocks
     $lvl11 = new StockLevel($prd1->id, $loc1->id, null, null, 10);
     $lvl11->id = StocksService::createLevel($lvl11);
     $lvl12 = new StockLevel($prd1->id, $loc2->id, null, 5.2, null);
     $lvl12->id = StocksService::createLevel($lvl12);
     $lvl21 = new StockLevel($prd2->id, $loc1->id, null, 7, 20);
     $lvl21->id = StocksService::createLevel($lvl21);
     $move = new StockMove(stdtimefstr("2014-01-01 00:00:00"), StockMove::REASON_IN_BUY, $loc1->id, $prd1->id, null, 3.5, 2.1);
     StocksService::addMove($move);
     $this->levels = array($lvl11, $lvl12, $lvl21);
 }
 /** @depends testCreateMoveBuy
  * @depends testReadLevel
  */
 public function testReadQty()
 {
     $level = new StockLevel($this->products[0]->id, $this->locations[0]->id, null, 1.2, 15.6, 3.5);
     // Quantity is set matching to move
     $level->id = StocksService::createLevel($level);
     $move = new StockMove(stdtimefstr("2014-01-01 00:00:00"), StockMove::REASON_IN_BUY, $level->productId, $level->locationId, $level->attrSetInstId, $level->qty, 10);
     $move->id = StocksService::addMove($move);
     $read = StocksService::getLevel($move->productId, $move->locationId, $move->attrSetInstId);
     $this->checkEquality($read, $level);
 }