Browse Source

ManyToMany on ProductFamily/Section + gestion stock + adaptation import

packProduct
Fabien Normand 3 years ago
parent
commit
55ff4aed0c
12 changed files with 41 additions and 35 deletions
  1. +0
    -1
      Controller/Section/SectionAdminController.php
  2. +2
    -1
      Factory/Distribution/DistributionFactory.php
  3. +5
    -4
      Field/AssociationField.php
  4. +18
    -0
      Model/Distribution/DistributionModel.php
  5. +0
    -17
      Model/Section/SectionModel.php
  6. +6
    -0
      Repository/Distribution/DistributionRepositoryQuery.php
  7. +2
    -0
      Repository/Distribution/DistributionStore.php
  8. +2
    -1
      Repository/Product/ProductFamilyRepositoryQuery.php
  9. +1
    -4
      Repository/Section/SectionRepositoryQuery.php
  10. +0
    -6
      Repository/Section/SectionStore.php
  11. +5
    -0
      Resolver/SectionResolver.php
  12. +0
    -1
      Resources/translations/admin.fr.yaml

+ 0
- 1
Controller/Section/SectionAdminController.php View File

@@ -49,7 +49,6 @@ abstract class SectionAdminController extends AbstractAdminController
CKEditorField::new('description')
->hideOnIndex(),
BooleanField::new('isDefault'),
BooleanField::new('isCommon'),
StatusField::new('status'),
],
$this->getSeoPanel(),

+ 2
- 1
Factory/Distribution/DistributionFactory.php View File

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

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

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

return $distribution;

+ 5
- 4
Field/AssociationField.php View File

@@ -92,11 +92,12 @@ final class AssociationField implements FieldInterface
return $this;
}

public function addAndWhere($whereClause, $parameter): self
public function addAndWhere($whereClause, $key, $value): self
{
$this->queryBuilderParameters['leftJoin'][] = [
$this->queryBuilderParameters['andWhere'][] = [
'whereClause' => $whereClause,
'parameter' => $parameter
'key' => $key,
'value' => $value
];

return $this;
@@ -147,7 +148,7 @@ final class AssociationField implements FieldInterface

if (isset($param['andWhere'])) {
foreach ($param['andWhere'] as $i => $whereClause) {
$qb->andWhere($whereClause['whereClause'])->setParamater($whereClause['parameter']);
$qb->andWhere($whereClause['whereClause'])->setParameter($whereClause['key'], $whereClause['value']);
}
}


+ 18
- 0
Model/Distribution/DistributionModel.php View File

@@ -35,6 +35,11 @@ abstract class DistributionModel implements DistributionInterface, EntityInterfa
*/
protected $year;

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

public function getSection(): ?SectionInterface
{
return $this->section;
@@ -70,4 +75,17 @@ abstract class DistributionModel implements DistributionInterface, EntityInterfa

return $this;
}


public function getCycleType(): ?string
{
return $this->cycleType;
}

public function setCycleType(string $cycleType): self
{
$this->cycleType = $cycleType;

return $this;
}
}

+ 0
- 17
Model/Section/SectionModel.php View File

@@ -90,11 +90,6 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant
*/
protected $openings;

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

/**
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilySectionPropertyInterface", mappedBy="section")
*/
@@ -409,18 +404,6 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant
return $this;
}

public function getIsCommon(): ?bool
{
return $this->isCommon;
}

public function setIsCommon(?bool $isCommon): self
{
$this->isCommon = $isCommon;

return $this;
}

/**
* @return Collection|ProductFamilySectionPropertyInterface[]
*/

+ 6
- 0
Repository/Distribution/DistributionRepositoryQuery.php View File

@@ -28,4 +28,10 @@ class DistributionRepositoryQuery extends AbstractRepositoryQuery
->andWhere('.cycleNumber = :cycleNumber')
->setParameter('cycleNumber', $cycleNumber);
}
public function filterByCycleType(string $cycleType): self
{
return $this
->andWhere('.cycleType = :cycleType')
->setParameter('cycleType', $cycleType);
}
}

+ 2
- 0
Repository/Distribution/DistributionStore.php View File

@@ -39,11 +39,13 @@ class DistributionStore extends AbstractStore
public function getOneByCycleNumberYearAndSection(
int $cycleNumber,
int $year,
string $cycleType,
SectionInterface $section
): ?Distribution {
$query = $this->createQuery();
$query->filterByCycleNumber($cycleNumber);
$query->filterByYear($year);
$query->filterByCycleType($cycleType);
$query->filterBySection($section);

return $query->findOne();

+ 2
- 1
Repository/Product/ProductFamilyRepositoryQuery.php View File

@@ -38,7 +38,8 @@ class ProductFamilyRepositoryQuery extends AbstractRepositoryQuery
public function filterBySection(SectionInterface $section)
{
$this->joinProductFamilySectionProperties();
return $this->andWhereSection('pfsp', $section);
$this->andWhereSection('pfsp', $section);
$this->andWhere('pfsp.status = 1');
}



+ 1
- 4
Repository/Section/SectionRepositoryQuery.php View File

@@ -20,9 +20,6 @@ class SectionRepositoryQuery extends AbstractRepositoryQuery
return $this->andWhereEqual('isDefault', $isDefault);
}

public function filterByIsCommon(bool $isCommon)
{
return $this->andWhereEqual('isCommon', $isCommon);
}


}

+ 0
- 6
Repository/Section/SectionStore.php View File

@@ -76,11 +76,5 @@ class SectionStore extends AbstractStore
// @TODO : à implémenter avec le nouveau système d'ouverture des commandes
}

public function getOnlineWithoutCommon($query = null)
{
$query = $this->createDefaultQuery($query);
$query->filterByIsCommon(false);
return $query->find();
}

}

+ 5
- 0
Resolver/SectionResolver.php View File

@@ -76,5 +76,10 @@ class SectionResolver
}
}

public function getDefault():SectionInterface
{
return $this->sectionStore->setMerchant($this->merchantResolver->getCurrent())->getOneDefault();
}


}

+ 0
- 1
Resources/translations/admin.fr.yaml View File

@@ -105,7 +105,6 @@ entity:
fields:
cycle: Cycle de vente
isDefault: Section par défaut
isCommon: Section commune
TaxRate:
label: Règle de taxe
label_plurial: Règles de taxes

Loading…
Cancel
Save