use Lc\CaracoleBundle\Model\File\DocumentInterface; | use Lc\CaracoleBundle\Model\File\DocumentInterface; | ||||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Generator\DocumentReferenceGenerator; | use Lc\CaracoleBundle\Generator\DocumentReferenceGenerator; | ||||
use Lc\CaracoleBundle\Solver\Address\AddressSolver; | |||||
class DocumentBuilder | class DocumentBuilder | ||||
{ | { | ||||
protected DocumentReferenceGenerator $documentReferenceGenerator; | protected DocumentReferenceGenerator $documentReferenceGenerator; | ||||
protected AddressSolver $addressSolver; | |||||
public function __construct(DocumentReferenceGenerator $documentReferenceGenerator) | |||||
public function __construct(DocumentReferenceGenerator $documentReferenceGenerator, AddressSolver $addressSolver) | |||||
{ | { | ||||
$this->documentReferenceGenerator = $documentReferenceGenerator; | $this->documentReferenceGenerator = $documentReferenceGenerator; | ||||
$this->addressSolver = $addressSolver; | |||||
} | } | ||||
public function initFromOrderShop(DocumentInterface $document, OrderShopInterface $orderShop) :DocumentInterface | public function initFromOrderShop(DocumentInterface $document, OrderShopInterface $orderShop) :DocumentInterface | ||||
{ | { | ||||
$merchantAddress = $orderShop->getMerchant()->getAddress(); | |||||
$merchantAddress = $orderShop->getSection()->getMerchant()->getAddress(); | |||||
$buyerAddress = $orderShop->getInvoiceAddress(); | $buyerAddress = $orderShop->getInvoiceAddress(); | ||||
$document->setReference($this->documentReferenceGenerator->buildReference($orderShop->getMerchant())) ; | |||||
$document->setReference($this->documentReferenceGenerator->buildReference($orderShop->getSection()->getMerchant(), $document->getType())) ; | |||||
$document->setMerchantAddress($merchantAddress); | $document->setMerchantAddress($merchantAddress); | ||||
$document->setBuyerAddress($buyerAddress); | $document->setBuyerAddress($buyerAddress); | ||||
$document->setMerchantAddressText($merchantAddress->getSummary()); | |||||
$document->setBuyerAddressText($buyerAddress->getSummary()); | |||||
$document->setMerchantAddressText($this->addressSolver->getSummary($merchantAddress)); | |||||
$document->setBuyerAddressText($this->addressSolver->getSummary($buyerAddress)); | |||||
$document->addOrderShop($orderShop); | $document->addOrderShop($orderShop); | ||||
$document->setCreatedBy($orderShop->getUser()); | $document->setCreatedBy($orderShop->getUser()); | ||||
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; | use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; | ||||
use Lc\CaracoleBundle\Resolver\OpeningResolver; | use Lc\CaracoleBundle\Resolver\OpeningResolver; | ||||
use Lc\CaracoleBundle\Resolver\OrderShopResolver; | use Lc\CaracoleBundle\Resolver\OrderShopResolver; | ||||
use Lc\CaracoleBundle\Solver\Order\OrderProductReductionCatalogSolver; | |||||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | ||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
use Lc\CaracoleBundle\Solver\Product\ProductSolver; | use Lc\CaracoleBundle\Solver\Product\ProductSolver; | ||||
protected OpeningResolver $openingResolver; | protected OpeningResolver $openingResolver; | ||||
protected ProductSolver $productSolver; | protected ProductSolver $productSolver; | ||||
protected OrderShopResolver $orderShopResolver; | protected OrderShopResolver $orderShopResolver; | ||||
protected OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver; | |||||
public function __construct( | public function __construct( | ||||
EntityManagerInterface $entityManager, | EntityManagerInterface $entityManager, | ||||
FlashBagInterface $flashBag, | FlashBagInterface $flashBag, | ||||
OpeningResolver $openingResolver, | OpeningResolver $openingResolver, | ||||
ProductSolver $productSolver, | ProductSolver $productSolver, | ||||
OrderShopResolver $orderShopResolver | |||||
OrderShopResolver $orderShopResolver, | |||||
OrderProductReductionCatalogSolver $orderProductReductionCatalogSolver | |||||
) { | ) { | ||||
$this->entityManager = $entityManager; | $this->entityManager = $entityManager; | ||||
$this->orderShopStore = $orderShopStore; | $this->orderShopStore = $orderShopStore; | ||||
$this->openingResolver = $openingResolver; | $this->openingResolver = $openingResolver; | ||||
$this->productSolver = $productSolver; | $this->productSolver = $productSolver; | ||||
$this->orderShopResolver = $orderShopResolver; | $this->orderShopResolver = $orderShopResolver; | ||||
$this->orderProductReductionCatalogSolver = $orderProductReductionCatalogSolver; | |||||
} | } | ||||
public function create( | public function create( | ||||
&& $orderProduct->getRedelivery() == $orderProductAdd->getRedelivery() | && $orderProduct->getRedelivery() == $orderProductAdd->getRedelivery() | ||||
&& (string)$this->priceSolver->getPrice($orderProduct) | && (string)$this->priceSolver->getPrice($orderProduct) | ||||
== (string)$this->priceSolver->getPrice($orderProductAdd) | == (string)$this->priceSolver->getPrice($orderProductAdd) | ||||
&& $orderProduct->getOrderProductReductionCatalog()->compare( | |||||
&& $orderProduct->getOrderProductReductionCatalog() | |||||
&& $orderProductAdd->getOrderProductReductionCatalog() | |||||
&& $this->orderProductReductionCatalogSolver->compare( | |||||
$orderProduct->getOrderProductReductionCatalog(), | |||||
$orderProductAdd->getOrderProductReductionCatalog() | $orderProductAdd->getOrderProductReductionCatalog() | ||||
)) { | )) { | ||||
$orderProduct->setQuantityOrder( | $orderProduct->setQuantityOrder( | ||||
public function createDocumentInvoice(OrderShopInterface $orderShop): DocumentInterface | public function createDocumentInvoice(OrderShopInterface $orderShop): DocumentInterface | ||||
{ | { | ||||
$documentFactory = new DocumentFactory(); | $documentFactory = new DocumentFactory(); | ||||
$document = $documentFactory->create(DocumentModel::TYPE_INVOICE); | |||||
$document = $documentFactory->create($orderShop->getSection(), DocumentModel::TYPE_INVOICE); | |||||
$this->documentBuilder->initFromOrderShop($document, $orderShop); | $this->documentBuilder->initFromOrderShop($document, $orderShop); | ||||
return $document; | return $document; | ||||
} | } | ||||
public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2) | public function getProductsSalesStatistic(SectionInterface $section, $entity, $nbWeek = 2) | ||||
{ | { | ||||
$productsSalesStatistic = new ProductsSalesStatistic($this->entityManager, $entity, $nbWeek, $this->productSolver); | |||||
$productsSalesStatistic = new ProductsSalesStatistic( | |||||
$this->entityManager, | |||||
$entity, | |||||
$nbWeek, | |||||
$this->productSolver | |||||
); | |||||
$productsSalesStatistic->init($section, $this->orderShopSolver, $this->openingResolver); | $productsSalesStatistic->init($section, $this->orderShopSolver, $this->openingResolver); | ||||
$productsSalesStatistic->populateProperties($this->orderShopStore); | $productsSalesStatistic->populateProperties($this->orderShopStore); |
use Lc\CaracoleBundle\Factory\Order\OrderProductFactory; | use Lc\CaracoleBundle\Factory\Order\OrderProductFactory; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderProductRepositoryQuery; | use Lc\CaracoleBundle\Repository\Order\OrderProductRepositoryQuery; | ||||
use Lc\CaracoleBundle\Repository\Order\OrderProductStore; | use Lc\CaracoleBundle\Repository\Order\OrderProductStore; | ||||
use Lc\CaracoleBundle\Solver\Order\OrderProductSolver; | |||||
class OrderProductContainer | class OrderProductContainer | ||||
{ | { | ||||
protected OrderProductFactory $factory; | protected OrderProductFactory $factory; | ||||
protected OrderProductSolver $solver; | |||||
protected OrderProductBuilder $builder; | protected OrderProductBuilder $builder; | ||||
protected OrderProductRepositoryQuery $repositoryQuery; | protected OrderProductRepositoryQuery $repositoryQuery; | ||||
protected OrderProductStore $store; | protected OrderProductStore $store; | ||||
public function __construct( | public function __construct( | ||||
OrderProductFactory $factory, | OrderProductFactory $factory, | ||||
OrderProductSolver $solver, | |||||
OrderProductBuilder $builder, | OrderProductBuilder $builder, | ||||
OrderProductRepositoryQuery $repositoryQuery, | OrderProductRepositoryQuery $repositoryQuery, | ||||
OrderProductStore $store | OrderProductStore $store | ||||
) { | ) { | ||||
$this->factory = $factory; | $this->factory = $factory; | ||||
$this->solver = $solver; | |||||
$this->builder = $builder; | $this->builder = $builder; | ||||
$this->repositoryQuery = $repositoryQuery; | $this->repositoryQuery = $repositoryQuery; | ||||
$this->store = $store; | $this->store = $store; | ||||
return $this->factory; | return $this->factory; | ||||
} | } | ||||
public function getSolver(): OrderProductSolver | |||||
{ | |||||
return $this->solver; | |||||
} | |||||
public function getBuilder(): OrderProductBuilder | public function getBuilder(): OrderProductBuilder | ||||
{ | { | ||||
return $this->builder; | return $this->builder; |
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory; | use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory; | ||||
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | ||||
use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel; | use Lc\CaracoleBundle\Model\Credit\CreditHistoryModel; | ||||
use Lc\CaracoleBundle\Model\Order\OrderPaymentModel; | |||||
use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | ||||
use Lc\SovBundle\Controller\AbstractAdminController; | use Lc\SovBundle\Controller\AbstractAdminController; | ||||
use Lc\SovBundle\Translation\TranslatorAdmin; | use Lc\SovBundle\Translation\TranslatorAdmin; | ||||
ChoiceField::new('meanPayment')->setChoices( | ChoiceField::new('meanPayment')->setChoices( | ||||
array( | array( | ||||
$translatorAdmin->transField( | $translatorAdmin->transField( | ||||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CASH, | |||||
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_CASH, | |||||
'CreditHistory' | 'CreditHistory' | ||||
) => CreditHistoryModel::MEAN_PAYMENT_CASH, | |||||
) => OrderPaymentModel::MEAN_PAYMENT_CASH, | |||||
$translatorAdmin->transField( | $translatorAdmin->transField( | ||||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CHEQUE, | |||||
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_CHEQUE, | |||||
'CreditHistory' | 'CreditHistory' | ||||
) => CreditHistoryModel::MEAN_PAYMENT_CHEQUE, | |||||
) => OrderPaymentModel::MEAN_PAYMENT_CHEQUE, | |||||
$translatorAdmin->transField( | $translatorAdmin->transField( | ||||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CREDIT, | |||||
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_CREDIT, | |||||
'CreditHistory' | 'CreditHistory' | ||||
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT, | |||||
) => OrderPaymentModel::MEAN_PAYMENT_CREDIT, | |||||
$translatorAdmin->transField( | $translatorAdmin->transField( | ||||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD, | |||||
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_CREDIT_CARD, | |||||
'CreditHistory' | 'CreditHistory' | ||||
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD, | |||||
) => OrderPaymentModel::MEAN_PAYMENT_CREDIT_CARD, | |||||
$translatorAdmin->transField( | $translatorAdmin->transField( | ||||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_TRANSFER, | |||||
'meanPaymentOptions.' . OrderPaymentModel::MEAN_PAYMENT_TRANSFER, | |||||
'CreditHistory' | 'CreditHistory' | ||||
) => CreditHistoryModel::MEAN_PAYMENT_TRANSFER, | |||||
) => OrderPaymentModel::MEAN_PAYMENT_TRANSFER, | |||||
) | ) | ||||
), | ), | ||||
TextField::new('reference'), | TextField::new('reference'), |
} else { | } else { | ||||
$product = null; | $product = null; | ||||
if ($productFamily->getActiveProducts()) { | if ($productFamily->getActiveProducts()) { | ||||
$products = $productFamily->getProductsOnline(); | |||||
$products = $this->productFamilySolver->getProductsOnline($productFamily); | |||||
if ($products && count($products) > 0) { | if ($products && count($products) > 0) { | ||||
$product = $products[0]; | $product = $products[0]; | ||||
} | } |
const DELIVERY_TYPE_HOME = 'home'; | const DELIVERY_TYPE_HOME = 'home'; | ||||
const DELIVERY_TYPE_POINTSALE = 'point-sale'; | const DELIVERY_TYPE_POINTSALE = 'point-sale'; | ||||
/** | /** | ||||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orderShops", fetch="EAGER") | * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orderShops", fetch="EAGER") | ||||
*/ | */ | ||||
protected $orderReductionCredits; | protected $orderReductionCredits; | ||||
/** | /** | ||||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\File\DocumentInterface", inversedBy="orderShops") | |||||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\File\DocumentInterface", inversedBy="orderShops", cascade={"persist"}) | |||||
*/ | */ | ||||
protected $documents; | protected $documents; | ||||
parent::__construct($repository, 'r', $paginator); | parent::__construct($repository, 'r', $paginator); | ||||
} | } | ||||
public function filterByType($type) | |||||
{ | |||||
return $this->andWhereEqual('type', $type); | |||||
} | |||||
public function filterByBuyerAddress(AddressInterface $buyerAddress) | public function filterByBuyerAddress(AddressInterface $buyerAddress) | ||||
{ | { | ||||
return $this | return $this |
namespace Lc\CaracoleBundle\Repository\File; | namespace Lc\CaracoleBundle\Repository\File; | ||||
use App\Entity\Address\Address; | use App\Entity\Address\Address; | ||||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | |||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | ||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\SovBundle\Repository\AbstractStore; | use Lc\SovBundle\Repository\AbstractStore; | ||||
class DocumentStore extends AbstractStore | class DocumentStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | use SectionStoreTrait; | ||||
use MerchantStoreTrait; | |||||
protected DocumentRepositoryQuery $query; | protected DocumentRepositoryQuery $query; | ||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->filterIsOnlineAndOffline(); | $query->filterIsOnlineAndOffline(); | ||||
$query->filterBySection($this->section); | |||||
if(isset($this->section) && $this->section) { | |||||
$query->filterBySection($this->section); | |||||
} | |||||
if(isset($this->merchant) && $this->merchant) { | |||||
$query->filterByMerchantViaSection($this->merchant); | |||||
} | |||||
return $query; | return $query; | ||||
} | } | ||||
} | } | ||||
public function getOneLatestByType(string $documentType, $query = null) | |||||
public function getOneLatestByType(string $documentType, $query = null): DocumentInterface | |||||
{ | { | ||||
// @TODO : à écrire | |||||
$query = $this->createDefaultQuery($query); | |||||
$query | |||||
->filterByType($documentType) | |||||
->orderBy('createdAt', 'DESC'); | |||||
return $query->findOne(); | |||||
} | } | ||||
// findLastInvoice | // findLastInvoice |
protected bool $isJoinOrderReductionCarts = false; | protected bool $isJoinOrderReductionCarts = false; | ||||
protected bool $isJoinOrderStatus = false; | protected bool $isJoinOrderStatus = false; | ||||
protected bool $isJoinMerchant = false; | protected bool $isJoinMerchant = false; | ||||
protected bool $isJoinSection = false; | |||||
protected bool $isJoinComplementaryOrderShops = false; | protected bool $isJoinComplementaryOrderShops = false; | ||||
protected bool $isJoinDeliveryPointSale = false; | protected bool $isJoinDeliveryPointSale = false; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function joinSection(): self | |||||
{ | |||||
if (!$this->isJoinSection) { | |||||
$this->isJoinSection = true; | |||||
return $this | |||||
->leftJoin('.section', 's'); | |||||
} | |||||
return $this; | |||||
} | |||||
public function joinComplementaryOrderShops(): self | public function joinComplementaryOrderShops(): self | ||||
{ | { | ||||
if (!$this->isJoinComplementaryOrderShops) { | if (!$this->isJoinComplementaryOrderShops) { |
} | } | ||||
if (isset($params['orderStatus'])) { | if (isset($params['orderStatus'])) { | ||||
$query->filterByStatus($params['orderStatus']); | |||||
$query->filterByStatus([$params['orderStatus']]); | |||||
} | } | ||||
if (isset($params['user'])) { | if (isset($params['user'])) { | ||||
$reductionCreditsArray = []; | $reductionCreditsArray = []; | ||||
foreach ($reductionCredits as $reductionCredit) { | foreach ($reductionCredits as $reductionCredit) { | ||||
if (!$this->countValidWithReductionCredit($reductionCredit, $user) | if (!$this->countValidWithReductionCredit($reductionCredit, $user) | ||||
&& (!$this->merchant || $reductionCredit->getSection()->getMerchant() == $this->merchant)) { | |||||
&& ($reductionCredit->getSection()->getMerchant() == $this->merchant)) { | |||||
$reductionCreditsArray[] = $reductionCredit; | $reductionCreditsArray[] = $reductionCredit; | ||||
} | } | ||||
} | } |
namespace Lc\CaracoleBundle\Repository\Product; | namespace Lc\CaracoleBundle\Repository\Product; | ||||
use Knp\Component\Pager\PaginatorInterface; | use Knp\Component\Pager\PaginatorInterface; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | ||||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | ||||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | use Lc\SovBundle\Repository\AbstractRepositoryQuery; |
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | ||||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | ||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | use Lc\CaracoleBundle\Solver\Price\PriceSolver; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
class ProductFamilyStore extends AbstractStore | class ProductFamilyStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | use SectionStoreTrait; | ||||
use MerchantStoreTrait; | |||||
protected ProductFamilyRepositoryQuery $query; | protected ProductFamilyRepositoryQuery $query; | ||||
protected PriceSolver $priceSolver; | protected PriceSolver $priceSolver; | ||||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | ||||
{ | { | ||||
$query->filterBySection($this->section); | |||||
if($this->section) { | |||||
$query->filterBySection($this->section); | |||||
} | |||||
if(isset($this->merchant) && $this->merchant) { | |||||
$query->filterByMerchantViaSection($this->merchant); | |||||
} | |||||
return $query; | return $query; | ||||
} | } | ||||
->setParameter('user', $user); | ->setParameter('user', $user); | ||||
} | } | ||||
public function filterByOwner(UserInterface $user) | |||||
{ | |||||
return $this | |||||
->andWhere('.owner = :user') | |||||
->setParameter('user', $user); | |||||
} | |||||
public function filterByType(string $type = ReductionCreditModel::TYPE_CREDIT) | public function filterByType(string $type = ReductionCreditModel::TYPE_CREDIT) | ||||
{ | { | ||||
return $this | return $this |
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | ||||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | ||||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | ||||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | use Lc\CaracoleBundle\Repository\SectionStoreTrait; | ||||
use Lc\SovBundle\Model\User\UserInterface; | use Lc\SovBundle\Model\User\UserInterface; | ||||
class ReductionCreditStore extends AbstractStore | class ReductionCreditStore extends AbstractStore | ||||
{ | { | ||||
use SectionStoreTrait; | use SectionStoreTrait; | ||||
use MerchantStoreTrait; | |||||
protected ReductionCreditRepositoryQuery $query; | protected ReductionCreditRepositoryQuery $query; | ||||
if($this->section) { | if($this->section) { | ||||
$query->filterBySection($this->section); | $query->filterBySection($this->section); | ||||
} | } | ||||
if(isset($this->merchant) && $this->merchant) { | |||||
$query->filterByMerchantViaSection($this->merchant); | |||||
} | |||||
$query->filterIsOnlineAndOffline(); | $query->filterIsOnlineAndOffline(); | ||||
return $query; | return $query; | ||||
} | } | ||||
{ | { | ||||
/// @TODO : à écrire | /// @TODO : à écrire | ||||
$query = $this->createDefaultQuery($query); | $query = $this->createDefaultQuery($query); | ||||
$query->filterByUser($user); | |||||
$query->filterByOwner($user); | |||||
return $query->find(); | return $query->find(); | ||||
} | } | ||||
{ | { | ||||
/// @TODO : à écrire | /// @TODO : à écrire | ||||
$query = $this->createDefaultQuery($query); | $query = $this->createDefaultQuery($query); | ||||
$query->filterByUser($user); | |||||
$query->filterByOwner($user); | |||||
return $query->find(); | return $query->find(); | ||||
} | } | ||||
namespace Lc\CaracoleBundle\Repository; | namespace Lc\CaracoleBundle\Repository; | ||||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | use Lc\CaracoleBundle\Model\Section\SectionInterface; | ||||
trait SectionRepositoryQueryTrait | trait SectionRepositoryQueryTrait | ||||
{ | { | ||||
protected bool $isJoinSection = false; | |||||
public function filterBySection(SectionInterface $section) | public function filterBySection(SectionInterface $section) | ||||
{ | { | ||||
return $this->andWhereSection($this->id, $section); | return $this->andWhereSection($this->id, $section); | ||||
} | } | ||||
public function filterByMerchantViaSection(MerchantInterface $merchant) | |||||
{ | |||||
$this->joinSection(); | |||||
return $this->andWhere('s.merchant = :merchant') | |||||
->setParameter('merchant', $merchant); | |||||
} | |||||
public function joinSection(): self | |||||
{ | |||||
if (!$this->isJoinSection) { | |||||
$this->isJoinSection = true; | |||||
return $this | |||||
->leftJoin('.section', 's'); | |||||
} | |||||
return $this; | |||||
} | |||||
} | } |
OrderProductReductionCatalogInterface $orderProductReductionCatalog, | OrderProductReductionCatalogInterface $orderProductReductionCatalog, | ||||
OrderProductReductionCatalogInterface $orderProductReductionCatalogCompare | OrderProductReductionCatalogInterface $orderProductReductionCatalogCompare | ||||
): bool { | ): bool { | ||||
return $orderProductReductionCatalogCompare | |||||
&& $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit() | |||||
return $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit() | |||||
&& (string)$orderProductReductionCatalog->getValue( | && (string)$orderProductReductionCatalog->getValue( | ||||
) == (string)$orderProductReductionCatalogCompare->getValue() | ) == (string)$orderProductReductionCatalogCompare->getValue() | ||||
&& $orderProductReductionCatalog->getBehaviorTaxRate( | && $orderProductReductionCatalog->getBehaviorTaxRate( |
} | } | ||||
// getProductQuantityMaxAddCart | // getProductQuantityMaxAddCart | ||||
public function getProductQuantityMaxAddCart(ProductInterface $product, OrderShopInterface $orderShop) | |||||
public function getProductQuantityMaxAddCart(OrderShopInterface $orderShop, ProductInterface $product) | |||||
{ | { | ||||
$productFamily = $product->getProductFamily(); | $productFamily = $product->getProductFamily(); | ||||
foreach ($products as $product) { | foreach ($products as $product) { | ||||
if ($product->getStatus() == 1) { | if ($product->getStatus() == 1) { | ||||
$titleProduct = $product->getTitleInherited(); | |||||
$titleProduct = $this->productSolver->getTitleInherited($product); | |||||
if (!isset($arrayProductsGroupByTitle[$titleProduct])) { | if (!isset($arrayProductsGroupByTitle[$titleProduct])) { | ||||
$arrayProductsGroupByTitle[$titleProduct] = []; | $arrayProductsGroupByTitle[$titleProduct] = []; | ||||
} | } | ||||
return $arrayProductsGroupByTitle; | return $arrayProductsGroupByTitle; | ||||
} | } | ||||
public function getQuantityTitle(ProductFamilyInterface $productFamily, ProductInterface $product) | |||||
{ | |||||
$title = $this->productSolver->getQuantityLabelInherited($product); | |||||
if ($this->hasProductsWithVariousWeight($productFamily)) { | |||||
$title .= ', ' . $this->productSolver->getTitleInherited($product); | |||||
} | |||||
return $title; | |||||
} | |||||
public function getOriginProduct(ProductFamilyInterface $productFamily): ?ProductInterface | public function getOriginProduct(ProductFamilyInterface $productFamily): ?ProductInterface | ||||
{ | { | ||||
$products = $productFamily->getProducts(); | $products = $productFamily->getProducts(); |
return $quantity . $unit->getWordingShort(); | return $quantity . $unit->getWordingShort(); | ||||
} | } | ||||
// @TODO : si besoin, à remettre en place | |||||
/*public function getQuantityTitle(ProductInterface $product, ProductFamilyInterface $productFamily) | |||||
{ | |||||
$title = $product->getQuantityLabelInherited(); | |||||
if ($this->productFamilySolver->hasProductsWithVariousWeight($productFamily)) { | |||||
$title .= ', ' . $product->getTitleInherited(); | |||||
} | |||||
return $title; | |||||
}*/ | |||||
public function getAvailableQuantityInherited(ProductInterface $product) | public function getAvailableQuantityInherited(ProductInterface $product) | ||||
{ | { | ||||
switch ($product->getProductFamily()->getBehaviorCountStock()) { | switch ($product->getProductFamily()->getBehaviorCountStock()) { |