Kaynağa Gözat

Produits : affichage front + gestion des prix (trait)

reduction
Guillaume 4 yıl önce
ebeveyn
işleme
79099e04f4
18 değiştirilmiş dosya ile 559 ekleme ve 156 silme
  1. +8
    -0
      ShopBundle/Context/GlobalParamInterface.php
  2. +27
    -0
      ShopBundle/Context/PriceInterface.php
  3. +8
    -0
      ShopBundle/Context/UnitInterface.php
  4. +22
    -8
      ShopBundle/Controller/Admin/ProductFamilyController.php
  5. +2
    -1
      ShopBundle/Model/AbstractEntity.php
  6. +4
    -53
      ShopBundle/Model/OrderProduct.php
  7. +98
    -0
      ShopBundle/Model/PriceTrait.php
  8. +38
    -20
      ShopBundle/Model/Product.php
  9. +1
    -1
      ShopBundle/Model/ProductCategory.php
  10. +51
    -25
      ShopBundle/Model/ProductFamily.php
  11. +2
    -42
      ShopBundle/Model/ProductPropertyTrait.php
  12. +120
    -0
      ShopBundle/Model/Unit.php
  13. +17
    -3
      ShopBundle/Repository/ProductCategoryRepository.php
  14. +50
    -0
      ShopBundle/Repository/ProductFamilyRepository.php
  15. +5
    -1
      ShopBundle/Resources/config/services.yaml
  16. +29
    -0
      ShopBundle/Services/GlobalParam.php
  17. +45
    -0
      ShopBundle/Services/Price.php
  18. +32
    -2
      ShopBundle/Services/Utils.php

+ 8
- 0
ShopBundle/Context/GlobalParamInterface.php Dosyayı Görüntüle

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context ;

interface GlobalParamInterface
{

}

+ 27
- 0
ShopBundle/Context/PriceInterface.php Dosyayı Görüntüle

@@ -0,0 +1,27 @@
<?php

namespace Lc\ShopBundle\Context ;

interface PriceInterface
{
/**
* Retourne le prix hérité
*
* @return float
*/
public function getPriceInherited();

/**
* Retourne le TaxRate hérité
*
* @return entity
*/
public function getTaxRateInherited();

/**
* Retourne le Unit hérité
*
* @return float
*/
public function getUnitInherited();
}

+ 8
- 0
ShopBundle/Context/UnitInterface.php Dosyayı Görüntüle

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context ;

interface UnitInterface
{

}

+ 22
- 8
ShopBundle/Controller/Admin/ProductFamilyController.php Dosyayı Görüntüle

@@ -10,6 +10,7 @@ use Lc\ShopBundle\Context\ProductCategoryInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\TaxRateInterface;
use Lc\ShopBundle\Context\UnitInterface;
use Lc\ShopBundle\Form\ProductFamilyCategoriesType;
use Lc\ShopBundle\Form\ProductType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
@@ -48,11 +49,16 @@ class ProductFamilyController extends AdminController
$this->choicesSupplierTaxRateParam[$tax->getId()] = $tax->getValue();
}



//là mon ami je kiffe symfo !!!!!
$this->choicesTaxRateParam[0] = $this->getUser()->getMerchant()->getTaxRate()->getValue();

// choices unit
$choicesUnits = [] ;
$unitClass = $this->em->getClassMetadata(UnitInterface::class)->getName() ;
foreach ($this->em->getRepository($unitClass)->findAll() as $unit) {
$choicesUnits[$unit->getWording()] = $unit->getId() ;
}

$formBuilder->add('taxRate', ChoiceType::class, array(
'label' => 'TVA',
'choices' => $choicesTaxRate,
@@ -80,10 +86,11 @@ class ProductFamilyController extends AdminController
},
));

