Sfoglia il codice sorgente

Gestion des stocks avancé

packProduct
Fabien Normand 3 anni fa
parent
commit
49ca766606
6 ha cambiato i file con 101 aggiunte e 194 eliminazioni
  1. +0
    -25
      Controller/Product/ProductFamilyAdminController.php
  2. +0
    -85
      Model/Product/ProductFamilyModel.php
  3. +1
    -0
      Solver/Order/OrderShopSolver.php
  4. +13
    -0
      Solver/Product/ProductFamilySectionPropertySolver.php
  5. +75
    -82
      Solver/Product/ProductFamilySolver.php
  6. +12
    -2
      Solver/Product/ProductSolver.php

+ 0
- 25
Controller/Product/ProductFamilyAdminController.php Vedi File

@@ -2,29 +2,14 @@

namespace Lc\CaracoleBundle\Controller\Product;

use Doctrine\ORM\QueryBuilder;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FieldCollection;
use EasyCorp\Bundle\EasyAdminBundle\Collection\FilterCollection;
use EasyCorp\Bundle\EasyAdminBundle\Config\KeyValueStore;
use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext;
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto;
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto;
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Container\Order\OrderShopContainer;
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer;
use Lc\CaracoleBundle\Controller\AdminControllerTrait;
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface;
use Lc\CaracoleBundle\Field\Address\AddressField;
use Lc\CaracoleBundle\Resolver\SectionResolver;
use Lc\SovBundle\Controller\AbstractAdminController;
use Lc\SovBundle\Field\BooleanField;
use Lc\SovBundle\Field\CKEditorField;
use Lc\SovBundle\Field\StatusField;
use Lc\SovBundle\Repository\RepositoryQueryInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;

abstract class ProductFamilyAdminController extends AbstractAdminController
@@ -37,16 +22,6 @@ abstract class ProductFamilyAdminController extends AbstractAdminController
return $this->get(ProductFamilyContainer::class)->getRepositoryQuery();
}

// 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
{
$responseParameters = parent::configureResponseParameters($responseParameters);

+ 0
- 85
Model/Product/ProductFamilyModel.php Vedi File

@@ -24,121 +24,36 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP
{
use ProductPropertyTrait;

const BEHAVIOR_COUNT_STOCK_UNLIMITED = 'unlimited';
const BEHAVIOR_COUNT_STOCK_BY_MEASURE = 'by-measure';
const BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY = 'by-product-family';
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_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_ERROR = 'error';
const WARNING_MESSAGE_TYPE_WARNING = 'warning';
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_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_REFERENCE_UNIT = 'by-reference-unit';

public function getBehaviorPriceChoices(): array
{
return [
self::BEHAVIOR_PRICE_BY_PIECE,
self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT,
];
}

const PROPERTY_ORGANIC_LABEL_AB = 'ab';
const PROPERTY_ORGANIC_LABEL_NP = 'nature-progres';
const PROPERTY_ORGANIC_LABEL_HVE = 'hve';
const PROPERTY_ORGANIC_LABEL_TVVR = 'tvvr';

public function getPropertyOrganicLabelChoices(): array
{
return [
self::PROPERTY_ORGANIC_LABEL_AB,
self::PROPERTY_ORGANIC_LABEL_NP,
self::PROPERTY_ORGANIC_LABEL_HVE,
self::PROPERTY_ORGANIC_LABEL_TVVR,
];
}

const TYPE_EXPIRATION_DATE_DLC = 'dlc';
const TYPE_EXPIRATION_DATE_DDM = 'ddm';
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 = '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 ?
protected $reductionCatalog;


+ 1
- 0
Solver/Order/OrderShopSolver.php Vedi File

@@ -17,6 +17,7 @@ use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Solver\Product\ProductFamilySectionPropertySolver;
use Lc\CaracoleBundle\Solver\Product\ProductSolver;

class OrderShopSolver

+ 13
- 0
Solver/Product/ProductFamilySectionPropertySolver.php Vedi File

@@ -2,9 +2,22 @@

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
{

public function getProductFamilySectionProperty(ProductFamilyInterface $productFamily, SectionInterface $section):? ProductFamilySectionPropertyInterface
{
foreach ($productFamily->getProductFamilySectionProperties() as $productFamilySectionProperty) {
if ($productFamilySectionProperty->getSection() == $section) {
return $productFamilySectionProperty;
}
}
return null;
}
}



+ 75
- 82
Solver/Product/ProductFamilySolver.php Vedi File

@@ -21,6 +21,81 @@ class ProductFamilySolver
$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 getPropertyOrganicLabelChoices(): array
{
return [
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_AB,
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_NP,
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_HVE,
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_TVVR,
];
}

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
{
$count = 0;
@@ -262,88 +337,6 @@ class ProductFamilySolver
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 getPropertyOrganicLabelChoices(): array
{
return [
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_AB,
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_NP,
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_HVE,
ProductFamilyModel::PROPERTY_ORGANIC_LABEL_TVVR,
];
}

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
{
return $productFamily->getBuyingPriceByRefUnit();

+ 12
- 2
Solver/Product/ProductSolver.php Vedi File

@@ -150,11 +150,21 @@ class ProductSolver
return $product->getProductFamily()->getAvailableQuantity();
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT :
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)
{
return $product->getProductFamily()->getTaxRateInherited();

Loading…
Annulla
Salva