class DistributionFactory extends 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 = new Distribution(); | ||||
$distribution->setSection($section); | |||||
$distribution->setCycleNumber($cycleNumber); | $distribution->setCycleNumber($cycleNumber); | ||||
$distribution->setCycleType($cycleType); | $distribution->setCycleType($cycleType); | ||||
$distribution->setYear($year); | $distribution->setYear($year); |
class DocumentFactory extends AbstractFactory | class DocumentFactory extends AbstractFactory | ||||
{ | { | ||||
public function create(SectionInterface $section, string $type): DocumentInterface | |||||
public function create(MerchantInterface $merchant, string $type): DocumentInterface | |||||
{ | { | ||||
$document = new Document(); | $document = new Document(); | ||||
$document->setSection($section); | |||||
$document->setMerchant($merchant); | |||||
$document->setType($type); | $document->setType($type); | ||||
$document->setTitle(''); | $document->setTitle(''); | ||||
$document->setStatus(1); | $document->setStatus(1); | ||||
return $document; | return $document; | ||||
} | } | ||||
} | |||||
} |
} | } | ||||
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) { | if ($filteredValue !== null) { | ||||
$repositoryQuery->filterByProductCategory($filteredValue); | $repositoryQuery->filterByProductCategory($filteredValue); | ||||
*/ | */ | ||||
abstract class DistributionModel implements DistributionInterface, EntityInterface | abstract class DistributionModel implements DistributionInterface, EntityInterface | ||||
{ | { | ||||
/** | |||||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||||
* @ORM\JoinColumn(nullable=false) | |||||
*/ | |||||
protected $section; | |||||
/** | /** | ||||
* @ORM\Column(type="integer") | * @ORM\Column(type="integer") | ||||
*/ | */ | ||||
return $this->getCycleNumber().'/'.$this->getYear(); | 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 | public function getCycleNumber(): ?int | ||||
{ | { | ||||
return $this->cycleNumber; | return $this->cycleNumber; |
/** | /** | ||||
* @ORM\MappedSuperclass() | * @ORM\MappedSuperclass() | ||||
*/ | */ | ||||
abstract class DocumentModel extends AbstractFullEntity implements FilterSectionInterface | |||||
abstract class DocumentModel extends AbstractFullEntity implements FilterMerchantInterface | |||||
{ | { | ||||
const TYPE_INVOICE = 'invoice'; | const TYPE_INVOICE = 'invoice'; | ||||
const TYPE_QUOTATION = 'quotation'; | const TYPE_QUOTATION = 'quotation'; | ||||
const TYPE_PURCHASE_ORDER = 'purchase-order'; | const TYPE_PURCHASE_ORDER = 'purchase-order'; | ||||
const TYPE_DELIVERY_NOTE = 'delivery-note'; | 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) | * @ORM\JoinColumn(nullable=false) | ||||
*/ | */ | ||||
protected $section; | |||||
protected $merchant; | |||||
/** | /** | ||||
* @ORM\Column(type="string", length=64) | * @ORM\Column(type="string", length=64) | ||||
return $this->getReference(); | 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; | return $this; | ||||
} | } |
class DistributionStore extends AbstractStore | class DistributionStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | |||||
protected DistributionRepositoryQuery $query; | protected DistributionRepositoryQuery $query; | ||||
public function __construct(DistributionRepositoryQuery $query) | public function __construct(DistributionRepositoryQuery $query) | ||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->filterBySection($this->section); | |||||
return $query; | return $query; | ||||
} | } | ||||
return $query; | return $query; | ||||
} | } | ||||
public function getOneByCycleNumberYearAndSection( | |||||
public function getOneByCycleNumberYearAndCycleType( | |||||
int $cycleNumber, | int $cycleNumber, | ||||
int $year, | int $year, | ||||
string $cycleType, | |||||
SectionInterface $section | |||||
string $cycleType | |||||
): ?Distribution { | ): ?Distribution { | ||||
$query = $this->createQuery(); | $query = $this->createQuery(); | ||||
$query->filterByCycleNumber($cycleNumber); | $query->filterByCycleNumber($cycleNumber); | ||||
$query->filterByYear($year); | $query->filterByYear($year); | ||||
$query->filterByCycleType($cycleType); | $query->filterByCycleType($cycleType); | ||||
$query->filterBySection($section); | |||||
return $query->findOne(); | return $query->findOne(); | ||||
} | } |
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | use Lc\CaracoleBundle\Model\Address\AddressInterface; | ||||
use Lc\CaracoleBundle\Model\Distribution\DistributionInterface; | use Lc\CaracoleBundle\Model\Distribution\DistributionInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | ||||
use Lc\CaracoleBundle\Model\User\VisitorInterface; | use Lc\CaracoleBundle\Model\User\VisitorInterface; | ||||
->setParameter('products', $products); | ->setParameter('products', $products); | ||||
} | } | ||||
public function filterByProduct(int $productId): self | |||||
public function filterByProduct(ProductInterface $product): self | |||||
{ | { | ||||
$this->joinProduct(); | $this->joinProduct(); | ||||
return $this | return $this | ||||
->andWhere('orderProduct.product = :product') | ->andWhere('orderProduct.product = :product') | ||||
->setParameter('product', $productId); | |||||
->setParameter('product', $product); | |||||
} | } | ||||
public function filterIsMerchantOnline(): self | public function filterIsMerchantOnline(): self |
use Lc\CaracoleBundle\Model\Distribution\DistributionInterface; | use Lc\CaracoleBundle\Model\Distribution\DistributionInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | ||||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | ||||
} | } | ||||
//countValidOrderProductsOfCycleByProduct | //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 | $query | ||||
->filterByAlias(OrderStatusModel::$statusAliasAsValid) | ->filterByAlias(OrderStatusModel::$statusAliasAsValid) | ||||
->filterByDistribution($distribution) | ->filterByDistribution($distribution) | ||||
->filterByProduct($productId) | |||||
->filterByProduct($product) | |||||
->selectSumQuantityOrder() | ->selectSumQuantityOrder() | ||||
->joinDistribution() | |||||
->groupBy('distribution.cycleNumber, product.id'); | ->groupBy('distribution.cycleNumber, product.id'); | ||||
$result = $query->findOne(); | $result = $query->findOne(); |
} | } | ||||
} | } | ||||
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) | public function getAvailableQuantitySupplierInherited(ProductInterface $product) | ||||
{ | { | ||||
switch ($product->getProductFamily()->getBehaviorCountStock()) { | switch ($product->getProductFamily()->getBehaviorCountStock()) { |