$formBuilder->add('unit', ChoiceType::class, array(
'label' => 'Unité',
//''
'choices' => $this->utils->getUnitsListFormatedForType()
$formBuilder->add('unit', EntityType::class, array(
'class' => $unitClass,
/*'label' => 'Unité',
'choices' => $choicesUnits,
'data'=> 0,*/
));

$formBuilder->add('quantity', NumberType::class, array(
@@ -335,11 +342,18 @@ class ProductFamilyController extends AdminController
'entity' => $entity
]);


$productCategoryRepository = $this->getDoctrine()->getRepository(ProductCategoryInterface::class);
$categories = $productCategoryRepository->findAllParents();

Method('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]);
$parameters = [
'form' => $newForm->createView(),
'entity_fields' => $fields,
'entity' => $entity,
'categories' => $categories,
'sortableProductsField' => array()
];

return $this->executeDynamicMethod('render<EntityName>Template', ['new', $this->entity['templates']['new'], $parameters]);
}

}

+ 2
- 1
ShopBundle/Model/AbstractEntity.php Dosyayı Görüntüle

@@ -4,7 +4,9 @@ namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\ShopBundle\Context\GlobalParamInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Services\Utils;

/**
* @ORM\MappedSuperclass
@@ -36,7 +38,6 @@ abstract class AbstractEntity
*/
protected $updatedBy;


public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;

+ 4
- 53
ShopBundle/Model/OrderProduct.php Dosyayı Görüntüle

@@ -3,12 +3,15 @@
namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\PriceInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderProduct extends AbstractEntity
abstract class OrderProduct extends AbstractEntity implements PriceInterface
{
use PriceTrait ;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderProducts", cascade={"persist"})
* @ORM\JoinColumn(nullable=false)
@@ -20,22 +23,6 @@ abstract class OrderProduct extends AbstractEntity
*/
protected $product;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $taxRate;

/**
* @ORM\Column(type="float")
*/
protected $price;

/**
* @ORM\Column(type="string", length=31)
*/
protected $unit;

/**
* @ORM\Column(type="float")
*/
@@ -80,42 +67,6 @@ abstract class OrderProduct extends AbstractEntity
return $this;
}

public function getTaxRate(): ?TaxRate
{
return $this->taxRate;
}

public function setTaxRate(?TaxRate $taxRate): self
{
$this->taxRate = $taxRate;

return $this;
}

public function getPrice(): ?float
{
return $this->price;
}

public function setPrice(float $price): self
{
$this->price = $price;

return $this;
}

public function getUnit(): ?string
{
return $this->unit;
}

public function setUnit(string $unit): self
{
$this->unit = $unit;

return $this;
}

public function getQuantity(): ?float
{
return $this->quantity;

+ 98
- 0
ShopBundle/Model/PriceTrait.php Dosyayı Görüntüle

@@ -0,0 +1,98 @@
<?php

namespace Lc\ShopBundle\Model ;

use Lc\ShopBundle\Context\UnitInterface;

trait PriceTrait
{
/**
* @ORM\Column(type="float", nullable=true)
*/
protected $price;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UnitInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $unit;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $taxRate;

public function getPrice(): ?float
{
return $this->price;
}

public function getPriceInherited()
{
return $this->getPrice() ;
}

public function getUnitInherited()
{
return $this->getUnit() ;
}

public function getTaxRateInherited(): ?TaxRate
{
return $this->getTaxRate() ;
}

public function getPriceWithTax()
{
return $this->calculatePriceWithTax($this->getPriceInherited(), $this->getTaxRateInherited()->getValue()) ;
}

public function getPriceByUnitRef()
{
return $this->getPriceInherited() * $this->getUnitInherited()->getCoefficient() ;
}

public function getPriceByUnitRefWithTax()
{
return $this->calculatePriceWithTax($this->getPriceByUnitRef(), $this->getTaxRateInherited()->getValue()) ;
}

public function setPrice(float $price): self
{
$this->price = $price;

return $this;
}

public function getUnit(): ?Unit
{
return $this->unit;
}

public function setUnit(Unit $unit): self
{
$this->unit = $unit;

return $this;
}

public function getTaxRate(): ?TaxRate
{
return $this->taxRate;
}

public function setTaxRate(?TaxRate $taxRate): self
{
$this->taxRate = $taxRate;

return $this;
}

private function calculatePriceWithTax($priceWithoutTax, $taxRateValue)
{
$price = floatval($priceWithoutTax) * ($taxRateValue + 1) ;
$price = number_format(( ($price * 100)) / 100, 2) ;
return $price ;
}
}

+ 38
- 20
ShopBundle/Model/Product.php Dosyayı Görüntüle

@@ -3,16 +3,17 @@
namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\PriceInterface;
use Lc\ShopBundle\Context\ProductPropertyInterface;
use Lc\ShopBundle\Context\SortableInterface;
use Lc\ShopBundle\Services\Price;

/**
* @ORM\MappedSuperclass()
*/
abstract class Product extends AbstractEntity implements SortableInterface, ProductPropertyInterface
abstract class Product extends AbstractEntity implements SortableInterface, ProductPropertyInterface, PriceInterface
{
use SortableTrait;

use ProductPropertyTrait;

/**
@@ -26,49 +27,66 @@ abstract class Product extends AbstractEntity implements SortableInterface, Prod
*/
protected $title;

public function getPriceInherited(){
if($this->price){
public function getPriceInherited()
{
if($this->price) {
return $this->price;
}else{
}
else {
return $this->productFamily->getPrice();
}
}

public function getUnitInherited(){
if($this->unit){
public function getUnitInherited()
{
if($this->unit) {
return $this->unit;
}else{
}
else{
return $this->productFamily->getUnit();
}
}

public function getTitleInherited(){
public function getTitleInherited()
{
if($this->title){
return $this->title;
}else{
}
else{
return $this->productFamily->getTitle();
}
}

public function getAvailableQuantityInherited(){
if($this->productFamily->getBehaviorCountStock()){
public function getQuantityInherited()
{
if($this->quantity) {
return $this->quantity;
}
else{
return $this->productFamily->getQuantity();
}
}

public function getAvailableQuantityInherited()
{
if($this->productFamily->getBehaviorCountStock()) {
return $this->availableQuantity;
}else{
}
else{
return $this->productFamily->getAvailableQuantity();
}
}

public function getTaxRateInherited(){
if($this->productFamily->getTaxRate()){
return $this->productFamily->getTaxRate()->getValue();
}else{
public function getTaxRateInherited()
{
if($this->productFamily->getTaxRate()) {
return $this->productFamily->getTaxRate();
}
else{
return $this->productFamily->getMerchant()->getTaxRate()->getValue();
}
}



public function getProductFamily(): ?ProductFamily
{
return $this->productFamily;

+ 1
- 1
ShopBundle/Model/ProductCategory.php Dosyayı Görüntüle

@@ -32,7 +32,7 @@ abstract class ProductCategory extends AbstractDocumentEntity implements TreeInt
protected $childrens;

/**
* @ORM\ManyToMany(targetEntity="App\Entity\ProductFamily", mappedBy="productCategory")
* @ORM\ManyToMany(targetEntity="App\Entity\ProductFamily", mappedBy="productCategories")
*/
protected $productFamilies;


+ 51
- 25
ShopBundle/Model/ProductFamily.php Dosyayı Görüntüle

@@ -5,13 +5,18 @@ namespace Lc\ShopBundle\Model;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\GlobalParamInterface;
use Lc\ShopBundle\Context\PriceInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ProductPropertyInterface;
use Lc\ShopBundle\Services\Price;
use Lc\ShopBundle\Services\Utils;
use League\Flysystem\Util;

/**
* @ORM\MappedSuperclass()
*/
abstract class ProductFamily extends AbstractDocumentEntity implements ProductPropertyInterface
abstract class ProductFamily extends AbstractDocumentEntity implements ProductPropertyInterface, PriceInterface
{
use ProductPropertyTrait;

@@ -41,30 +46,21 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
*/
protected $products;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
* @ORM\JoinColumn(nullable=true)
*/
protected $taxRate;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\TaxRateInterface")
*/
protected $supplierTaxRate;


/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $subTitle;


/**
* @ORM\Column(type="text", nullable=true)
*/
protected $note;


/**
* @ORM\Column(type="string", length=31, nullable=true)
*/
@@ -102,6 +98,16 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
$this->products = new ArrayCollection();
}

public function getTaxRateInherited()
{
if($this->getTaxRate()) {
return $this->getTaxRate() ;
}
else {
return $this->getMerchant()->getTaxRate() ;
}
}

public function getMerchant(): ?Merchant
{
return $this->merchant;
@@ -200,19 +206,6 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
return $this;
}

public function getTaxRate(): ?TaxRate
{
return $this->taxRate;
}

public function setTaxRate(?TaxRate $taxRate): self
{
$this->taxRate = $taxRate;

return $this;
}


public function getSupplierTaxRate(): ?TaxRate
{
return $this->supplierTaxRate;
@@ -250,8 +243,6 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
return $this;
}



public function getBehaviorOutOfStock(): ?string
{
return $this->behaviorOutOfStock;
@@ -327,5 +318,40 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr
return $this;
}

private function getCheapestOrMostExpensiveProduct($comparisonFunction, $returnSelfIfNotActiveProducts)
{
$products = $this->getProducts()->getValues() ;
if(count($products) > 0) {
usort($products, $comparisonFunction) ;
return $products[0] ;
}
if($returnSelfIfNotActiveProducts) {
return $this ;
}
else {
return false ;
}
}

public function getCheapestProduct()
{
return $this->getCheapestOrMostExpensiveProduct(function($a, $b) {
return $a->getPriceInherited() > $b->getPriceInherited() ;
},true) ;
}

public function getCheapestProductByUnitRef()
{
return $this->getCheapestOrMostExpensiveProduct(function($a, $b) {
return $a->getPriceByUnitRef() > $b->getPriceByUnitRef() ;
},false) ;
}

public function getMostExpensiveProductByUnitRef()
{
return $this->getCheapestOrMostExpensiveProduct(function($a, $b) {
return $a->getPriceByUnitRef() < $b->getPriceByUnitRef() ;
},false) ;
}

}

+ 2
- 42
ShopBundle/Model/ProductPropertyTrait.php Dosyayı Görüntüle

@@ -4,27 +4,17 @@ namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Lc\ShopBundle\Services\Price;

trait ProductPropertyTrait
{



/**
* @ORM\Column(type="float", nullable=true)
*/
protected $price;
use PriceTrait ;

/**
* @ORM\Column(type="float", nullable=true)
*/
protected $buyingPrice;

/**
* @ORM\Column(type="string", length=31, nullable=true)
*/
protected $unit;

/**
* @ORM\Column(type="float", nullable=true)
*/
@@ -35,42 +25,16 @@ trait ProductPropertyTrait
*/
protected $availableQuantity;


/**
* @ORM\Column(type="float", nullable=true)
*/
protected $availableQuantityDefault;


/**
* @ORM\Column(type="date", nullable=true)
*/
protected $expirationDate;

public function getUnit(): ?string
{
return $this->unit;
}

public function setUnit(?string $unit): self
{
$this->unit = $unit;

return $this;
}

public function getPrice(): ?float
{
return $this->price;
}

public function setPrice(?float $price): self
{
$this->price = $price;

return $this;
}

public function getBuyingPrice(): ?float
{
return $this->buyingPrice;
@@ -95,7 +59,6 @@ trait ProductPropertyTrait
return $this;
}


public function getAvailableQuantity(): ?float
{
return $this->availableQuantity;
@@ -108,7 +71,6 @@ trait ProductPropertyTrait
return $this;
}


public function getAvailableQuantityDefault(): ?float
{
return $this->availableQuantityDefault;
@@ -132,6 +94,4 @@ trait ProductPropertyTrait

return $this;
}


}

+ 120
- 0
ShopBundle/Model/Unit.php Dosyayı Görüntüle

@@ -0,0 +1,120 @@
<?php

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Model\AbstractEntity;

/**
* @ORM\MappedSuperclass
*/
abstract class Unit extends AbstractEntity
{
/**
* @ORM\Column(type="string", length=32)
*/
protected $unit;

/**
* @ORM\Column(type="string", length=32)
*/
protected $wording;

/**
* @ORM\Column(type="string", length=32)
*/
protected $wordingUnit;

/**
* @ORM\Column(type="string", length=32)
*/
protected $wordingShort;

/**
* @ORM\Column(type="integer")
*/
protected $coefficient;

/**
* @ORM\ManyToOne(targetEntity="App\Entity\Unit")
* @ORM\JoinColumn(nullable=true)
*/
protected $unitReference;

public function __toString()
{
return $this->getWording() ;
}

public function getUnit(): ?string
{
return $this->unit;
}

public function setUnit(string $unit): self
{
$this->unit = $unit;

return $this;
}

public function getWording(): ?string
{
return $this->wording;
}

public function setWording(string $wording): self
{
$this->wording = $wording;

return $this;
}

public function getWordingUnit(): ?string
{
return $this->wordingUnit;
}

public function setWordingUnit(string $wordingUnit): self
{
$this->wordingUnit = $wordingUnit;

return $this;
}

public function getWordingShort(): ?string
{
return $this->wordingShort;
}

public function setWordingShort(string $wordingShort): self
{
$this->wordingShort = $wordingShort;

return $this;
}

public function getCoefficient(): ?int
{
return $this->coefficient;
}

public function setCoefficient(int $coefficient): self
{
$this->coefficient = $coefficient;

return $this;
}

public function getUnitReference(): ?self
{
return $this->unitReference;
}

public function setUnitReference(?self $unitReference): self
{
$this->unitReference = $unitReference;

return $this;
}
}

+ 17
- 3
ShopBundle/Repository/ProductCategoryRepository.php Dosyayı Görüntüle

@@ -5,6 +5,7 @@ namespace Lc\ShopBundle\Repository;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\QueryBuilder;
use Lc\ShopBundle\Context\GlobalParamInterface;
use Lc\ShopBundle\Context\ProductCategoryInterface;

/**
@@ -15,8 +16,11 @@ use Lc\ShopBundle\Context\ProductCategoryInterface;
*/
class ProductCategoryRepository extends BaseRepository
{
public function __construct(EntityManager $entityManager)
protected $globalParam ;

public function __construct(EntityManager $entityManager, GlobalParamInterface $globalParam)
{
$this->globalParam = $globalParam ;
parent::__construct($entityManager, ProductCategoryInterface::class);
}

@@ -28,13 +32,23 @@ class ProductCategoryRepository extends BaseRepository
->orderBy('e.position', 'ASC');
}

public function findAllParents($merchant)
public function findAllParents()
{
return $this->findByMerchantQuery($merchant)
return $this->findByMerchantQuery($this->globalParam->getCurrentMerchant())
->andWhere('e.parent is NULL')
->andWhere('e.status >= 0')
->orderBy('e.position', 'ASC')
->getQuery()
->getResult();
}

public function findAllByParent($parentCategory)
{
//$query = $this->findByMerchantQuery($this->globalParam->getCurrentMerchant()) ;
$query = $this->createQueryBuilder('e') ;
$query->andWhere('e.parent = :idParentCategory')
->setParameter('idParentCategory', $parentCategory->getId());

return $query->getQuery()->getResult() ;
}
}

+ 50
- 0
ShopBundle/Repository/ProductFamilyRepository.php Dosyayı Görüntüle

@@ -0,0 +1,50 @@
<?php

namespace Lc\ShopBundle\Repository;

use App\Entity\ProductFamily;
use Doctrine\ORM\EntityManager;

/**
* @method ProductFamily|null find($id, $lockMode = null, $lockVersion = null)
* @method ProductFamily|null findOneBy(array $criteria, array $orderBy = null)
* @method ProductFamily[] findAll()
* @method ProductFamily[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class ProductFamilyRepository extends BaseRepository
{
public function __construct(EntityManager $registry)
{
parent::__construct($registry, ProductFamily::class);
}


// /**
// * @return ProductFamily[] Returns an array of ProductFamily objects
// */
/*
public function findByExampleField($value)
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->orderBy('p.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
}
*/

/*
public function findOneBySomeField($value): ?ProductFamily
{
return $this->createQueryBuilder('p')
->andWhere('p.exampleField = :val')
->setParameter('val', $value)
->getQuery()
->getOneOrNullResult()
;
}
*/
}

+ 5
- 1
ShopBundle/Resources/config/services.yaml Dosyayı Görüntüle

@@ -1,4 +1,8 @@
services:
# ...
Lc\ShopBundle\Routing\ExtraLoader:
tags: [routing.loader]
tags: [routing.loader]

Lc\ShopBundle\ProductFamily:
calls:
- [initServices]

+ 29
- 0
ShopBundle/Services/GlobalParam.php Dosyayı Görüntüle

@@ -0,0 +1,29 @@
<?php

namespace Lc\ShopBundle\Services;

use Lc\ShopBundle\Context\GlobalParamInterface;
use Symfony\Component\Security\Core\Security;

class GlobalParam
{
private $security;

public function __construct(Security $security)
{
$this->security = $security ;
}

public function getCurrentMerchant()
{
$user = $this->security->getUser() ;

if($user && $user->getMerchant()) {
return $user->getMerchant() ;
}
else {
return false ;
}
}

}

+ 45
- 0
ShopBundle/Services/Price.php Dosyayı Görüntüle

@@ -0,0 +1,45 @@
<?php

namespace Lc\ShopBundle\Services ;

class Price
{
protected $price ;
protected $taxRate ;

public function __construct($price, $taxRate)
{
$this->price = $price ;
$this->taxRate = $taxRate ;
}

public function withTax()
{
return self::getPriceWithTax(
$this->price,
$this->taxRate
) ;
}

public function withoutTax()
{
return $this->price ;
}

/* Static */

public static function priceTwoDecimals($number)
{
return number_format(( ($number * 100)) / 100, 2) ;
}

public static function getPriceWithoutTax($priceWithTax, $taxRate)
{
return floatval($priceWithTax) / ($taxRate + 1);
}

public static function getPriceWithTax($priceWithoutTax, $taxRate)
{
return self::priceTwoDecimals(floatval($priceWithoutTax) * ($taxRate + 1)) ;
}
}

+ 32
- 2
ShopBundle/Services/Utils.php Dosyayı Görüntüle

@@ -97,16 +97,46 @@ class Utils
return '' ;
}

public function getUnitsListFormatedForType() {
public function getUnitsListFormatedForType()
{
$choices = [] ;
foreach ($this->unitsArray as $unit=>$unitInfo){
$choices[$unitInfo['wording_unit']] = $unit;
};
return $choices;
}
public function getUnitsList() {

public function getUnitsList()
{
return $this->unitsArray;
}

public function getUnitProperty($unit, $property)
{
$unitsArray = $this->getUnitsList() ;

if(isset($unitsArray[$unit][$property])) {
return $unitsArray[$unit][$property] ;
}

return false ;
}

public function getUnitWording($unit, $type = 'wording_short')
{
return $this->getUnitProperty($unit, $type) ;
}

public function getUnitRef($unit)
{
return $this->getUnitProperty($unit, 'ref') ;
}

public function getUnitCoefficient($unit)
{
return $this->getUnitProperty($unit, 'coefficient') ;
}

public function getElementByDevAlias($devAlias, $class = PageInterface::class)
{
$class = $this->em->getClassMetadata($class)->getName();

Yükleniyor…
İptal
Kaydet