->create($this->getMerchantCurrent()); | ->create($this->getMerchantCurrent()); | ||||
} | } | ||||
// public function createIndexQueryBuilder(SearchDto $searchDto, EntityDto $entityDto, FieldCollection $fields, FilterCollection $filters): QueryBuilder | |||||
// { | |||||
// $queryBuilder = parent::createIndexQueryBuilder($searchDto, $entityDto, $fields, $filters); | |||||
// | |||||
// $queryBuilder->leftJoin('entity.productFamilySectionProperties', 'pfsp'); | |||||
// $queryBuilder->andWhereSection('pfsp', $this->getSectionCurrent()); | |||||
// $queryBuilder->addOrderBy('entity.id'); | |||||
// return $queryBuilder; | |||||
// } | |||||
public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | public function configureResponseParameters(KeyValueStore $responseParameters): KeyValueStore | ||||
{ | { |
{ | { | ||||
use ProductPropertyTrait; | use ProductPropertyTrait; | ||||
const BEHAVIOR_COUNT_STOCK_UNLIMITED = 'unlimited'; | |||||
const BEHAVIOR_COUNT_STOCK_BY_MEASURE = 'by-measure'; | const BEHAVIOR_COUNT_STOCK_BY_MEASURE = 'by-measure'; | ||||
const BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY = 'by-product-family'; | const BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY = 'by-product-family'; | ||||
const BEHAVIOR_COUNT_STOCK_BY_PRODUCT = 'by-product'; | const BEHAVIOR_COUNT_STOCK_BY_PRODUCT = 'by-product'; | ||||
public function getBehaviorCountStockChoices(): array | |||||
{ | |||||
return [ | |||||
self::BEHAVIOR_COUNT_STOCK_BY_MEASURE, | |||||
self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT, | |||||
self::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY, | |||||
self::BEHAVIOR_COUNT_STOCK_UNLIMITED, | |||||
]; | |||||
} | |||||
const BEHAVIOR_DISPLAY_SALE_BY_MEASURE = 'by-measure'; | const BEHAVIOR_DISPLAY_SALE_BY_MEASURE = 'by-measure'; | ||||
const BEHAVIOR_DISPLAY_SALE_BY_QUANTITY = 'by-quantity'; | const BEHAVIOR_DISPLAY_SALE_BY_QUANTITY = 'by-quantity'; | ||||
public function getBehaviorDisplaySaleChoices(): array | |||||
{ | |||||
return [ | |||||
self::BEHAVIOR_DISPLAY_SALE_BY_MEASURE, | |||||
self::BEHAVIOR_DISPLAY_SALE_BY_QUANTITY, | |||||
]; | |||||
} | |||||
const BEHAVIOR_STOCK_CYCLE_RENEWABLE = 'renewable'; | |||||
const BEHAVIOR_STOCK_CYCLE_RENEWABLE_VALIDATION = 'renewable-with-validation'; | |||||
const BEHAVIOR_STOCK_CYCLE_NON_RENEWABLE = 'non-renewable'; | |||||
public function getBehaviorStockCycleChoices(): array | |||||
{ | |||||
return [ | |||||
self::BEHAVIOR_STOCK_CYCLE_NON_RENEWABLE, | |||||
self::BEHAVIOR_STOCK_CYCLE_RENEWABLE, | |||||
self::BEHAVIOR_STOCK_CYCLE_RENEWABLE_VALIDATION, | |||||
]; | |||||
} | |||||
const WARNING_MESSAGE_TYPE_SUCCESS = 'success'; | const WARNING_MESSAGE_TYPE_SUCCESS = 'success'; | ||||
const WARNING_MESSAGE_TYPE_ERROR = 'error'; | const WARNING_MESSAGE_TYPE_ERROR = 'error'; | ||||
const WARNING_MESSAGE_TYPE_WARNING = 'warning'; | const WARNING_MESSAGE_TYPE_WARNING = 'warning'; | ||||
const WARNING_MESSAGE_TYPE_INFO = 'info'; | const WARNING_MESSAGE_TYPE_INFO = 'info'; | ||||
public function getWaringMessageTypeChoices(): array | |||||
{ | |||||
return [ | |||||
self::WARNING_MESSAGE_TYPE_ERROR, | |||||
self::WARNING_MESSAGE_TYPE_INFO, | |||||
self::WARNING_MESSAGE_TYPE_SUCCESS, | |||||
self::WARNING_MESSAGE_TYPE_WARNING, | |||||
]; | |||||
} | |||||
const BEHAVIOR_ADD_TO_CART_SIMPLE = 'simple'; | const BEHAVIOR_ADD_TO_CART_SIMPLE = 'simple'; | ||||
const BEHAVIOR_ADD_TO_CART_MULTIPLE = 'multiple'; | const BEHAVIOR_ADD_TO_CART_MULTIPLE = 'multiple'; | ||||
public function getBehaviorAddToCartChoices(): array | |||||
{ | |||||
return [ | |||||
self::BEHAVIOR_ADD_TO_CART_MULTIPLE, | |||||
self::BEHAVIOR_ADD_TO_CART_SIMPLE, | |||||
]; | |||||
} | |||||
const BEHAVIOR_PRICE_BY_PIECE = 'by-piece'; | const BEHAVIOR_PRICE_BY_PIECE = 'by-piece'; | ||||
const BEHAVIOR_PRICE_BY_REFERENCE_UNIT = 'by-reference-unit'; | const BEHAVIOR_PRICE_BY_REFERENCE_UNIT = 'by-reference-unit'; | ||||
public function getBehaviorPriceChoices(): array | |||||
{ | |||||
return [ | |||||
self::BEHAVIOR_PRICE_BY_PIECE, | |||||
self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT, | |||||
]; | |||||
} | |||||
const QUALITY_LABEL_AB = 'ab'; | const QUALITY_LABEL_AB = 'ab'; | ||||
const QUALITY_LABEL_NP = 'nature-progres'; | const QUALITY_LABEL_NP = 'nature-progres'; | ||||
const QUALITY_LABEL_HVE = 'hve'; | const QUALITY_LABEL_HVE = 'hve'; | ||||
self::QUALITY_LABEL_HVE, | self::QUALITY_LABEL_HVE, | ||||
self::QUALITY_LABEL_TVVR | self::QUALITY_LABEL_TVVR | ||||
]; | ]; | ||||
static $geographicLabels = [ | static $geographicLabels = [ | ||||
self::QUALITY_LABEL_AOC, | self::QUALITY_LABEL_AOC, | ||||
self::QUALITY_LABEL_AOP, | self::QUALITY_LABEL_AOP, | ||||
const TYPE_EXPIRATION_DATE_DDM = 'ddm'; | const TYPE_EXPIRATION_DATE_DDM = 'ddm'; | ||||
const TYPE_EXPIRATION_DATE_DLUO = 'dluo'; | const TYPE_EXPIRATION_DATE_DLUO = 'dluo'; | ||||
public function getTypeExpirationDateChoices(): array | |||||
{ | |||||
return [ | |||||
self::TYPE_EXPIRATION_DATE_DLC, | |||||
self::TYPE_EXPIRATION_DATE_DDM, | |||||
self::TYPE_EXPIRATION_DATE_DLUO, | |||||
]; | |||||
} | |||||
const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY = 'by-product-family'; | const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY = 'by-product-family'; | ||||
const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT = 'by-product'; | const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT = 'by-product'; | ||||
public function getBehaviorExpirationDateChoices(): array | |||||
{ | |||||
return [ | |||||
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY, | |||||
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT | |||||
]; | |||||
} | |||||
// @TODO : Champ hydraté par ProductFamilyBuilder ? | // @TODO : Champ hydraté par ProductFamilyBuilder ? | ||||
protected $reductionCatalog; | protected $reductionCatalog; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | ||||
use Lc\CaracoleBundle\Solver\Product\ProductFamilySectionPropertySolver; | |||||
use Lc\CaracoleBundle\Solver\Product\ProductSolver; | use Lc\CaracoleBundle\Solver\Product\ProductSolver; | ||||
class OrderShopSolver | class OrderShopSolver |
namespace Lc\CaracoleBundle\Solver\Product; | namespace Lc\CaracoleBundle\Solver\Product; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||||
class ProductFamilySectionPropertySolver | class ProductFamilySectionPropertySolver | ||||
{ | { | ||||
public function getProductFamilySectionProperty(ProductFamilyInterface $productFamily, SectionInterface $section):? ProductFamilySectionPropertyInterface | |||||
{ | |||||
foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) { | |||||
if ($productFamilySectionProperty->getSection() == $section) { | |||||
return $productFamilySectionProperty; | |||||
} | |||||
} | |||||
return null; | |||||
} | |||||
} | } | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | use Lc\CaracoleBundle\Model\Product\ProductInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | ||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||||
class ProductFamilySolver | class ProductFamilySolver | ||||
{ | { | ||||
$this->productSolver = $productSolver; | $this->productSolver = $productSolver; | ||||
} | } | ||||
public function getBehaviorCountStockChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE, | |||||
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT, | |||||
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY, | |||||
]; | |||||
} | |||||
public function getWaringMessageTypeChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::WARNING_MESSAGE_TYPE_ERROR, | |||||
ProductFamilyModel::WARNING_MESSAGE_TYPE_INFO, | |||||
ProductFamilyModel::WARNING_MESSAGE_TYPE_SUCCESS, | |||||
ProductFamilyModel::WARNING_MESSAGE_TYPE_WARNING, | |||||
]; | |||||
} | |||||
public function getBehaviorAddToCartChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_ADD_TO_CART_MULTIPLE, | |||||
ProductFamilyModel::BEHAVIOR_ADD_TO_CART_SIMPLE, | |||||
]; | |||||
} | |||||
public function getBehaviorPriceChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_PRICE_BY_PIECE, | |||||
ProductFamilyModel::BEHAVIOR_PRICE_BY_REFERENCE_UNIT, | |||||
]; | |||||
} | |||||
public function getTypeExpirationDateChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::TYPE_EXPIRATION_DATE_DLC, | |||||
ProductFamilyModel::TYPE_EXPIRATION_DATE_DDM, | |||||
ProductFamilyModel::TYPE_EXPIRATION_DATE_DLUO, | |||||
]; | |||||
} | |||||
public function getBehaviorExpirationDateChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY, | |||||
ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT, | |||||
]; | |||||
} | |||||
public function getBehaviorDisplaySaleChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE, | |||||
ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_QUANTITY, | |||||
]; | |||||
} | |||||
public function countProductFamiliesOrganizedByParentCategory(array $categories): int | public function countProductFamiliesOrganizedByParentCategory(array $categories): int | ||||
{ | { | ||||
$count = 0; | $count = 0; | ||||
return $productFamily->getBehaviorPrice(); | return $productFamily->getBehaviorPrice(); | ||||
} | } | ||||
public function getBehaviorCountStockChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE, | |||||
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT, | |||||
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY, | |||||
ProductFamilyModel::BEHAVIOR_COUNT_STOCK_UNLIMITED, | |||||
]; | |||||
} | |||||
public function getBehaviorDisplaySaleChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_MEASURE, | |||||
ProductFamilyModel::BEHAVIOR_DISPLAY_SALE_BY_QUANTITY, | |||||
]; | |||||
} | |||||
public function getBehaviorStockCycleChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_STOCK_CYCLE_NON_RENEWABLE, | |||||
ProductFamilyModel::BEHAVIOR_STOCK_CYCLE_RENEWABLE, | |||||
ProductFamilyModel::BEHAVIOR_STOCK_CYCLE_RENEWABLE_VALIDATION, | |||||
]; | |||||
} | |||||
public function getWaringMessageTypeChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::WARNING_MESSAGE_TYPE_ERROR, | |||||
ProductFamilyModel::WARNING_MESSAGE_TYPE_INFO, | |||||
ProductFamilyModel::WARNING_MESSAGE_TYPE_SUCCESS, | |||||
ProductFamilyModel::WARNING_MESSAGE_TYPE_WARNING, | |||||
]; | |||||
} | |||||
public function getBehaviorAddToCartChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_ADD_TO_CART_MULTIPLE, | |||||
ProductFamilyModel::BEHAVIOR_ADD_TO_CART_SIMPLE, | |||||
]; | |||||
} | |||||
public function getBehaviorPriceChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_PRICE_BY_PIECE, | |||||
ProductFamilyModel::BEHAVIOR_PRICE_BY_REFERENCE_UNIT, | |||||
]; | |||||
} | |||||
public function getTypeExpirationDateChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::TYPE_EXPIRATION_DATE_DLC, | |||||
ProductFamilyModel::TYPE_EXPIRATION_DATE_DDM, | |||||
ProductFamilyModel::TYPE_EXPIRATION_DATE_DLUO, | |||||
]; | |||||
} | |||||
public function getBehaviorExpirationDateChoices(): array | |||||
{ | |||||
return [ | |||||
ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY, | |||||
ProductFamilyModel::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT, | |||||
]; | |||||
} | |||||
public function getBuyingPriceByRefUnitInherited(ProductFamilyInterface $productFamily): ?float | public function getBuyingPriceByRefUnitInherited(ProductFamilyInterface $productFamily): ?float | ||||
{ | { | ||||
return $productFamily->getBuyingPriceByRefUnit(); | return $productFamily->getBuyingPriceByRefUnit(); |
return $product->getProductFamily()->getAvailableQuantity(); | return $product->getProductFamily()->getAvailableQuantity(); | ||||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : | case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : | ||||
return $product->getAvailableQuantity(); | return $product->getAvailableQuantity(); | ||||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_UNLIMITED : | |||||
return false; | |||||
} | } | ||||
} | } | ||||
public function getAvailableQuantitySupplierInherited(ProductInterface $product) | |||||
{ | |||||
switch ($product->getProductFamily()->getBehaviorCountStock()) { | |||||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : | |||||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE : | |||||
return $product->getProductFamily()->getAvailableQuantitySupplier(); | |||||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : | |||||
return $product->getAvailableQuantitySupplier(); | |||||
} | |||||
} | |||||
/*public function getTaxRateInherited(ProductInterface $product) | /*public function getTaxRateInherited(ProductInterface $product) | ||||
{ | { | ||||
return $product->getProductFamily()->getTaxRateInherited(); | return $product->getProductFamily()->getTaxRateInherited(); |