<?php | |||||
namespace Lc\CaracoleBundle\Builder\Product; | |||||
class ProductFamilyBuilder | |||||
{ | |||||
} |
use Lc\CaracoleBundle\Factory\PointSale\PointSaleFactory; | use Lc\CaracoleBundle\Factory\PointSale\PointSaleFactory; | ||||
use Lc\CaracoleBundle\Repository\PointSale\PointSaleRepositoryQuery; | use Lc\CaracoleBundle\Repository\PointSale\PointSaleRepositoryQuery; | ||||
use Lc\CaracoleBundle\Repository\PointSale\PointSaleStore; | use Lc\CaracoleBundle\Repository\PointSale\PointSaleStore; | ||||
use Lc\CaracoleBundle\Solver\PointSale\PointSaleSolver; | |||||
class PointSaleContainer | class PointSaleContainer | ||||
{ | { | ||||
protected PointSaleFactory $factory; | protected PointSaleFactory $factory; | ||||
protected PointSaleSolver $solver; | |||||
protected PointSaleRepositoryQuery $repositoryQuery; | protected PointSaleRepositoryQuery $repositoryQuery; | ||||
protected PointSaleStore $store; | protected PointSaleStore $store; | ||||
public function __construct( | public function __construct( | ||||
PointSaleFactory $factory, | PointSaleFactory $factory, | ||||
PointSaleSolver $solver, | |||||
PointSaleRepositoryQuery $repositoryQuery, | PointSaleRepositoryQuery $repositoryQuery, | ||||
PointSaleStore $store | PointSaleStore $store | ||||
) { | ) { | ||||
$this->factory = $factory; | $this->factory = $factory; | ||||
$this->solver = $solver; | |||||
$this->repositoryQuery = $repositoryQuery; | $this->repositoryQuery = $repositoryQuery; | ||||
$this->store = $store; | $this->store = $store; | ||||
} | } | ||||
return $this->factory; | return $this->factory; | ||||
} | } | ||||
public function getSolver(): PointSaleSolver | |||||
{ | |||||
return $this->solver; | |||||
} | |||||
public function getRepositoryQuery(): PointSaleRepositoryQuery | public function getRepositoryQuery(): PointSaleRepositoryQuery | ||||
{ | { | ||||
return $this->repositoryQuery; | return $this->repositoryQuery; | ||||
{ | { | ||||
return $this->store; | return $this->store; | ||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Container\Product; | namespace Lc\CaracoleBundle\Container\Product; | ||||
use Lc\CaracoleBundle\Builder\Product\ProductFamilyBuilder; | |||||
use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory; | use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory; | ||||
use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery; | use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery; | ||||
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; | use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; | ||||
protected ProductFamilySolver $solver; | protected ProductFamilySolver $solver; | ||||
protected ProductFamilyRepositoryQuery $repositoryQuery; | protected ProductFamilyRepositoryQuery $repositoryQuery; | ||||
protected ProductFamilyStore $store; | protected ProductFamilyStore $store; | ||||
protected ProductFamilyBuilder $builder; | |||||
protected ProductFamilyResolver $resolver; | protected ProductFamilyResolver $resolver; | ||||
public function __construct( | public function __construct( | ||||
ProductFamilySolver $solver, | ProductFamilySolver $solver, | ||||
ProductFamilyRepositoryQuery $repositoryQuery, | ProductFamilyRepositoryQuery $repositoryQuery, | ||||
ProductFamilyStore $store, | ProductFamilyStore $store, | ||||
ProductFamilyBuilder $builder, | |||||
ProductFamilyResolver $resolver | ProductFamilyResolver $resolver | ||||
) { | ) { | ||||
$this->factory = $factory; | $this->factory = $factory; | ||||
$this->solver = $solver; | $this->solver = $solver; | ||||
$this->repositoryQuery = $repositoryQuery; | $this->repositoryQuery = $repositoryQuery; | ||||
$this->store = $store; | $this->store = $store; | ||||
$this->builder = $builder; | |||||
$this->resolver = $resolver; | $this->resolver = $resolver; | ||||
} | } | ||||
return $this->resolver; | return $this->resolver; | ||||
} | } | ||||
} | |||||
public function getBuilder(): ProductFamilyBuilder | |||||
{ | |||||
return $this->builder; | |||||
} | |||||
} |
$solver = $this->getSolver($product); | $solver = $this->getSolver($product); | ||||
if ($solver->getBehaviorPriceInherited($product) == 'by-piece') { | if ($solver->getBehaviorPriceInherited($product) == 'by-piece') { | ||||
dump($product); | |||||
return $solver->getBuyingPriceInherited($product); | return $solver->getBuyingPriceInherited($product); | ||||
} elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') { | } elseif ($solver->getBehaviorPriceInherited($product) == 'by-reference-unit') { | ||||
if ($solver->getQuantityInherited($product) > 0) { | if ($solver->getQuantityInherited($product) > 0) { |
return $productFamily->getBuyingPriceByRefUnit(); | return $productFamily->getBuyingPriceByRefUnit(); | ||||
} | } | ||||
public function getBuyingPriceInherited(ProductFamilyInterface $productFamily): ?float | |||||
{ | |||||
return $productFamily->getBuyingPrice(); | |||||
} | |||||
public function getPriceByRefUnitInherited(ProductFamilyInterface $productFamily): ?float | public function getPriceByRefUnitInherited(ProductFamilyInterface $productFamily): ?float | ||||
{ | { | ||||
return $productFamily->getPriceByRefUnit(); | return $productFamily->getPriceByRefUnit(); |