Parcourir la source

Suppresion des section dans distribution

packProduct
Fab il y a 3 ans
Parent
révision
d73ca6ac4c
9 fichiers modifiés avec 35 ajouts et 45 suppressions
  1. +1
    -2
      Factory/Distribution/DistributionFactory.php
  2. +3
    -3
      Factory/File/DocumentFactory.php
  3. +2
    -1
      Field/Filter/ProductCategoriesFilter.php
  4. +0
    -18
      Model/Distribution/DistributionModel.php
  5. +7
    -9
      Model/File/DocumentModel.php
  6. +2
    -7
      Repository/Distribution/DistributionStore.php
  7. +3
    -2
      Repository/Order/OrderShopRepositoryQuery.php
  8. +6
    -3
      Repository/Order/OrderShopStore.php
  9. +11
    -0
      Solver/Product/ProductSolver.php

+ 1
- 2
Factory/Distribution/DistributionFactory.php Voir le fichier

@@ -9,11 +9,10 @@ use Lc\SovBundle\Factory\AbstractFactory;
class DistributionFactory extends AbstractFactory
{

public function create(int $cycleNumber, int $year, string $cycleType, SectionInterface $section):Distribution
public function create(int $cycleNumber, int $year, string $cycleType):Distribution
{
$distribution = new Distribution();

$distribution->setSection($section);
$distribution->setCycleNumber($cycleNumber);
$distribution->setCycleType($cycleType);
$distribution->setYear($year);

+ 3
- 3
Factory/File/DocumentFactory.php Voir le fichier

@@ -14,11 +14,11 @@ use Lc\SovBundle\Model\User\UserInterface;
class DocumentFactory extends AbstractFactory
{

public function create(SectionInterface $section, string $type): DocumentInterface
public function create(MerchantInterface $merchant, string $type): DocumentInterface
{
$document = new Document();

$document->setSection($section);
$document->setMerchant($merchant);
$document->setType($type);
$document->setTitle('');
$document->setStatus(1);
@@ -26,4 +26,4 @@ class DocumentFactory extends AbstractFactory
return $document;
}

}
}

+ 2
- 1
Field/Filter/ProductCategoriesFilter.php Voir le fichier

@@ -39,8 +39,9 @@ class ProductCategoriesFilter extends AssociationFilter
}


