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); }
protected function setUp() { $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); $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, false); $this->prdId = ProductsService::create($prd); }
protected function setUp() { $this->taxes = array(); $taxCat1 = new TaxCat("Standard"); $tax1 = new Tax(null, "20%", stdtimefstr("2014-01-01 00:00:00"), 0.2); $taxCat1->addTax($tax1); $tax3 = new Tax(null, "Old", stdtimefstr("2000-01-01 00:00:00"), 0.22); $taxCat1->addTax($tax3); $taxCat1->id = TaxesService::createCat($taxCat1); $taxCat2 = new TaxCat("Reduced"); $tax2 = new Tax(null, "10%", stdtimefstr("2014-01-01 00:00:00"), 0.1); $taxCat2->addTax($tax2); $taxCat2->id = TaxesService::createCat($taxCat2); $this->taxes[] = $taxCat1; $this->taxes[] = $taxCat2; }
protected function setUp() { $this->products = array(); $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); $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, true, 0.3, null, "12345", false, true, 0.2); $prd->id = ProductsService::create($prd); $this->products[] = $prd; $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 3, $taxCat->id, true, false); $prd2->id = ProductsService::create($prd2); $this->products[] = $prd2; }
protected function setUp() { $this->areas = array(); $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); $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, false); $prd->id = ProductsService::create($prd); $area = new TariffArea("Area", 1); $area->addPrice($prd->id, 0.8); $srv = new TariffAreasService(); $area->id = $srv->create($area); $area2 = new TariffArea("Area51", 51); $area2->id = $srv->create($area2); $this->areas[] = $area; $this->areas[] = $area2; }
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); }
protected function setUp() { $this->products = array(); $this->compositions = array(); // Setup tax and categories $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); $pdo = PDOBuilder::getPDO(); $id = CompositionsService::CAT_ID; $catCmp = new Category(null, "Compositions", false, 1); $sql = "INSERT INTO CATEGORIES (ID, NAME, PARENTID, DISPORDER, IMAGE) " . "VALUES (:id, :name, :pid, :order, null)"; $stmt = $pdo->prepare($sql); $stmt->bindParam(":name", $catCmp->label, \PDO::PARAM_STR); $stmt->bindParam(":pid", $catCmp->parentId, \PDO::PARAM_INT); $stmt->bindParam(":id", $id, \PDO::PARAM_INT); $stmt->bindParam(":order", $catCmp->dispOrder, \PDO::PARAM_INT); $stmt->execute(); $cat = new Category(null, "Category", false, 2); $cat->id = CategoriesService::createCat($cat); // Set up products $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, true, 0.3, null, "12345", false, true, 0.2); $prd->id = ProductsService::create($prd, null); $this->products[] = $prd; $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 3, $taxCat->id, true, false); $prd2->id = ProductsService::create($prd2, null); $this->products[] = $prd2; $cmp = new Composition("CMP", "composition", 1.0, $id, 1, $taxCat->id, true, true, 0.3, null, "12345", false, true, 0.2); $subgrp = new Subgroup(null, "Subgroup", 1, false); $subgrp->addProduct(new SubgroupProduct($prd->id, null, 1)); $subgrp->addProduct(new SubgroupProduct($prd2->id, null, 2)); $cmp->addGroup($subgrp); $cmp->id = CompositionsService::create($cmp, null, null); $this->compositions[] = $cmp; }
protected function setUp() { // Attribute set $set = new AttributeSet("set"); $attr = new Attribute("attr", 1); $val = new AttributeValue("value"); $attr->id = AttributesService::createAttribute($attr); $val->id = AttributesService::createValue($val, $attr->id); $attr->addValue($val); $set->addAttribute($attr); $set->id = AttributesService::createSet($set); // Product, tax and category $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); $taxCat2 = new TaxCat("Tax2"); $tax2 = new Tax(null, "Tax2", stdtimefstr("2001-01-01 00:00:00"), 0.2); $taxCat2->addTax($tax2); $taxCat2->id = TaxesService::createCat($taxCat2); $pdo = PDOBuilder::getPDO(); $stmt = $pdo->prepare("INSERT INTO CATEGORIES (ID, NAME) " . "VALUES (:id, :name)"); $stmt->execute(array(":id" => "-1", ":name" => "Refill")); $cat = new Category(null, "Category", false, 1); $cat->id = CategoriesService::createCat($cat); $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, false, 0.5, $set->id); $prd->id = ProductsService::create($prd); $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 1, $taxCat2->id, true, false, 0.5, null); $prd2->id = ProductsService::create($prd2); $prdRefill = new Product("REFILL", "Refill", 1.0, "-1", null, 1, $taxCat->id, true, false); $prdRefill->id = ProductsService::create($prdRefill); // Tariff area $srvArea = new TariffAreasService(); $area = new TariffArea("area", 1); $area->addPrice($prd->id, 0.8); $area->id = $srvArea->create($area); $this->areaId = $area->id; // Customer $srvCust = new CustomersService(); $cust = new Customer(1, "Cust", "It's me", "card", null, null, 50.0, 10.0, 5.0, stdtimefstr("2012-01-01 00:00:00"), "It's", "me", "*****@*****.**", "012345", "23456", "11111", "Address1", "Address2", "59000", "City", "Region", "France", "Note", true); $cust->id = $srvCust->create($cust); $this->custId = $cust->id; // Location $locSrv = new LocationsService(); $loc = new Location("Location"); $loc->id = $locSrv->create($loc); $this->locationId = $loc->id; // Cash register $srvCashReg = new CashRegistersService(); $cashReg = new CashRegister("Cash", $loc->id, 1); $cashReg->id = $srvCashReg->create($cashReg); // Cash $srvCash = new CashesService(); $cash = $srvCash->add($cashReg->id); $cash->openDate = stdtimefstr("2000-02-02 02:02:02"); $srvCash->update($cash); $this->cashId = $cash->id; // User $srvUsers = new UsersService(); $user = new User("User", null, null, "0", true, false); $user->id = $srvUsers->create($user); // Currency $curr = new Currency("Eur", "€", ",", ".", "#,##0.00\$", 1, true, false); $srvCurr = new CurrenciesService(); $curr->id = $srvCurr->create($curr); // Discount profile $profSrv = new DiscountProfilesService(); $prof = new DiscountProfile("Profile", 0.1); $prof->id = $profSrv->create($prof); $this->discountProfilId = $prof->id; // Ticket $tkt1 = array("date" => stdtimefstr("2012-01-01 00:00:00"), "userId" => $user->id, "customerId" => null, "type" => Ticket::TYPE_SELL, "custCount" => 3, "tariffAreaId" => null, "discountRate" => 0.0, "discountProfileId" => null, "payments" => array(array("type" => "cash", "amount" => 10, "currencyId" => $curr->id, "currencyAmount" => 12)), "lines" => array(array("dispOrder" => 1, "productId" => $prd->id, "taxId" => $tax->id, "attributes" => null, "quantity" => 1.0, "price" => 10.0, "discountRate" => 0.0))); $jsAttr = array("attributeSetId" => $set->id, "values" => array(array("id" => $attr->id, "value" => "value"))); $tkt2 = array("date" => stdtimefstr("2012-01-01 00:00:00"), "userId" => $user->id, "customerId" => null, "type" => Ticket::TYPE_SELL, "custCount" => 3, "tariffAreaId" => null, "discountRate" => 0.25, "discountProfileId" => $prof->id, "payments" => array(array("type" => "cash", "amount" => 10, "currencyId" => $curr->id, "currencyAmount" => 12)), "lines" => array(array("dispOrder" => 1, "productId" => $prd->id, "taxId" => $tax->id, "attributes" => $jsAttr, "quantity" => 1.0, "price" => 10.0, "discountRate" => 0.25))); $this->jsTicket1 = json_encode($tkt1); $this->jsTicket2 = json_encode($tkt2); }
protected function setUp() { // Attribute set $set = new AttributeSet("set"); $attr = new Attribute("attr", 1); $val = new AttributeValue("value"); $attr->id = AttributesService::createAttribute($attr); $val->id = AttributesService::createValue($val, $attr->id); $attr->addValue($val); $this->attr = $attr; $set->addAttribute($attr); $set->id = AttributesService::createSet($set); $this->attrSet = $set; // Product, tax and category $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); $taxCat2 = new TaxCat("Tax2"); $tax2 = new Tax(null, "Tax2", stdtimefstr("2001-01-01 00:00:00"), 0.2); $taxCat2->addTax($tax2); $taxCat2->id = TaxesService::createCat($taxCat2); $this->tax = $taxCat->taxes[0]; $this->tax2 = $taxCat2->taxes[0]; $pdo = PDOBuilder::getPDO(); $stmt = $pdo->prepare("INSERT INTO CATEGORIES (ID, NAME) " . "VALUES (:id, :name)"); $stmt->execute(array(":id" => "-1", ":name" => "Refill")); $cat = new Category(null, "Category", false, 1); $cat->id = CategoriesService::createCat($cat); $prd = new Product("REF", "product", 1.0, $cat->id, null, 1, $taxCat->id, true, false, 0.5, $set->id); $prd->id = ProductsService::create($prd); $this->prd = $prd; $prd2 = new Product("REF2", "product2", 2.0, $cat->id, null, 1, $taxCat2->id, true, false, 0.5, null); $prd2->id = ProductsService::create($prd2); $prdRefill = new Product("REFILL", "Refill", 1.0, "-1", null, 1, $taxCat->id, true, false); $prdRefill->id = ProductsService::create($prdRefill); $this->prd = $prd; $this->prd2 = $prd2; $this->prdRefill = $prdRefill; // Tariff area $srvArea = new TariffAreasService(); $area = new TariffArea("area", 1); $area->addPrice($this->prd->id, 0.8); $area->id = $srvArea->create($area); $this->area = $area; // Discount profile $srvProfile = new DiscountProfilesService(); $profile = new DiscountProfile("Discount profile", 1.0); $profile->id = $srvProfile->create($profile); $this->discountProfile = $profile; // Customer $srvCust = new CustomersService(); $cust = new Customer(1, "Cust", "It's me", "card", null, null, 50.0, 10.0, 5.0, stdtimefstr("2012-01-01 00:00:00"), "It's", "me", "*****@*****.**", "012345", "23456", "11111", "Address1", "Address2", "59000", "City", "Region", "France", "Note", true); $cust->id = $srvCust->create($cust); $this->customer = $cust; // Location $locSrv = new LocationsService(); $loc = new Location("Location"); $loc->id = $locSrv->create($loc); $this->location = $loc; // Cash $srvCashReg = new CashRegistersService(); $cashReg = new CashRegister("CashReg", $loc->id, 1); $cashReg->id = $srvCashReg->create($cashReg); $srvCash = new CashesService(); $cash = $srvCash->add($cashReg->id); $cash->openDate = stdtimefstr("2000-02-02 02:02:02"); $srvCash->update($cash); $this->cash = $cash; // User $srvUsers = new UsersService(); $user = new User("User", null, null, "0", true, false); $user->id = $srvUsers->create($user); $this->user = $user; // Currency $curr = new Currency("Eur", "€", ",", ".", "#,##0.00\$", 1, true, false); $srvCurr = new CurrenciesService(); $curr->id = $srvCurr->create($curr); $this->currency = $curr; }