public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, string $fieldProperty, $filteredValue = null)
public function applyFilter(RepositoryQueryInterface $repositoryQuery, FieldDto $fieldDto, $filteredValue = null)
{
$fieldProperty = $this->getFieldProperty($fieldDto);
if ($filteredValue !== null) {
$repositoryQuery->filterByProductCategory($filteredValue);


+ 0
- 18
Model/Distribution/DistributionModel.php Voir le fichier

@@ -19,12 +19,6 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
*/
abstract class DistributionModel implements DistributionInterface, EntityInterface
{
/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;

/**
* @ORM\Column(type="integer")
*/
@@ -45,18 +39,6 @@ abstract class DistributionModel implements DistributionInterface, EntityInterfa
return $this->getCycleNumber().'/'.$this->getYear();
}

public function getSection(): ?SectionInterface
{
return $this->section;
}

public function setSection(?SectionInterface $section): self
{
$this->section = $section;

return $this;
}

public function getCycleNumber(): ?int
{
return $this->cycleNumber;

+ 7
- 9
Model/File/DocumentModel.php Voir le fichier

@@ -19,20 +19,18 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity;
/**
* @ORM\MappedSuperclass()
*/
abstract class DocumentModel extends AbstractFullEntity implements FilterSectionInterface
abstract class DocumentModel extends AbstractFullEntity implements FilterMerchantInterface
{


const TYPE_INVOICE = 'invoice';
const TYPE_QUOTATION = 'quotation';
const TYPE_PURCHASE_ORDER = 'purchase-order';
const TYPE_DELIVERY_NOTE = 'delivery-note';

/**
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface")
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface")
* @ORM\JoinColumn(nullable=false)
*/
protected $section;
protected $merchant;

/**
* @ORM\Column(type="string", length=64)
@@ -102,14 +100,14 @@ abstract class DocumentModel extends AbstractFullEntity implements FilterSection
return $this->getReference();
}

public function getSection(): ?SectionInterface
public function getMerchant(): ?MerchantInterface
{
return $this->section;
return $this->merchant;
}

public function setSection(?SectionInterface $section): self
public function setMerchant(?MerchantInterface $merchant): self
{
$this->section = $section;
$this->merchant = $merchant;

return $this;
}

+ 2
- 7
Repository/Distribution/DistributionStore.php Voir le fichier

@@ -10,8 +10,6 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface;

class DistributionStore extends AbstractStore
{
use SectionStoreTrait;

protected DistributionRepositoryQuery $query;

public function __construct(DistributionRepositoryQuery $query)
@@ -27,7 +25,6 @@ class DistributionStore extends AbstractStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
return $query;
}

@@ -36,17 +33,15 @@ class DistributionStore extends AbstractStore
return $query;
}

public function getOneByCycleNumberYearAndSection(
public function getOneByCycleNumberYearAndCycleType(
int $cycleNumber,
int $year,
string $cycleType,
SectionInterface $section
string $cycleType
): ?Distribution {
$query = $this->createQuery();
$query->filterByCycleNumber($cycleNumber);
$query->filterByYear($year);
$query->filterByCycleType($cycleType);
$query->filterBySection($section);

return $query->findOne();
}

+ 3
- 2
Repository/Order/OrderShopRepositoryQuery.php Voir le fichier

@@ -5,6 +5,7 @@ namespace Lc\CaracoleBundle\Repository\Order;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Distribution\DistributionInterface;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\User\VisitorInterface;
@@ -115,13 +116,13 @@ class OrderShopRepositoryQuery extends AbstractRepositoryQuery
->setParameter('products', $products);
}

public function filterByProduct(int $productId): self
public function filterByProduct(ProductInterface $product): self
{
$this->joinProduct();

return $this
->andWhere('orderProduct.product = :product')
->setParameter('product', $productId);
->setParameter('product', $product);
}

public function filterIsMerchantOnline(): self

+ 6
- 3
Repository/Order/OrderShopStore.php Voir le fichier

@@ -9,6 +9,7 @@ use Lc\CaracoleBundle\Builder\File\DocumentBuilder;
use Lc\CaracoleBundle\Model\Distribution\DistributionInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusModel;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
@@ -566,15 +567,17 @@ class OrderShopStore extends AbstractStore
}

//countValidOrderProductsOfCycleByProduct
public function countValidOrderProductsOfDistributionByProduct(DistributionInterface $distribution, int $productId, $query = null): ?string
public function countValidOrderProductsOfDistributionByProduct(DistributionInterface $distribution, ProductInterface $product, $query = null): ?string
{
$query = $this->createDefaultQuery($query);
//TODO attention à vérifier
$query = $this->createQuery($query);

$query
->filterByAlias(OrderStatusModel::$statusAliasAsValid)
->filterByDistribution($distribution)
->filterByProduct($productId)
->filterByProduct($product)
->selectSumQuantityOrder()
->joinDistribution()
->groupBy('distribution.cycleNumber, product.id');

$result = $query->findOne();

+ 11
- 0
Solver/Product/ProductSolver.php Voir le fichier

@@ -153,6 +153,17 @@ class ProductSolver
}
}

public function getAvailableQuantityDefaultInherited(ProductInterface $product)
{
switch ($product->getProductFamily()->getBehaviorCountStock()) {
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY :
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE :
return $product->getProductFamily()->getAvailableQuantityDefault();
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT :
return $product->getAvailableQuantityDefault();
}
}

public function getAvailableQuantitySupplierInherited(ProductInterface $product)
{
switch ($product->getProductFamily()->getBehaviorCountStock()) {

Chargement…
Annuler
Enregistrer