@@ -21,7 +21,7 @@ class CreditHistoryBuilder | |||
} | |||
// saveCreditHistory | |||
public function save(CreditHistoryInterface $creditHistory) | |||
public function save(CreditHistoryInterface $creditHistory) :bool | |||
{ | |||
if ($creditHistory) { | |||
$userMerchant = $creditHistory->getUserMerchant(); |
@@ -15,7 +15,7 @@ class DocumentBuilder | |||
$this->documentReferenceGenerator = $documentReferenceGenerator; | |||
} | |||
public function initFromOrderShop(DocumentInterface $document, OrderShopInterface $orderShop) | |||
public function initFromOrderShop(DocumentInterface $document, OrderShopInterface $orderShop) :DocumentInterface | |||
{ | |||
$merchantAddress = $orderShop->getMerchant()->getAddress(); | |||
$buyerAddress = $orderShop->getInvoiceAddress(); |
@@ -21,7 +21,7 @@ class MerchantBuilder | |||
$this->cookieComponent = $cookieComponent; | |||
} | |||
public function setCookieMerchantCurrent($response, MerchantInterface $merchant) | |||
public function setCookieMerchantCurrent($response, MerchantInterface $merchant) :void | |||
{ | |||
$response->headers->setCookie( | |||
Cookie::create( |
@@ -6,28 +6,29 @@ use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderProductInterface; | |||
use Lc\CaracoleBundle\Repository\Order\OrderProductStore; | |||
use Lc\CaracoleBundle\Resolver\Price\PriceResolver; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
class OrderProductBuilder | |||
{ | |||
protected EntityManagerInterface $entityManager; | |||
protected PriceResolver $priceResolver; | |||
protected PriceSolver $priceSolver; | |||
protected OrderProductStore $orderProductStore; | |||
public function __construct( | |||
EntityManagerInterface $entityManager, | |||
PriceResolver $priceResolver, | |||
PriceSolver $priceSolver, | |||
OrderProductStore $orderProductStore | |||
) { | |||
$this->entityManager = $entityManager; | |||
$this->priceResolver = $priceResolver; | |||
$this->priceSolver = $priceSolver; | |||
$this->orderProductStore = $orderProductStore; | |||
} | |||
public function init(OrderProductInterface $orderProduct) | |||
public function init(OrderProductInterface $orderProduct) :OrderProductInterface | |||
{ | |||
$orderProduct->setTitle($orderProduct->getTitleOrderShop()); | |||
$orderProduct->setPrice($this->priceResolver->getPrice($orderProduct->getProduct())); | |||
$orderProduct->setBuyingPrice($this->priceResolver->getBuyingPrice($orderProduct->getProduct())); | |||
$orderProduct->setPrice($this->priceSolver->getPrice($orderProduct->getProduct())); | |||
$orderProduct->setBuyingPrice($this->priceSolver->getBuyingPrice($orderProduct->getProduct())); | |||
$orderProduct->setUnit($orderProduct->getProduct()->getUnitInherited()); | |||
$orderProduct->setTaxRate($orderProduct->getProduct()->getTaxRateInherited()); | |||
$orderProduct->setQuantityProduct($orderProduct->getProduct()->getQuantityInherited()); |
@@ -12,8 +12,11 @@ use Lc\CaracoleBundle\Factory\Order\OrderReductionCartFactory; | |||
use Lc\CaracoleBundle\Factory\Order\OrderReductionCreditFactory; | |||
use Lc\CaracoleBundle\Factory\Order\OrderShopFactory; | |||
use Lc\CaracoleBundle\Factory\Order\OrderStatusHistoryFactory; | |||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | |||
use Lc\CaracoleBundle\Model\File\DocumentModel; | |||
use Lc\CaracoleBundle\Model\Order\OrderProductInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderReductionCartInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderReductionCreditInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||
@@ -27,6 +30,7 @@ use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||
use Lc\CaracoleBundle\Repository\Order\OrderStatusStore; | |||
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; | |||
use Lc\CaracoleBundle\Resolver\Price\PriceResolver; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Symfony\Component\EventDispatcher\EventDispatcherInterface; | |||
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface; | |||
@@ -36,8 +40,9 @@ class OrderShopBuilder | |||
protected EntityManagerInterface $entityManager; | |||
protected OrderStatusStore $orderStatusStore; | |||
protected OrderProductStore $orderProductStore; | |||
protected OrderShopStore $orderShopStore; | |||
protected ProductFamilyStore $productFamilyStore; | |||
protected PriceResolver $priceResolver; | |||
protected PriceSolver $priceSolver; | |||
protected OrderProductBuilder $orderProductBuilder; | |||
protected DocumentBuilder $documentBuilder; | |||
protected EventDispatcherInterface $eventDispatcher; | |||
@@ -51,7 +56,7 @@ class OrderShopBuilder | |||
ProductFamilyStore $productFamilyStore, | |||
OrderProductBuilder $orderProductBuilder, | |||
DocumentBuilder $documentBuilder, | |||
PriceResolver $priceResolver, | |||
PriceSolver $priceSolver, | |||
EventDispatcherInterface $eventDispatcher, | |||
FlashBagInterface $flashBag | |||
) { | |||
@@ -62,7 +67,7 @@ class OrderShopBuilder | |||
$this->productFamilyStore = $productFamilyStore; | |||
$this->orderProductBuilder = $orderProductBuilder; | |||
$this->documentBuilder = $documentBuilder; | |||
$this->priceResolver = $priceResolver; | |||
$this->priceSolver = $priceSolver; | |||
$this->eventDispatcher = $eventDispatcher; | |||
$this->flashBag = $flashBag; | |||
} | |||
@@ -71,11 +76,14 @@ class OrderShopBuilder | |||
SectionInterface $section, | |||
UserInterface $user = null, | |||
VisitorInterface $visitor = null | |||
) { | |||
): OrderShopInterface { | |||
$orderShopFactory = new OrderShopFactory(); | |||
$orderShop = $orderShopFactory->create($section, $user, $visitor); | |||
$this->changeOrderStatus($orderShop, OrderStatusModel::ALIAS_CART); | |||
$this->setOrderStatus($orderShop, OrderStatusModel::ALIAS_CART); | |||
//TODO flush ??? | |||
return $orderShop; | |||
} | |||
@@ -84,7 +92,7 @@ class OrderShopBuilder | |||
SectionInterface $section, | |||
UserInterface $user = null, | |||
VisitorInterface $visitor = null | |||
) { | |||
): OrderShopInterface { | |||
$cart = $this->orderShopStore->getCartBy( | |||
[ | |||
'section' => $section, | |||
@@ -100,14 +108,16 @@ class OrderShopBuilder | |||
return $cart; | |||
} | |||
public function changeOrderStatus(OrderShopInterface $orderShop, string $alias, bool $forceByAdmin = false) | |||
{ | |||
public function setOrderStatus( | |||
OrderShopInterface $orderShop, | |||
string $alias, | |||
bool $forceByAdmin = false | |||
): OrderShopInterface { | |||
$orderStatus = $this->orderStatusStore->getRepositoryQuery()->findOneByAlias($alias); | |||
if ($orderStatus) { | |||
if ($orderShop->getOrderStatus() === null | |||
|| $orderShop->getOrderStatus()->getNextStatusAllowed()->contains($orderStatus)) { | |||
$this->applyChangeOrderStatus($orderShop, $orderStatus, $forceByAdmin); | |||
} | |||
} else { | |||
@@ -121,7 +131,7 @@ class OrderShopBuilder | |||
OrderShopInterface $orderShop, | |||
OrderStatusInterface $orderStatus, | |||
bool $forceByAdmin = false | |||
) { | |||
): void { | |||
$this->eventDispatcher->dispatch( | |||
new OrderShopChangeStatusEvent($orderShop, $orderStatus, $forceByAdmin), | |||
OrderShopChangeStatusEvent::PRE_CHANGE_STATUS | |||
@@ -144,7 +154,7 @@ class OrderShopBuilder | |||
OrderShopInterface $orderShop, | |||
OrderProductInterface $orderProductAdd, | |||
bool $persist = true | |||
) { | |||
): bool { | |||
$return = false; | |||
if ($this->orderProductStore->isOrderProductAvailableAddCart($orderProductAdd, $orderShop)) { | |||
@@ -199,10 +209,11 @@ class OrderShopBuilder | |||
if ($persist) { | |||
if (isset($orderProductReductionCatalog)) { | |||
$this->entityManager->persist($orderProductReductionCatalog); | |||
$this->entityManager->create($orderProductReductionCatalog); | |||
} | |||
$this->entityManager->persist($orderProductAdd); | |||
$this->entityManager->persist($orderShop); | |||
//TODO est-ce un update ou un create ??? | |||
$this->entityManager->update($orderProductAdd); | |||
$this->entityManager->update($orderShop); | |||
} | |||
$return = true; | |||
@@ -242,8 +253,11 @@ class OrderShopBuilder | |||
return $return; | |||
} | |||
public function merge(OrderShopInterface $orderShop1, OrderShopInterface $orderShop2, $persist = true) | |||
{ | |||
public function merge( | |||
OrderShopInterface $orderShop1, | |||
OrderShopInterface $orderShop2, | |||
$persist = true | |||
): OrderShopInterface { | |||
if ($orderShop1 && $orderShop2) { | |||
foreach ($orderShop2->getOrderProducts() as $orderProduct) { | |||
$orderProductAlreadyInCart = $orderShop1->hasOrderProductAlreadyInCart($orderProduct); | |||
@@ -258,13 +272,13 @@ class OrderShopBuilder | |||
} | |||
if ($persist) { | |||
$this->entityManager->remove($orderProduct); | |||
$this->entityManager->delete($orderProduct); | |||
} | |||
} | |||
if ($persist) { | |||
$this->entityManager->remove($orderShop2); | |||
$this->entityManager->persist($orderShop1); | |||
$this->entityManager->delete($orderShop2); | |||
$this->entityManager->update($orderShop1); | |||
$this->entityManager->flush(); | |||
} | |||
@@ -272,7 +286,7 @@ class OrderShopBuilder | |||
} | |||
} | |||
public function addPayment(OrderShopInterface $orderShop, $meanPayment, $amount) | |||
public function addPayment(OrderShopInterface $orderShop, string $meanPayment, float $amount): OrderShopInterface | |||
{ | |||
$orderPaymentFactory = new OrderPaymentFactory(); | |||
$orderPayment = $orderPaymentFactory->create($orderShop, $meanPayment, $amount); | |||
@@ -289,23 +303,25 @@ class OrderShopBuilder | |||
$orderShop = $this->changeOrderStatus($orderShop, $nextStatus); | |||
} | |||
$this->entityManager->persist($orderPayment); | |||
$this->entityManager->create($orderPayment); | |||
$this->entityManager->update($orderShop); | |||
$this->entityManager->flush(); | |||
return $orderShop; | |||
} | |||
public function createDocumentInvoice(OrderShopInterface $orderShop) | |||
public function createDocumentInvoice(OrderShopInterface $orderShop): DocumentInterface | |||
{ | |||
$documentFactory = new DocumentFactory(); | |||
$document = $documentFactory->create(DocumentModel::TYPE_INVOICE); | |||
$this->documentBuilder->initFromOrderShop($orderShop); | |||
$this->documentBuilder->initFromOrderShop($document, $orderShop); | |||
return $document; | |||
} | |||
public function addReductionCart(OrderShopInterface $orderShop, ReductionCartInterface $reductionCart) | |||
{ | |||
public function addReductionCart( | |||
OrderShopInterface $orderShop, | |||
ReductionCartInterface $reductionCart | |||
): ?OrderReductionCartInterface { | |||
$orderReductionCartFactory = new OrderReductionCartFactory(); | |||
$orderReductionCart = $orderReductionCartFactory->create($orderShop, $reductionCart); | |||
@@ -313,19 +329,22 @@ class OrderShopBuilder | |||
if ($this->orderShopStore->isPositiveAmount($orderShop) | |||
&& $this->isPositiveAmountRemainingToBePaid($orderShop)) { | |||
$this->entityManager->persist($orderReductionCart); | |||
$this->entityManager->create($orderReductionCart); | |||
$this->entityManager->flush(); | |||
return $orderReductionCart; | |||
} else { | |||
//TODO vérifier ce case ! Avec le null en valeur de retour | |||
$orderShop->removeOrderReductionCart($orderReductionCart); | |||
return false; | |||
return null; | |||
} | |||
} | |||
// createOrderReductionCredit | |||
public function addReductionCredit(OrderShopInterface $orderShop, ReductionCreditInterface $reductionCredit) | |||
{ | |||
public function addReductionCredit( | |||
OrderShopInterface $orderShop, | |||
ReductionCreditInterface $reductionCredit | |||
): ?OrderReductionCreditInterface { | |||
$orderReductionCreditFactory = new OrderReductionCreditFactory(); | |||
$orderReductionCredit = $orderReductionCreditFactory->create($orderShop, $reductionCredit); | |||
@@ -333,69 +352,68 @@ class OrderShopBuilder | |||
if ($this->isOrderShopPositiveAmount($orderShop) | |||
&& $this->isOrderShopPositiveAmountRemainingToBePaid($orderShop)) { | |||
$this->entityManager->persist($orderReductionCredit); | |||
$this->entityManager->create($orderReductionCredit); | |||
$this->entityManager->flush(); | |||
return $orderReductionCredit; | |||
} else { | |||
$orderShop->removeOrderReductionCredit($orderReductionCredit); | |||
return false; | |||
return null; | |||
} | |||
} | |||
public function deductAvailabilityProduct(OrderShopInterface $orderShop) | |||
public function deductAvailabilityProduct(OrderShopInterface $orderShop): void | |||
{ | |||
// @TODO : à refactorer en plaçant dans src tout ce qui est spécifique à PDL | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
//Si ce n'esrt pas une relivraison OU si c'est une relivraison + relivraison + ce n'est pas une erruer producteur | |||
if (!$orderProduct->isRedelivery() || ($orderProduct->isRedelivery( | |||
) && $orderProduct->isRedeliverySupplierOrder( | |||
) && !$orderProduct->isRedeliverySupplierMistake())) { | |||
switch ($orderProduct->getProduct()->getProductFamily()->getBehaviorCountStock()) { | |||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE : | |||
$this->applyDeductAvailabilityProduct($orderShop, $orderProduct); | |||
} | |||
} | |||
//Disponibilité par unité de référence | |||
$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited(); | |||
$newAvailability = $oldAvailability - ($orderProduct->getQuantityOrder( | |||
) * ($orderProduct->getQuantityProduct() / $orderProduct->getUnit( | |||
)->getCoefficient())); | |||
public function applyDeductAvailabilityProduct( | |||
OrderShopInterface $orderShop, | |||
OrderProductInterface $orderProduct | |||
): void { | |||
switch ($orderProduct->getProduct()->getProductFamily()->getBehaviorCountStock()) { | |||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE : | |||
$productFamily = $orderProduct->getProduct()->getProductFamily(); | |||
$productFamily->setAvailableQuantity($newAvailability); | |||
$productFamily->setUpdatedBy($orderShop->getUser()); | |||
//Disponibilité par unité de référence | |||
$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited(); | |||
$newAvailability = $oldAvailability - ($orderProduct->getQuantityOrder( | |||
) * ($orderProduct->getQuantityProduct() / $orderProduct->getUnit()->getCoefficient())); | |||
$this->entityManager->persist($productFamily); | |||
$productFamily = $orderProduct->getProduct()->getProductFamily(); | |||
$productFamily->setAvailableQuantity($newAvailability); | |||
$productFamily->setUpdatedBy($orderShop->getUser()); | |||
break; | |||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : | |||
$this->entityManager->update($productFamily); | |||
$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited(); | |||
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder(); | |||
break; | |||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY : | |||
$productFamily = $orderProduct->getProduct()->getProductFamily(); | |||
$productFamily->setAvailableQuantity($newAvailability); | |||
$productFamily->setUpdatedBy($orderShop->getUser()); | |||
$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited(); | |||
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder(); | |||
$this->entityManager->persist($productFamily); | |||
$productFamily = $orderProduct->getProduct()->getProductFamily(); | |||
$productFamily->setAvailableQuantity($newAvailability); | |||
$productFamily->setUpdatedBy($orderShop->getUser()); | |||
break; | |||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : | |||
$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited(); | |||
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder(); | |||
$this->entityManager->update($productFamily); | |||
$product = $orderProduct->getProduct(); | |||
$product->setAvailableQuantity($newAvailability); | |||
$product->setUpdatedBy($orderShop->getUser()); | |||
break; | |||
case ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT : | |||
$oldAvailability = $orderProduct->getProduct()->getAvailableQuantityInherited(); | |||
$newAvailability = $oldAvailability - $orderProduct->getQuantityOrder(); | |||
$this->entityManager->persist($product); | |||
$product = $orderProduct->getProduct(); | |||
$product->setAvailableQuantity($newAvailability); | |||
$product->setUpdatedBy($orderShop->getUser()); | |||
break; | |||
} | |||
$this->entityManager->update($product); | |||
$this->entityManager->flush(); | |||
} | |||
break; | |||
} | |||
$this->entityManager->flush(); | |||
} | |||
} |
@@ -11,13 +11,13 @@ use Lc\SovBundle\Builder\User\UserBuilder as SovUserBuilder; | |||
class UserBuilder extends SovUserBuilder | |||
{ | |||
public function linkToPointSale(UserInterface $user, PointSaleInterface $pointSale) | |||
public function linkToPointSale(UserInterface $user, PointSaleInterface $pointSale):bool | |||
{ | |||
if (!$user->isLinkedToPointSale($pointSale)) { | |||
$userPointSaleFactory = new UserPointSaleFactory(); | |||
$userPointSale = $userPointSaleFactory->create($user, $pointSale); | |||
$this->entityManager->persist($userPointSale); | |||
$this->entityManager->create($userPointSale); | |||
$this->entityManager->flush(); | |||
return true; |
@@ -31,23 +31,28 @@ class UserMerchantBuilder | |||
if (!$userMerchant) { | |||
$userMerchantFactory = new UserMerchantFactory(); | |||
$userMerchant = $userMerchantFactory | |||
->setMerchant($merchant) | |||
->create($user); | |||
$userMerchant = $userMerchantFactory->create($user, $merchant); | |||
} | |||
return $userMerchant; | |||
} | |||
public function init(UserInterface $user, MerchantInterface $merchant, bool $active = true, bool $creditActive = false, float $credit = null, bool $persist = true) | |||
{ | |||
public function init( | |||
UserInterface $user, | |||
MerchantInterface $merchant, | |||
bool $active = true, | |||
bool $creditActive = false, | |||
float $credit = null, | |||
bool $persist = true | |||
): UserMerchantInterface { | |||
$userMerchant = $this->createIfNotExist($user, $merchant); | |||
$userMerchant->setActive($active); | |||
$userMerchant->setCreditActive($creditActive) ; | |||
$userMerchant->setCredit($credit) ; | |||
$userMerchant->setCreditActive($creditActive); | |||
$userMerchant->setCredit($credit); | |||
if($persist) { | |||
if ($persist) { | |||
//TODO create ou update ??? | |||
$this->entityManager->persist($userMerchant); | |||
$this->entityManager->flush(); | |||
} | |||
@@ -60,11 +65,11 @@ class UserMerchantBuilder | |||
MerchantInterface $merchant, | |||
$creditActive = true | |||
): UserMerchantInterface { | |||
$userMerchant = $this->createIfNotExist($user, $merchant); | |||
$userMerchant->setCreditActive($creditActive); | |||
//TODO create ou update ??? | |||
$this->entityManager->persist($userMerchant); | |||
$this->entityManager->flush(); | |||
@@ -88,8 +93,8 @@ class UserMerchantBuilder | |||
): UserMerchantInterface { | |||
$userMerchant->setCredit($amount); | |||
$this->entityManager->persist($creditHistory); | |||
$this->entityManager->persist($userMerchant); | |||
$this->entityManager->update($creditHistory); | |||
$this->entityManager->update($userMerchant); | |||
$this->entityManager->flush(); | |||
return $userMerchant; |
@@ -31,7 +31,7 @@ class VisitorBuilder | |||
$visitorFactory = new VisitorFactory(); | |||
$visitor = $visitorFactory->create($cookie, $ip); | |||
$this->entityManager->persist($visitor); | |||
$this->entityManager->create($visitor); | |||
$this->entityManager->flush(); | |||
} | |||
@@ -42,12 +42,12 @@ class VisitorBuilder | |||
$visitor->setTotalVisit($totalVisit); | |||
$visitor->setLastAccess(new \DateTime()); | |||
$this->entityManager->persist($visitor); | |||
$this->entityManager->update($visitor); | |||
$this->entityManager->flush(); | |||
} | |||
// setCookieVisitor | |||
public function setCookie($response, $cookie) | |||
public function setCookie($response, $cookie): void | |||
{ | |||
$response->headers->setCookie( | |||
Cookie::create( | |||
@@ -61,7 +61,7 @@ class VisitorBuilder | |||
} | |||
// updateVisitorCookie | |||
public function updateCookie($response) | |||
public function updateCookie($response): void | |||
{ | |||
$response->headers->setCookie( | |||
Cookie::create( |
@@ -0,0 +1,90 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Checker; | |||
use Lc\CaracoleBundle\Model\Order\OrderProductInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
class OrderChecker | |||
{ | |||
protected PriceSolver $priceSolver; | |||
protected OrderShopSolver $orderShopSolver; | |||
public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver) | |||
{ | |||
$this->priceSolver = $priceSolver; | |||
$this->orderShopSolver = $orderShopSolver; | |||
} | |||
public function hasOrderProductAlreadyInCart( | |||
OrderShopInterface $orderShop, | |||
OrderProductInterface $orderProductTest | |||
): ?OrderProductInterface { | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
if ($orderProduct->getProduct() == $orderProductTest->getProduct()) { | |||
return $orderProduct; | |||
} | |||
} | |||
return null; | |||
} | |||
public function isValid(OrderShopInterface $orderShop): bool | |||
{ | |||
if ($orderShop->getOrderStatus() && in_array( | |||
$orderShop->getOrderStatus()->getAlias(), | |||
OrderStatusModel::$statusAliasAsValid | |||
) > 0) { | |||
return true; | |||
} | |||
return false; | |||
} | |||
public function isCart(OrderShopInterface $orderShop): bool | |||
{ | |||
if ($orderShop->getOrderStatus() && in_array( | |||
$orderShop->getOrderStatus()->getAlias(), | |||
OrderStatusModel::$statusAliasAsCart | |||
) > 0) { | |||
return true; | |||
} | |||
return false; | |||
} | |||
// isOrderShopPositiveAmount | |||
public function isPositiveAmount(OrderShopInterface $orderShop): bool | |||
{ | |||
return $this->priceSolver->getTotalWithTax($orderShop) >= 0; | |||
} | |||
public function isPaid(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false): bool | |||
{ | |||
$totalOrderPayments = $this->orderShopSolver->getTotalOrderPayments($orderShop, $mergeComplementaryOrderShop); | |||
$totalOrder = $this->priceSolver->getTotalWithTax($orderShop); | |||
if ((abs($totalOrderPayments - $totalOrder) < 0.00001 | |||
|| $totalOrderPayments >= $totalOrder) | |||
&& $totalOrder > 0) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} | |||
// isOrderShopPositiveAmountRemainingToBePaid | |||
public function isPositiveAmountRemainingToBePaid(OrderShopInterface $orderShop): bool | |||
{ | |||
return $this->orderShopSolver->getTotalRemainingToBePaid($orderShop) > 0; | |||
} | |||
public function isCartAllowToBeOrder(OrderShopInterface $orderShop): bool | |||
{ | |||
return true; | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Address; | |||
use Lc\CaracoleBundle\Factory\Address\AddressFactory; | |||
use Lc\CaracoleBundle\Repository\Address\AddressRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Address\AddressStore; | |||
class AddressContainer | |||
{ | |||
protected AddressFactory $factory; | |||
protected AddressRepositoryQuery $repositoryQuery; | |||
protected AddressStore $store; | |||
public function __construct( | |||
AddressFactory $factory, | |||
AddressRepositoryQuery $repositoryQuery, | |||
AddressStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): AddressFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): AddressRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): AddressStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Config; | |||
use Lc\CaracoleBundle\Factory\Config\TaxRateFactory; | |||
use Lc\CaracoleBundle\Repository\Config\TaxRateRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Config\TaxRateStore; | |||
class TaxRateContainer | |||
{ | |||
protected TaxRateFactory $factory; | |||
protected TaxRateRepositoryQuery $repositoryQuery; | |||
protected TaxRateStore $store; | |||
public function __construct( | |||
TaxRateFactory $factory, | |||
TaxRateRepositoryQuery $repositoryQuery, | |||
TaxRateStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): TaxRateFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): TaxRateRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): TaxRateStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Config; | |||
use Lc\CaracoleBundle\Factory\Config\UnitFactory; | |||
use Lc\CaracoleBundle\Repository\Config\UnitRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Config\UnitStore; | |||
class UnitContainer | |||
{ | |||
protected UnitFactory $factory; | |||
protected UnitRepositoryQuery $repositoryQuery; | |||
protected UnitStore $store; | |||
public function __construct( | |||
UnitFactory $factory, | |||
UnitRepositoryQuery $repositoryQuery, | |||
UnitStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): UnitFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): UnitRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): UnitStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Credit; | |||
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory; | |||
use Lc\CaracoleBundle\Repository\Credit\CreditHistoryRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Credit\CreditHistoryStore; | |||
class CreditHistoryContainer | |||
{ | |||
protected CreditHistoryFactory $factory; | |||
protected CreditHistoryRepositoryQuery $repositoryQuery; | |||
protected CreditHistoryStore $store; | |||
public function __construct( | |||
CreditHistoryFactory $factory, | |||
CreditHistoryRepositoryQuery $repositoryQuery, | |||
CreditHistoryStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): CreditHistoryFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): CreditHistoryRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): CreditHistoryStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\File; | |||
use Lc\CaracoleBundle\Factory\File\DocumentFactory; | |||
use Lc\CaracoleBundle\Repository\File\DocumentRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\File\DocumentStore; | |||
class DocumentContainer | |||
{ | |||
protected DocumentFactory $factory; | |||
protected DocumentRepositoryQuery $repositoryQuery; | |||
protected DocumentStore $store; | |||
public function __construct( | |||
DocumentFactory $factory, | |||
DocumentRepositoryQuery $repositoryQuery, | |||
DocumentStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): DocumentFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): DocumentRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): DocumentStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,52 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Merchant; | |||
use Lc\CaracoleBundle\Builder\Merchant\MerchantBuilder; | |||
use Lc\CaracoleBundle\Factory\Merchant\MerchantFactory; | |||
use Lc\CaracoleBundle\Repository\Merchant\MerchantRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
class MerchantContainer | |||
{ | |||
protected MerchantFactory $factory; | |||
protected MerchantBuilder $builder; | |||
protected MerchantResolver $resolver; | |||
protected MerchantRepositoryQuery $repositoryQuery; | |||
protected MerchantStore $store; | |||
public function __construct( | |||
MerchantFactory $factory, | |||
MerchantBuilder $builder, | |||
MerchantResolver $resolver, | |||
MerchantRepositoryQuery $repositoryQuery, | |||
MerchantStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->builder = $builder; | |||
$this->resolver = $resolver; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): MerchantFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getResolver(): MerchantResolver | |||
{ | |||
return $this->resolver; | |||
} | |||
public function getRepositoryQuery(): MerchantRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): MerchantStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -1,20 +0,0 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
/** | |||
* class MyContainer. | |||
* | |||
* @author Simon Vieille <simon@deblan.fr> | |||
*/ | |||
class MyContainer | |||
{ | |||
public MerchantResolver $merchantResolver; | |||
public function __construct(MerchantResolver $merchantResolver) | |||
{ | |||
$this->merchantResolver = $merchantResolver; | |||
} | |||
} |
@@ -0,0 +1,39 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Factory\Order\OrderPaymentFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderPaymentRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderPaymentStore; | |||
class OrderPaymentContainer | |||
{ | |||
protected OrderPaymentFactory $factory; | |||
protected OrderPaymentRepositoryQuery $repositoryQuery; | |||
protected OrderPaymentStore $store; | |||
public function __construct( | |||
OrderPaymentFactory $factory, | |||
OrderPaymentRepositoryQuery $repositoryQuery, | |||
OrderPaymentStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OrderPaymentFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): OrderPaymentRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OrderPaymentStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Builder\Order\OrderProductBuilder; | |||
use Lc\CaracoleBundle\Factory\Order\OrderProductFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderProductRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderProductStore; | |||
class OrderProductContainer | |||
{ | |||
protected OrderProductFactory $factory; | |||
protected OrderProductBuilder $builder; | |||
protected OrderProductRepositoryQuery $repositoryQuery; | |||
protected OrderProductStore $store; | |||
public function __construct( | |||
OrderProductFactory $factory, | |||
OrderProductBuilder $builder, | |||
OrderProductRepositoryQuery $repositoryQuery, | |||
OrderProductStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->builder = $builder; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OrderProductFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getBuilder(): OrderProductBuilder | |||
{ | |||
return $this->builder; | |||
} | |||
public function getRepositoryQuery(): OrderProductRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OrderProductStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Factory\Order\OrderProductReductionCatalogFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderProductReductionCatalogRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderProductReductionCatalogStore; | |||
use Lc\CaracoleBundle\Solver\Order\OrderProductReductionCatalogSolver; | |||
class OrderProductReductionCatalogContainer | |||
{ | |||
protected OrderProductReductionCatalogFactory $factory; | |||
protected OrderProductReductionCatalogSolver $solver; | |||
protected OrderProductReductionCatalogRepositoryQuery $repositoryQuery; | |||
protected OrderProductReductionCatalogStore $store; | |||
public function __construct( | |||
OrderProductReductionCatalogFactory $factory, | |||
OrderProductReductionCatalogSolver $solver, | |||
OrderProductReductionCatalogRepositoryQuery $repositoryQuery, | |||
OrderProductReductionCatalogStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->solver = $solver; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OrderProductReductionCatalogFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getSolver(): OrderProductReductionCatalogSolver | |||
{ | |||
return $this->solver; | |||
} | |||
public function getRepositoryQuery(): OrderProductReductionCatalogRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OrderProductReductionCatalogStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Factory\Order\OrderProductRefundFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderProductRefundRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderProductRefundStore; | |||
class OrderProductRefundContainer | |||
{ | |||
protected OrderProductRefundFactory $factory; | |||
protected OrderProductRefundRepositoryQuery $repositoryQuery; | |||
protected OrderProductRefundStore $store; | |||
public function __construct( | |||
OrderProductRefundFactory $factory, | |||
OrderProductRefundRepositoryQuery $repositoryQuery, | |||
OrderProductRefundStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OrderProductRefundFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): OrderProductRefundRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OrderProductRefundStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Factory\Order\OrderReductionCartFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderReductionCartRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderReductionCartStore; | |||
class OrderReductionCartContainer | |||
{ | |||
protected OrderReductionCartFactory $factory; | |||
protected OrderReductionCartRepositoryQuery $repositoryQuery; | |||
protected OrderReductionCartStore $store; | |||
public function __construct( | |||
OrderReductionCartFactory $factory, | |||
OrderReductionCartRepositoryQuery $repositoryQuery, | |||
OrderReductionCartStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OrderReductionCartFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): OrderReductionCartRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OrderReductionCartStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Factory\Order\OrderReductionCreditFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderReductionCreditRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderReductionCreditStore; | |||
class OrderReductionCreditContainer | |||
{ | |||
protected OrderReductionCreditFactory $factory; | |||
protected OrderReductionCreditRepositoryQuery $repositoryQuery; | |||
protected OrderReductionCreditStore $store; | |||
public function __construct( | |||
OrderReductionCreditFactory $factory, | |||
OrderReductionCreditRepositoryQuery $repositoryQuery, | |||
OrderReductionCreditStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OrderReductionCreditFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): OrderReductionCreditRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OrderReductionCreditStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Factory\Order\OrderRefundFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderRefundRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderRefundStore; | |||
class OrderRefundContainer | |||
{ | |||
protected OrderRefundFactory $factory; | |||
protected OrderRefundRepositoryQuery $repositoryQuery; | |||
protected OrderRefundStore $store; | |||
public function __construct( | |||
OrderRefundFactory $factory, | |||
OrderRefundRepositoryQuery $repositoryQuery, | |||
OrderRefundStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OrderRefundFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): OrderRefundRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OrderRefundStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,67 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder; | |||
use Lc\CaracoleBundle\Checker\OrderChecker; | |||
use Lc\CaracoleBundle\Factory\Order\OrderShopFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderShopRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | |||
class OrderShopContainer | |||
{ | |||
protected OrderShopFactory $orderShopFactory; | |||
protected OrderShopSolver $orderShopSolver; | |||
protected OrderChecker $orderChecker; | |||
protected OrderShopRepositoryQuery $orderShopRepositoryQuery; | |||
protected OrderShopStore $orderShopStore; | |||
protected OrderShopBuilder $orderShopBuilder; | |||
public function __construct( | |||
OrderShopFactory $orderShopFactory, | |||
OrderShopSolver $orderShopSolver, | |||
OrderChecker $orderChecker, | |||
OrderShopRepositoryQuery $orderShopRepositoryQuery, | |||
OrderShopStore $orderShopStore, | |||
OrderShopBuilder $orderShopBuilder | |||
) { | |||
$this->orderShopFactory = $orderShopFactory; | |||
$this->orderShopSolver = $orderShopSolver; | |||
$this->orderChecker = $orderChecker; | |||
$this->orderShopRepositoryQuery = $orderShopRepositoryQuery; | |||
$this->orderShopStore = $orderShopStore; | |||
$this->orderShopBuilder = $orderShopBuilder; | |||
} | |||
public function getFactory(): OrderShopFactory | |||
{ | |||
return $this->orderShopFactory; | |||
} | |||
public function getSolver(): OrderShopSolver | |||
{ | |||
return $this->orderShopSolver; | |||
} | |||
public function getChecker(): OrderChecker | |||
{ | |||
return $this->orderChecker; | |||
} | |||
public function getRepositoryQuery(): OrderShopRepositoryQuery | |||
{ | |||
return $this->orderShopRepositoryQuery; | |||
} | |||
public function getStore(): OrderShopStore | |||
{ | |||
return $this->orderShopStore; | |||
} | |||
public function getBuilder(): OrderShopBuilder | |||
{ | |||
return $this->orderShopBuilder; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Factory\Order\OrderStatusFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderStatusRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderStatusStore; | |||
class OrderStatusContainer | |||
{ | |||
protected OrderStatusFactory $factory; | |||
protected OrderStatusRepositoryQuery $repositoryQuery; | |||
protected OrderStatusStore $store; | |||
public function __construct( | |||
OrderStatusFactory $factory, | |||
OrderStatusRepositoryQuery $repositoryQuery, | |||
OrderStatusStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OrderStatusFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): OrderStatusRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OrderStatusStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Order; | |||
use Lc\CaracoleBundle\Factory\Order\OrderStatusHistoryFactory; | |||
use Lc\CaracoleBundle\Repository\Order\OrderStatusHistoryRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Order\OrderStatusHistoryStore; | |||
class OrderStatusHistoryContainer | |||
{ | |||
protected OrderStatusHistoryFactory $factory; | |||
protected OrderStatusHistoryRepositoryQuery $repositoryQuery; | |||
protected OrderStatusHistoryStore $store; | |||
public function __construct( | |||
OrderStatusHistoryFactory $factory, | |||
OrderStatusHistoryRepositoryQuery $repositoryQuery, | |||
OrderStatusHistoryStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OrderStatusHistoryFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): OrderStatusHistoryRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OrderStatusHistoryStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\PointSale; | |||
use Lc\CaracoleBundle\Factory\PointSale\PointSaleFactory; | |||
use Lc\CaracoleBundle\Repository\PointSale\PointSaleRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\PointSale\PointSaleStore; | |||
class PointSaleContainer | |||
{ | |||
protected PointSaleFactory $factory; | |||
protected PointSaleRepositoryQuery $repositoryQuery; | |||
protected PointSaleStore $store; | |||
public function __construct( | |||
PointSaleFactory $factory, | |||
PointSaleRepositoryQuery $repositoryQuery, | |||
PointSaleStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): PointSaleFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): PointSaleRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): PointSaleStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Product; | |||
use Lc\CaracoleBundle\Factory\Product\ProductCategoryFactory; | |||
use Lc\CaracoleBundle\Repository\Product\ProductCategoryRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Product\ProductCategoryStore; | |||
class ProductCategoryContainer | |||
{ | |||
protected ProductCategoryFactory $factory; | |||
protected ProductCategoryRepositoryQuery $repositoryQuery; | |||
protected ProductCategoryStore $store; | |||
public function __construct( | |||
ProductCategoryFactory $factory, | |||
ProductCategoryRepositoryQuery $repositoryQuery, | |||
ProductCategoryStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): ProductCategoryFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): ProductCategoryRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): ProductCategoryStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Product; | |||
use Lc\CaracoleBundle\Factory\Product\ProductFactory; | |||
use Lc\CaracoleBundle\Repository\Product\ProductRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Product\ProductStore; | |||
class ProductContainer | |||
{ | |||
protected ProductFactory $factory; | |||
protected ProductRepositoryQuery $repositoryQuery; | |||
protected ProductStore $store; | |||
public function __construct( | |||
ProductFactory $factory, | |||
ProductRepositoryQuery $repositoryQuery, | |||
ProductStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): ProductFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): ProductRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): ProductStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Product; | |||
use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory; | |||
use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Product\ProductFamilyStore; | |||
class ProductFamilyContainer | |||
{ | |||
protected ProductFamilyFactory $factory; | |||
protected ProductFamilyRepositoryQuery $repositoryQuery; | |||
protected ProductFamilyStore $store; | |||
public function __construct( | |||
ProductFamilyFactory $factory, | |||
ProductFamilyRepositoryQuery $repositoryQuery, | |||
ProductFamilyStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): ProductFamilyFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): ProductFamilyRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): ProductFamilyStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Reduction; | |||
use Lc\CaracoleBundle\Factory\Reduction\ReductionCartFactory; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore; | |||
class ReductionCartContainer | |||
{ | |||
protected ReductionCartFactory $factory; | |||
protected ReductionCartRepositoryQuery $repositoryQuery; | |||
protected ReductionCartStore $store; | |||
public function __construct( | |||
ReductionCartFactory $factory, | |||
ReductionCartRepositoryQuery $repositoryQuery, | |||
ReductionCartStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): ReductionCartFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): ReductionCartRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): ReductionCartStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Reduction; | |||
use Lc\CaracoleBundle\Factory\Reduction\ReductionCatalogFactory; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogStore; | |||
class ReductionCatalogContainer | |||
{ | |||
protected ReductionCatalogFactory $factory; | |||
protected ReductionCatalogRepositoryQuery $repositoryQuery; | |||
protected ReductionCatalogStore $store; | |||
public function __construct( | |||
ReductionCatalogFactory $factory, | |||
ReductionCatalogRepositoryQuery $repositoryQuery, | |||
ReductionCatalogStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): ReductionCatalogFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): ReductionCatalogRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): ReductionCatalogStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Reduction; | |||
use Lc\CaracoleBundle\Factory\Reduction\ReductionCreditFactory; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore; | |||
class ReductionCreditContainer | |||
{ | |||
protected ReductionCreditFactory $factory; | |||
protected ReductionCreditRepositoryQuery $repositoryQuery; | |||
protected ReductionCreditStore $store; | |||
public function __construct( | |||
ReductionCreditFactory $factory, | |||
ReductionCreditRepositoryQuery $repositoryQuery, | |||
ReductionCreditStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): ReductionCreditFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): ReductionCreditRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): ReductionCreditStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Section; | |||
use Lc\CaracoleBundle\Factory\Section\OpeningFactory; | |||
use Lc\CaracoleBundle\Repository\Section\OpeningRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Section\OpeningStore; | |||
use Lc\CaracoleBundle\Resolver\OpeningResolver; | |||
class OpeningContainer | |||
{ | |||
protected OpeningFactory $factory; | |||
protected OpeningResolver $resolver; | |||
protected OpeningRepositoryQuery $repositoryQuery; | |||
protected OpeningStore $store; | |||
public function __construct( | |||
OpeningFactory $factory, | |||
OpeningResolver $resolver, | |||
OpeningRepositoryQuery $repositoryQuery, | |||
OpeningStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->resolver = $resolver; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): OpeningFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getResolver(): OpeningResolver | |||
{ | |||
return $this->resolver; | |||
} | |||
public function getRepositoryQuery(): OpeningRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): OpeningStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Section; | |||
use Lc\CaracoleBundle\Factory\Section\SectionFactory; | |||
use Lc\CaracoleBundle\Repository\Section\SectionRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Section\SectionStore; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
class SectionContainer | |||
{ | |||
protected SectionFactory $factory; | |||
protected SectionResolver $resolver; | |||
protected SectionRepositoryQuery $repositoryQuery; | |||
protected SectionStore $store; | |||
public function __construct( | |||
SectionFactory $factory, | |||
SectionResolver $resolver, | |||
SectionRepositoryQuery $repositoryQuery, | |||
SectionStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->resolver = $resolver; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): SectionFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getResolver(): SectionResolver | |||
{ | |||
return $this->resolver; | |||
} | |||
public function getRepositoryQuery(): SectionRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): SectionStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,48 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Setting; | |||
use Lc\CaracoleBundle\Definition\MerchantSettingDefinition; | |||
use Lc\CaracoleBundle\Factory\Setting\MerchantSettingFactory; | |||
use Lc\CaracoleBundle\Repository\Setting\MerchantSettingRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Setting\MerchantSettingStore; | |||
class MerchantSettingContainer | |||
{ | |||
protected MerchantSettingFactory $factory; | |||
protected MerchantSettingDefinition $definition; | |||
protected MerchantSettingRepositoryQuery $repositoryQuery; | |||
protected MerchantSettingStore $store; | |||
public function __construct( | |||
MerchantSettingFactory $factory, | |||
MerchantSettingDefinition $definition, | |||
MerchantSettingRepositoryQuery $repositoryQuery, | |||
MerchantSettingStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): MerchantSettingFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getDefinition(): MerchantSettingDefinition | |||
{ | |||
return $this->definition; | |||
} | |||
public function getRepositoryQuery(): MerchantSettingRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): MerchantSettingStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,49 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\Setting; | |||
use Lc\CaracoleBundle\Definition\SectionSettingDefinition; | |||
use Lc\CaracoleBundle\Factory\Setting\SectionSettingFactory; | |||
use Lc\CaracoleBundle\Repository\Setting\SectionSettingRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\Setting\SectionSettingStore; | |||
class SectionSettingContainer | |||
{ | |||
protected SectionSettingFactory $factory; | |||
protected SectionSettingDefinition $definition; | |||
protected SectionSettingRepositoryQuery $repositoryQuery; | |||
protected SectionSettingStore $store; | |||
public function __construct( | |||
SectionSettingFactory $factory, | |||
SectionSettingDefinition $definition, | |||
SectionSettingRepositoryQuery $repositoryQuery, | |||
SectionSettingStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->definition = $definition; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): SectionSettingFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getDefinition(): SectionSettingDefinition | |||
{ | |||
return $this->definition; | |||
} | |||
public function getRepositoryQuery(): SectionSettingRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): SectionSettingStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\User; | |||
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory; | |||
use Lc\CaracoleBundle\Repository\User\UserMerchantRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\User\UserMerchantStore; | |||
class UserMerchantContainer | |||
{ | |||
protected UserMerchantFactory $factory; | |||
protected UserMerchantRepositoryQuery $repositoryQuery; | |||
protected UserMerchantStore $store; | |||
public function __construct( | |||
UserMerchantFactory $factory, | |||
UserMerchantRepositoryQuery $repositoryQuery, | |||
UserMerchantStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): UserMerchantFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): UserMerchantRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): UserMerchantStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\User; | |||
use Lc\CaracoleBundle\Factory\User\UserPointSaleFactory; | |||
use Lc\CaracoleBundle\Repository\User\UserPointSaleRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\User\UserPointSaleStore; | |||
class UserPointSaleContainer | |||
{ | |||
protected UserPointSaleFactory $factory; | |||
protected UserPointSaleRepositoryQuery $repositoryQuery; | |||
protected UserPointSaleStore $store; | |||
public function __construct( | |||
UserPointSaleFactory $factory, | |||
UserPointSaleRepositoryQuery $repositoryQuery, | |||
UserPointSaleStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): UserPointSaleFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): UserPointSaleRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): UserPointSaleStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -0,0 +1,40 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Container\User; | |||
use Lc\CaracoleBundle\Factory\User\VisitorFactory; | |||
use Lc\CaracoleBundle\Repository\User\VisitorRepositoryQuery; | |||
use Lc\CaracoleBundle\Repository\User\VisitorStore; | |||
class VisitorContainer | |||
{ | |||
protected VisitorFactory $factory; | |||
protected VisitorRepositoryQuery $repositoryQuery; | |||
protected VisitorStore $store; | |||
public function __construct( | |||
VisitorFactory $factory, | |||
VisitorRepositoryQuery $repositoryQuery, | |||
VisitorStore $store | |||
) { | |||
$this->factory = $factory; | |||
$this->repositoryQuery = $repositoryQuery; | |||
$this->store = $store; | |||
} | |||
public function getFactory(): VisitorFactory | |||
{ | |||
return $this->factory; | |||
} | |||
public function getRepositoryQuery(): VisitorRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; | |||
} | |||
public function getStore(): VisitorStore | |||
{ | |||
return $this->store; | |||
} | |||
} |
@@ -15,6 +15,36 @@ use EasyCorp\Bundle\EasyAdminBundle\Exception\ForbiddenActionException; | |||
use EasyCorp\Bundle\EasyAdminBundle\Exception\InsufficientEntityPermissionException; | |||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | |||
use Lc\CaracoleBundle\Container\Address\AddressContainer; | |||
use Lc\CaracoleBundle\Container\Config\TaxRateContainer; | |||
use Lc\CaracoleBundle\Container\Config\UnitContainer; | |||
use Lc\CaracoleBundle\Container\Credit\CreditHistoryContainer; | |||
use Lc\CaracoleBundle\Container\File\DocumentContainer; | |||
use Lc\CaracoleBundle\Container\Merchant\MerchantContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderPaymentContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderProductContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderProductReductionCatalogContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderProductRefundContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderReductionCartContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderReductionCreditContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderRefundContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderShopContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderStatusContainer; | |||
use Lc\CaracoleBundle\Container\Order\OrderStatusHistoryContainer; | |||
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductCategoryContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductContainer; | |||
use Lc\CaracoleBundle\Container\Product\ProductFamilyContainer; | |||
use Lc\CaracoleBundle\Container\Reduction\ReductionCartContainer; | |||
use Lc\CaracoleBundle\Container\Reduction\ReductionCatalogContainer; | |||
use Lc\CaracoleBundle\Container\Reduction\ReductionCreditContainer; | |||
use Lc\CaracoleBundle\Container\Section\OpeningContainer; | |||
use Lc\CaracoleBundle\Container\Section\SectionContainer; | |||
use Lc\CaracoleBundle\Container\Setting\MerchantSettingContainer; | |||
use Lc\CaracoleBundle\Container\Setting\SectionSettingContainer; | |||
use Lc\CaracoleBundle\Container\User\UserMerchantContainer; | |||
use Lc\CaracoleBundle\Container\User\UserPointSaleContainer; | |||
use Lc\CaracoleBundle\Container\User\VisitorContainer; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMultipleMerchantsInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
@@ -27,6 +57,17 @@ use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use EasyCorp\Bundle\EasyAdminBundle\Dto\EntityDto; | |||
use EasyCorp\Bundle\EasyAdminBundle\Dto\SearchDto; | |||
use Lc\SovBundle\Component\EntityComponent; | |||
use Lc\SovBundle\Container\File\FileContainer; | |||
use Lc\SovBundle\Container\Newsletter\NewsletterContainer; | |||
use Lc\SovBundle\Container\Reminder\ReminderContainer; | |||
use Lc\SovBundle\Container\Setting\SiteSettingContainer; | |||
use Lc\SovBundle\Container\Site\NewsContainer; | |||
use Lc\SovBundle\Container\Site\PageContainer; | |||
use Lc\SovBundle\Container\Site\SiteContainer; | |||
use Lc\SovBundle\Container\Ticket\TicketContainer; | |||
use Lc\SovBundle\Container\Ticket\TicketMessageContainer; | |||
use Lc\SovBundle\Container\User\GroupUserContainer; | |||
use Lc\SovBundle\Container\User\UserContainer; | |||
use Lc\SovBundle\Factory\User\UserFactory; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
use Symfony\Component\HttpFoundation\Response; | |||
@@ -40,11 +81,38 @@ trait AdminControllerTrait | |||
return array_merge( | |||
parent::getSubscribedServices(), | |||
[ | |||
'merchant_resolver' => MerchantResolver::class, | |||
'section_resolver' => SectionResolver::class, | |||
'user_factory' => UserFactory::class, | |||
'user_merchant_factory' => UserMerchantFactory::class, | |||
ReductionCatalogStore::class => ReductionCatalogStore::class, | |||
MerchantResolver::class => MerchantResolver::class, | |||
SectionResolver::class=> SectionResolver::class, | |||
AddressContainer::class => AddressContainer::class, | |||
TaxRateContainer::class => TaxRateContainer::class, | |||
UnitContainer::class => UnitContainer::class, | |||
CreditHistoryContainer::class => CreditHistoryContainer::class, | |||
DocumentContainer::class => DocumentContainer::class, | |||
MerchantContainer::class => MerchantContainer::class, | |||
OrderPaymentContainer::class => OrderPaymentContainer::class, | |||
OrderProductContainer::class => OrderProductContainer::class, | |||
OrderProductReductionCatalogContainer::class => OrderProductReductionCatalogContainer::class, | |||
OrderProductRefundContainer::class => OrderProductRefundContainer::class, | |||
OrderReductionCartContainer::class => OrderReductionCartContainer::class, | |||
OrderReductionCreditContainer::class => OrderReductionCreditContainer::class, | |||
OrderRefundContainer::class => OrderRefundContainer::class, | |||
OrderShopContainer::class => OrderShopContainer::class, | |||
OrderStatusContainer::class => OrderStatusContainer::class, | |||
OrderStatusHistoryContainer::class => OrderStatusHistoryContainer::class, | |||
PointSaleContainer::class => PointSaleContainer::class, | |||
ProductCategoryContainer::class => ProductCategoryContainer::class, | |||
ProductContainer::class => ProductContainer::class, | |||
ProductFamilyContainer::class => ProductFamilyContainer::class, | |||
ReductionCartContainer::class => ReductionCartContainer::class, | |||
ReductionCatalogContainer::class => ReductionCatalogContainer::class, | |||
ReductionCreditContainer::class => ReductionCreditContainer::class, | |||
OpeningContainer::class => OpeningContainer::class, | |||
SectionContainer::class => SectionContainer::class, | |||
MerchantSettingContainer::class => MerchantSettingContainer::class, | |||
SectionSettingContainer::class => SectionSettingContainer::class, | |||
UserMerchantContainer::class => UserMerchantContainer::class, | |||
UserPointSaleContainer::class => UserPointSaleContainer::class, | |||
VisitorContainer::class => VisitorContainer::class | |||
] | |||
); | |||
} | |||
@@ -120,7 +188,7 @@ trait AdminControllerTrait | |||
'entityClass' => $context->getEntity()->getFqcn(), | |||
'entityId' => $context->getEntity()->getInstance()->getId(), | |||
'action' => $context->getRequest()->getUri(), | |||
'attr' => ['id'=> 'duplicate-other-merchant-form'], | |||
'attr' => ['id' => 'duplicate-other-merchant-form'], | |||
) | |||
); | |||
@@ -162,7 +230,7 @@ trait AdminControllerTrait | |||
); | |||
return new Response(json_encode($response)); | |||
}else{ | |||
} else { | |||
throw new \ErrorException('La requête doit être effectué en ajax'); | |||
} | |||
} | |||
@@ -194,7 +262,7 @@ trait AdminControllerTrait | |||
'entityClass' => $context->getEntity()->getFqcn(), | |||
'entityId' => $context->getEntity()->getInstance()->getId(), | |||
'action' => $context->getRequest()->getUri(), | |||
'attr' => ['id'=> 'duplicate-other-section-form'], | |||
'attr' => ['id' => 'duplicate-other-section-form'], | |||
) | |||
); | |||
@@ -235,7 +303,7 @@ trait AdminControllerTrait | |||
); | |||
return new Response(json_encode($response)); | |||
}else{ | |||
} else { | |||
throw new \ErrorException('La requête doit être effectué en ajax'); | |||
} | |||
} |
@@ -3,9 +3,9 @@ | |||
namespace Lc\CaracoleBundle\Controller\Config; | |||
use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Container\Config\TaxRateContainer; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Config\TaxRateFactory; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
@@ -29,7 +29,6 @@ abstract class TaxRateAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new TaxRateFactory(); | |||
return $factory->create(); | |||
return $this->get(TaxRateContainer::class)->getFactory()->create(); | |||
} | |||
} |
@@ -7,6 +7,7 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Container\Config\UnitContainer; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Config\UnitFactory; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
@@ -29,7 +30,6 @@ abstract class UnitAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new UnitFactory(); | |||
return $factory->create(); | |||
return $this->get(UnitContainer::class)->getFactory()->create(); | |||
} | |||
} |
@@ -19,6 +19,8 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\MoneyField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | |||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||
use Lc\CaracoleBundle\Container\Credit\CreditHistoryContainer; | |||
use Lc\CaracoleBundle\Container\User\UserMerchantContainer; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory; | |||
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | |||
@@ -30,7 +32,7 @@ use Lc\SovBundle\Translation\TranslatorAdmin; | |||
abstract class CreditHistoryAdminController extends AbstractAdminController | |||
{ | |||
use AdminControllerTrait; | |||
public function overrideGlobalActions(?ActionCollection $actions): void | |||
{ | |||
parent::overrideGlobalActions($actions); | |||
@@ -52,8 +54,7 @@ abstract class CreditHistoryAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new CreditHistoryFactory(); | |||
return $factory->create(); | |||
return $this->get(CreditHistoryContainer::class)->getFactory()->create(); | |||
} | |||
public function persistEntity(EntityManagerInterface $entityManager, $entityInstance): void | |||
@@ -66,11 +67,9 @@ abstract class CreditHistoryAdminController extends AbstractAdminController | |||
protected function getUserMerchant(): UserMerchantInterface | |||
{ | |||
$request = $this->get(AdminContextProvider::class)->getContext()->getRequest(); | |||
$userMerchant = $this->get('em')->getRepository(UserMerchantInterface::class)->find( | |||
return $this->get(UserMerchantContainer::class)->getStore()->getOneById( | |||
$request->get('userMerchantId') | |||
); | |||
return $userMerchant; | |||
} | |||
public function configureActions(Actions $actions): Actions | |||
@@ -92,45 +91,47 @@ abstract class CreditHistoryAdminController extends AbstractAdminController | |||
$translatorAdmin = $this->get('translator_admin'); | |||
return [ | |||
IdField::new('id')->hideOnForm(), | |||
// @TODO : transChoices | |||
ChoiceField::new('type')->setChoices( | |||
array( | |||
$translatorAdmin->transField( | |||
'typeOptions.'.CreditHistoryModel::TYPE_CREDIT, | |||
'typeOptions.' . CreditHistoryModel::TYPE_CREDIT, | |||
'CreditHistory' | |||
) => CreditHistoryModel::TYPE_CREDIT, | |||
$translatorAdmin->transField( | |||
'typeOptions.'.CreditHistoryModel::TYPE_DEBIT, | |||
'typeOptions.' . CreditHistoryModel::TYPE_DEBIT, | |||
'CreditHistory' | |||
) => CreditHistoryModel::TYPE_DEBIT, | |||
) | |||
), | |||
MoneyField::new('amount')->setCurrency('EUR'), | |||
DateField::new('paidAt'), | |||
// @TODO : transChoices | |||
ChoiceField::new('meanPayment')->setChoices( | |||
array( | |||
$translatorAdmin->transField( | |||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CASH, | |||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CASH, | |||
'CreditHistory' | |||
) => CreditHistoryModel::MEAN_PAYMENT_CASH, | |||
$translatorAdmin->transField( | |||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CHEQUE, | |||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CHEQUE, | |||
'CreditHistory' | |||
) => CreditHistoryModel::MEAN_PAYMENT_CHEQUE, | |||
$translatorAdmin->transField( | |||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CREDIT, | |||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CREDIT, | |||
'CreditHistory' | |||
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT, | |||
$translatorAdmin->transField( | |||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD, | |||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD, | |||
'CreditHistory' | |||
) => CreditHistoryModel::MEAN_PAYMENT_CREDIT_CARD, | |||
$translatorAdmin->transField( | |||
'meanPaymentOptions.'.CreditHistoryModel::MEAN_PAYMENT_TRANSFER, | |||
'meanPaymentOptions.' . CreditHistoryModel::MEAN_PAYMENT_TRANSFER, | |||
'CreditHistory' | |||
) => CreditHistoryModel::MEAN_PAYMENT_TRANSFER, | |||
) | |||
@@ -146,6 +147,7 @@ abstract class CreditHistoryAdminController extends AbstractAdminController | |||
FieldCollection $fields, | |||
FilterCollection $filters | |||
): QueryBuilder { | |||
$queryBuilder = parent::createIndexQueryBuilder( | |||
$searchDto, | |||
$entityDto, |
@@ -15,7 +15,7 @@ class FavoriteMerchantController extends AbstractController | |||
/** | |||
* @Route("/merchant/favorite", name="carac_merchant_favorite") | |||
*/ | |||
public function favoriteMerchant(Request $request, Security $security, EntityManagerInterface $em) | |||
public function favoriteMerchant(Request $request, Security $security, EntityManagerInterface $entityManager) | |||
{ | |||
$user = $security->getUser() ; | |||
@@ -29,9 +29,10 @@ class FavoriteMerchantController extends AbstractController | |||
if ($merchant) { | |||
$user->setFavoriteMerchant($merchant) ; | |||
$em->update($user) ; | |||
$em->flush() ; | |||
$entityManager->update($user) ; | |||
$entityManager->flush() ; | |||
// @TODO : à fignoler, hein gamin ? | |||
$url = $merchant->getSettingValue(MerchantSettingDefinition::SETTING_URL).'admin'; | |||
if ($url) { |
@@ -2,10 +2,12 @@ | |||
namespace Lc\CaracoleBundle\Controller\Merchant; | |||
use App\Entity\Merchant\Merchant; | |||
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\Merchant\MerchantContainer; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Merchant\MerchantFactory; | |||
use Lc\CaracoleBundle\Field\Address\AddressField; | |||
@@ -45,8 +47,7 @@ abstract class MerchantAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new MerchantFactory(); | |||
return $factory->create(); | |||
return $this->get(MerchantContainer::class)->getFactory()->create(); | |||
} | |||
} |
@@ -14,7 +14,7 @@ class SwitchMerchantController extends AbstractController | |||
/** | |||
* @Route("/merchant/switch", name="carac_merchant_switch") | |||
*/ | |||
public function switchMerchant(Request $request, MerchantRepository $merchantRepository) | |||
public function switchMerchant(Request $request) | |||
{ | |||
$form = $this->createForm(SwitchMerchantFormType::class); | |||
$form->handleRequest($request); | |||
@@ -37,8 +37,4 @@ class SwitchMerchantController extends AbstractController | |||
} | |||
} | |||
public function visitMerchant() | |||
{ | |||
} | |||
} |
@@ -4,6 +4,8 @@ namespace Lc\CaracoleBundle\Controller\Newsletter; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Newsletter\NewsletterFactory; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\SovBundle\Container\Newsletter\NewsletterContainer; | |||
use Lc\SovBundle\Controller\Newsletter\NewsletterAdminController as SovNewsletterAdminController; | |||
abstract class NewsletterAdminController extends SovNewsletterAdminController | |||
@@ -12,8 +14,9 @@ abstract class NewsletterAdminController extends SovNewsletterAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new NewsletterFactory(); | |||
$factory->setMerchant($this->get('merchant_resolver')->getCurrent()); | |||
return $factory->create(); | |||
return $this->get(NewsletterContainer::class) | |||
->getFactory() | |||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) | |||
->create(); | |||
} | |||
} |
@@ -5,9 +5,11 @@ namespace Lc\CaracoleBundle\Controller\PointSale; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Container\PointSale\PointSaleContainer; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\PointSale\PointSaleFactory; | |||
use Lc\CaracoleBundle\Field\Address\AddressField; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
use Lc\SovBundle\Field\BooleanField; | |||
use Lc\SovBundle\Field\StatusField; | |||
@@ -44,8 +46,8 @@ abstract class PointSaleAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new PointSaleFactory(); | |||
$currentMerchant = $this->get('merchant_resolver')->getCurrent(); | |||
return $factory->create($currentMerchant); | |||
return $this->get(PointSaleContainer::class) | |||
->getFactory() | |||
->create($this->get(MerchantResolver::class)->getCurrent()); | |||
} | |||
} |
@@ -7,12 +7,15 @@ 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\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Field\Address\AddressField; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCatalogStore; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
use Lc\SovBundle\Field\BooleanField; | |||
use Lc\SovBundle\Field\CKEditorField; | |||
use Lc\SovBundle\Field\StatusField; | |||
use Lc\SovBundle\Translation\TranslatorAdmin; | |||
abstract class ProductCategoryAdminController extends AbstractAdminController | |||
{ |
@@ -17,5 +17,4 @@ abstract class ProductFamilyAdminController extends AbstractAdminController | |||
{ | |||
use AdminControllerTrait; | |||
} |
@@ -2,8 +2,12 @@ | |||
namespace Lc\CaracoleBundle\Controller\Reminder; | |||
use App\Entity\Reminder\Reminder; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Reminder\ReminderFactory; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\SovBundle\Container\Reminder\ReminderContainer; | |||
use Lc\SovBundle\Controller\Reminder\ReminderAdminController as SovReminderAdminController; | |||
class ReminderAdminController extends SovReminderAdminController | |||
@@ -12,10 +16,10 @@ class ReminderAdminController extends SovReminderAdminController | |||
public function createEntity(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null) | |||
{ | |||
$factory = new ReminderFactory(); | |||
return $factory | |||
->setMerchant($this->get('merchant_resolver')->getCurrent()) | |||
->setSection($this->get('section_resolver')->getCurrent()) | |||
return $this->get(ReminderContainer::class) | |||
->getFactory() | |||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) | |||
->setSection($this->get(SectionResolver::class)->getCurrent()) | |||
->create($crudAction, $crudControllerFqcn, $entityId); | |||
} | |||
} |
@@ -6,8 +6,10 @@ use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TimeField; | |||
use Lc\CaracoleBundle\Container\Section\OpeningContainer; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Section\OpeningFactory; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
abstract class OpeningAdminController extends AbstractAdminController | |||
@@ -56,9 +58,9 @@ abstract class OpeningAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new OpeningFactory(); | |||
$currentSection = $this->get('section_resolver')->getCurrent(); | |||
return $factory->create($currentSection); | |||
return $this->get(OpeningContainer::class) | |||
->getFactory() | |||
->create($this->get(SectionResolver::class)->getCurrent()); | |||
} | |||
} |
@@ -6,15 +6,18 @@ use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\FormField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; | |||
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; | |||
use Lc\CaracoleBundle\Container\Section\SectionContainer; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Section\SectionFactory; | |||
use Lc\CaracoleBundle\Form\Section\OpeningsFormType; | |||
use Lc\CaracoleBundle\Model\Section\SectionModel; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
use Lc\SovBundle\Field\BooleanField; | |||
use Lc\SovBundle\Field\CKEditorField; | |||
use Lc\SovBundle\Field\StatusField; | |||
use Symfony\Component\HttpFoundation\Request; | |||
use Symfony\Component\HttpFoundation\Session\SessionFactory; | |||
use Symfony\Component\Routing\Annotation\Route; | |||
abstract class SectionAdminController extends AbstractAdminController | |||
@@ -56,9 +59,9 @@ abstract class SectionAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new SectionFactory(); | |||
$currentMerchant = $this->get('merchant_resolver')->getCurrent(); | |||
return $factory->create($currentMerchant); | |||
return $this->get(SectionContainer::class) | |||
->getFactory() | |||
->create($this->get(MerchantResolver::class)->getCurrent()); | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Controller\Section; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\CaracoleBundle\Container\Section\SectionContainer; | |||
use Lc\CaracoleBundle\Form\Section\SwitchSectionFormType; | |||
use Lc\CaracoleBundle\Repository\Section\SectionRepository; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
@@ -18,22 +19,22 @@ class SwitchSectionAdminController extends AbstractController | |||
*/ | |||
public function switchSection( | |||
Request $request, | |||
EntityManagerInterface $em, | |||
EntityManagerInterface $entityManager, | |||
MerchantResolver $merchantResolver, | |||
SectionRepository $sectionRepository | |||
SectionContainer $sectionContainer | |||
) { | |||
$form = $this->createForm(SwitchSectionFormType::class); | |||
$form->handleRequest($request); | |||
if ($form->isSubmitted() && $form->isValid()) { | |||
$idSection = $form->get('id_section')->getData(); | |||
$section = $sectionRepository->find($idSection); | |||
$section = $sectionContainer->getStore()->getOneById($idSection); | |||
$userMerchant = $merchantResolver->getUserMerchant(); | |||
if ($section && $userMerchant) { | |||
$userMerchant->setCurrentAdminSection($section); | |||
$em->update($section); | |||
$em->flush(); | |||
$entityManager->update($section); | |||
$entityManager->flush(); | |||
} | |||
} | |||
@@ -2,6 +2,12 @@ | |||
namespace Lc\CaracoleBundle\Controller\Setting; | |||
use Lc\CaracoleBundle\Container\Merchant\MerchantContainer; | |||
use Lc\CaracoleBundle\Container\Section\SectionContainer; | |||
use Lc\CaracoleBundle\Container\Setting\MerchantSettingContainer; | |||
use Lc\CaracoleBundle\Container\Setting\SectionSettingContainer; | |||
use Lc\SovBundle\Container\Setting\SiteSettingContainer; | |||
use Lc\SovBundle\Container\Site\SiteContainer; | |||
use Lc\SovBundle\Controller\Setting\SettingAdminController as SovSettingController; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\CaracoleBundle\Definition\MerchantSettingDefinitionInterface; | |||
@@ -19,63 +25,39 @@ use Symfony\Component\Routing\Annotation\Route; | |||
class SettingAdminController extends SovSettingController | |||
{ | |||
protected $em; | |||
protected $translatorAdmin; | |||
protected $merchantResolver; | |||
protected $merchantSettingDefinition; | |||
protected $sectionResolver; | |||
protected $sectionSettingDefinition; | |||
protected $siteSettingDefinition; | |||
protected $siteRepository; | |||
public function __construct( | |||
EntityManagerInterface $em, | |||
TranslatorAdmin $translatorAdmin, | |||
MerchantResolver $merchantResolver, | |||
SectionResolver $sectionResolver, | |||
MerchantSettingDefinitionInterface $merchantSettingDefinition, | |||
SectionSettingDefinitionInterface $sectionSettingDefinition, | |||
SiteSettingDefinition $siteSettingDefinition, | |||
SiteRepository $siteRepository | |||
) { | |||
$this->em = $em; | |||
$this->translatorAdmin = $translatorAdmin; | |||
$this->merchantResolver = $merchantResolver; | |||
$this->sectionResolver = $sectionResolver; | |||
$this->merchantSettingDefinition = $merchantSettingDefinition; | |||
$this->sectionSettingDefinition = $sectionSettingDefinition; | |||
$this->siteSettingDefinition = $siteSettingDefinition; | |||
$this->siteRepository = $siteRepository; | |||
} | |||
/** | |||
* @Route("/admin/setting/merchant", name="carac_admin_setting_merchant") | |||
*/ | |||
public function manageMerchant(Request $request) | |||
{ | |||
public function manageMerchant( | |||
Request $request | |||
) { | |||
return $this->manage($request, 'merchant'); | |||
} | |||
/** | |||
* @Route("/admin/setting/section", name="carac_admin_setting_section") | |||
*/ | |||
public function manageSection(Request $request) | |||
{ | |||
public function manageSection( | |||
Request $request | |||
) { | |||
return $this->manage($request, 'section'); | |||
} | |||
public function manage(Request $request, $type) | |||
{ | |||
public function manage( | |||
Request $request, | |||
$type | |||
) { | |||
$entity = null; | |||
$entityManager = $this->get(EntityManagerInterface::class); | |||
if ($type == 'merchant') { | |||
$resolver = $this->merchantResolver; | |||
$resolver = $this->get(MerchantContainer::class)->getResolver(); | |||
$formClass = MerchantSettingsFormType::class; | |||
$settingDefinition = $this->merchantSettingDefinition; | |||
$settingDefinition = $this->get(MerchantSettingContainer::class)->getDefinition(); | |||
} elseif ($type == 'section') { | |||
$resolver = $this->sectionResolver; | |||
$resolver = $this->get(SectionContainer::class)->getResolver(); | |||
$formClass = SectionSettingsFormType::class; | |||
$settingDefinition = $this->sectionSettingDefinition; | |||
$settingDefinition = $this->get(SectionSettingContainer::class)->getDefinition(); | |||
} | |||
$entity = $resolver->getCurrent(); | |||
@@ -86,10 +68,10 @@ class SettingAdminController extends SovSettingController | |||
$form->handleRequest($request); | |||
if ($form->isSubmitted() && $form->isValid()) { | |||
$this->em->update($entity); | |||
$this->em->flush(); | |||
$entityManager->update($entity); | |||
$entityManager->flush(); | |||
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved')); | |||
$this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('settings_saved')); | |||
} | |||
return $this->render( | |||
@@ -107,18 +89,18 @@ class SettingAdminController extends SovSettingController | |||
/** | |||
* @Route("/admin/setting/site2", name="carac_admin_setting_site") | |||
*/ | |||
public function manageGlobal(Request $request) | |||
public function manageGlobal(Request $request, EntityManagerInterface $entityManager) | |||
{ | |||
$site = $this->siteRepository->findOneByDevAlias('default'); | |||
$site = $this->get(SiteContainer::class)->getStore()->getOneByDevAlias('default'); | |||
$form = $this->createForm(SiteSettingsFormType::class, $site); | |||
$form->handleRequest($request); | |||
if ($form->isSubmitted() && $form->isValid()) { | |||
$this->em->update($site); | |||
$this->em->flush(); | |||
$entityManager->update($site); | |||
$entityManager->flush(); | |||
$this->addFlash('success', $this->translatorAdmin->transFlashMessage('settings_saved')); | |||
$this->addFlash('success', $this->get(TranslatorAdmin::class)->transFlashMessage('settings_saved')); | |||
} | |||
return $this->render( |
@@ -4,6 +4,8 @@ namespace Lc\CaracoleBundle\Controller\Site; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Site\NewsFactory; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\SovBundle\Container\Site\NewsContainer; | |||
use Lc\SovBundle\Controller\Site\NewsAdminController as SovNewsAdminController; | |||
abstract class NewsAdminController extends SovNewsAdminController | |||
@@ -12,9 +14,9 @@ abstract class NewsAdminController extends SovNewsAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new NewsFactory(); | |||
$currentMerchant = $this->get('merchant_resolver')->getCurrent(); | |||
$factory->setMerchant($currentMerchant); | |||
return $factory->create(); | |||
return $this->get(NewsContainer::class) | |||
->getFactory() | |||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) | |||
->create(); | |||
} | |||
} |
@@ -4,6 +4,8 @@ namespace Lc\CaracoleBundle\Controller\Site; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\Site\PageFactory; | |||
use Lc\CaracoleBundle\Resolver\SectionResolver; | |||
use Lc\SovBundle\Container\Site\PageContainer; | |||
use Lc\SovBundle\Controller\Site\PageAdminController as SovPageAdminController; | |||
abstract class PageAdminController extends SovPageAdminController | |||
@@ -12,9 +14,9 @@ abstract class PageAdminController extends SovPageAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new PageFactory(); | |||
$currentSection = $this->get('section_resolver')->getCurrent(); | |||
$factory->setSection($currentSection); | |||
return $factory->create(); | |||
return $this->get(PageContainer::class) | |||
->getFactory() | |||
->setSection($this->get(SectionResolver::class)->getCurrent()) | |||
->create(); | |||
} | |||
} |
@@ -3,6 +3,8 @@ | |||
namespace Lc\CaracoleBundle\Controller\Ticket; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\SovBundle\Container\Ticket\TicketContainer; | |||
use Lc\SovBundle\Controller\Ticket\TicketAdminController as SovTicketAdminController; | |||
use Lc\CaracoleBundle\Factory\Ticket\TicketFactory; | |||
@@ -12,10 +14,10 @@ class TicketAdminController extends SovTicketAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$merchantResolver = $this->get('merchant_resolver'); | |||
$factory = new TicketFactory(); | |||
$factory->setMerchant($merchantResolver->getCurrent()); | |||
return $factory->create(); | |||
return $this->get(TicketContainer::class) | |||
->getFactory() | |||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) | |||
->create(); | |||
} | |||
} |
@@ -4,6 +4,8 @@ namespace Lc\CaracoleBundle\Controller\User; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\User\GroupUserFactory; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\SovBundle\Container\User\GroupUserContainer; | |||
use Lc\SovBundle\Controller\User\GroupUserAdminController as SovGroupUserAdminController; | |||
abstract class GroupUserAdminController extends SovGroupUserAdminController | |||
@@ -12,9 +14,9 @@ abstract class GroupUserAdminController extends SovGroupUserAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
$factory = new GroupUserFactory(); | |||
$currentMerchant = $this->get('merchant_resolver')->getCurrent(); | |||
$factory->setMerchant($currentMerchant); | |||
return $factory->create(); | |||
return $this->get(GroupUserContainer::class) | |||
->getFactory() | |||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) | |||
->create(); | |||
} | |||
} |
@@ -23,10 +23,15 @@ use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; | |||
use EasyCorp\Bundle\EasyAdminBundle\Provider\AdminContextProvider; | |||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||
use EasyCorp\Bundle\EasyAdminBundle\Security\Permission; | |||
use Lc\CaracoleBundle\Container\User\UserMerchantContainer; | |||
use Lc\CaracoleBundle\Controller\AdminControllerTrait; | |||
use Lc\CaracoleBundle\Factory\User\UserFactory; | |||
use Lc\CaracoleBundle\Factory\User\UserMerchantFactory; | |||
use Lc\CaracoleBundle\Form\Credit\CreditHistoryFormType; | |||
use Lc\CaracoleBundle\Form\User\UserMerchantFormType; | |||
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | |||
use Lc\CaracoleBundle\Resolver\MerchantResolver; | |||
use Lc\SovBundle\Container\User\UserContainer; | |||
use Lc\SovBundle\Controller\AbstractAdminController; | |||
use Lc\SovBundle\Field\BooleanField; | |||
use Lc\SovBundle\Field\ToggleField; | |||
@@ -38,14 +43,6 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
{ | |||
use AdminControllerTrait; | |||
protected $em; | |||
protected $translatorAdmin; | |||
public function __construct(EntityManagerInterface $entityManager, TranslatorAdmin $translatorAdmin) | |||
{ | |||
$this->em = $entityManager; | |||
$this->translatorAdmin = $translatorAdmin; | |||
} | |||
public function overrideEntitiesActions(?EntityCollection $entities): void | |||
{ | |||
@@ -53,13 +50,12 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
$adminUrlGenerator = $this->get(AdminUrlGenerator::class); | |||
$creditControllerFqcn = $context->getCrudControllers()->findCrudFqcnByEntityFqcn( | |||
$this->em->getEntityName(CreditHistoryInterface::class) | |||
$this->get(EntityManagerInterface::class)->getEntityName(CreditHistoryInterface::class) | |||
); | |||
if ($entities) { | |||
foreach ($entities as $entity) { | |||
foreach ($entity->getActions() as $action) { | |||
if ($action->getName() == 'credit_history') { | |||
$url = $adminUrlGenerator | |||
->setController($creditControllerFqcn) | |||
@@ -81,7 +77,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
->setHtmlAttributes( | |||
array( | |||
'data-toggle' => 'tooltip', | |||
'title' => $this->translatorAdmin->transAction('credit'), | |||
'title' => $this->get(TranslatorAdmin::class)->transAction('credit'), | |||
) | |||
) | |||
->setCssClass('btn btn-sm btn-success'); | |||
@@ -111,18 +107,17 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
public function configureFilters(Filters $filters): Filters | |||
{ | |||
return $filters | |||
->add(BooleanFilter::new('active')) | |||
; | |||
->add(BooleanFilter::new('active')); | |||
} | |||
public function new(AdminContext $context): Response | |||
{ | |||
$entityManager = $this->get('em'); | |||
$userFactory = $this->get('user_factory'); | |||
$userMerchantFactory = $this->get('user_merchant_factory'); | |||
$userRepository = $entityManager->getRepository(UserInterface::class); | |||
$merchantResolver = $this->get('merchant_resolver'); | |||
$userMerchant = $userMerchantFactory->create(); | |||
$entityManager = $this->get(EntityManagerInterface::class); | |||
$merchantResolver = $this->get(MerchantResolver::class); | |||
$userMerchant = $this->get(UserMerchantContainer::class) | |||
->getFactory() | |||
->create($merchantResolver->getCurrent()); | |||
$form = $this->createForm(UserMerchantFormType::class, $userMerchant); | |||
@@ -131,7 +126,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
if ($form->isSubmitted() && $form->isValid()) { | |||
$userMerchant = $form->getData(); | |||
$existingUser = $userRepository->findOneByEmail($form->get('email')->getData()); | |||
$existingUser = $this->get(UserContainer::class)->getStore()->getOneByEmail($form->get('email')->getData()); | |||
//Le user n'existe pas, on le créer | |||
if ($existingUser == null) { | |||
$param['email'] = $form->get('email')->getData(); | |||
@@ -139,13 +134,15 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
$param['lastname'] = $form->get('firstname')->getData(); | |||
$param['roles'] = array(); | |||
// @TODO : à adapter l'array de valeur passer au factory | |||
$userFactory = new UserFactory(); | |||
$user = $userFactory->create($param); | |||
$entityManager->create($user); | |||
$userMerchant->setUser($user); | |||
$entityManager->create($userMerchant); | |||
$entityManager->flush(); | |||
$this->addFlash('success', $this->get('translator_admin')->trans('form.user_merchant.create')); | |||
$this->addFlash('success', $this->get(TranslatorAdmin::class)->trans('form.user_merchant.create')); | |||
$url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); | |||
return $this->redirect($url); | |||
@@ -157,12 +154,12 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
$entityManager->create($userMerchant); | |||
$entityManager->flush(); | |||
$this->addFlash('success', $this->get('translator_admin')->trans('form.user_merchant.linked')); | |||
$this->addFlash('success', $this->get(TranslatorAdmin::class)->trans('form.user_merchant.linked')); | |||
$url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); | |||
return $this->redirect($url); | |||
} else { | |||
$this->addFlash('error', $this->get('translator_admin')->trans('form.user_merchant.already_exist')); | |||
$this->addFlash('error', $this->get(TranslatorAdmin::class)->trans('form.user_merchant.already_exist')); | |||
} | |||
} | |||
} | |||
@@ -178,9 +175,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
public function edit(AdminContext $context): Response | |||
{ | |||
$entityManager = $this->get('em'); | |||
$userRepository = $entityManager->getRepository(UserInterface::class); | |||
$merchantResolver = $this->get('merchant_resolver'); | |||
$entityManager = $this->get(EntityManagerInterface::class); | |||
$userMerchant = $context->getEntity()->getInstance(); | |||
@@ -198,7 +193,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
$entityManager->update($userMerchant); | |||
$entityManager->update($userMerchant->getUser()); | |||
$entityManager->flush(); | |||
$this->addFlash('success', $this->get('translator_admin')->trans('form.user_merchant.update')); | |||
$this->addFlash('success', $this->get(TranslatorAdmin::class)->trans('form.user_merchant.update')); | |||
$url = $this->get(AdminUrlGenerator::class)->setAction(Action::INDEX)->generateUrl(); | |||
return $this->redirect($url); |
@@ -35,7 +35,6 @@ trait PayoffTrait | |||
*/ | |||
protected $comment; | |||
public function setMeanPayment(?string $meanPayment): self | |||
{ | |||
$this->meanPayment = $meanPayment; | |||
@@ -48,7 +47,6 @@ trait PayoffTrait | |||
return $this->meanPayment; | |||
} | |||
public function getReference(): ?string | |||
{ | |||
return $this->reference; |
@@ -24,13 +24,11 @@ trait PriceTrait | |||
*/ | |||
protected $taxRate; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $buyingPrice; | |||
public function getPriceInherited(): ?float | |||
{ | |||
return $this->getPrice(); |
@@ -73,7 +73,6 @@ trait ProductPropertyTrait | |||
return $this; | |||
} | |||
public function getQuantity(): ?float | |||
{ | |||
return $this->quantity; |
@@ -6,9 +6,6 @@ use Doctrine\ORM\Mapping as ORM; | |||
trait ReductionTrait | |||
{ | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
@@ -24,7 +21,6 @@ trait ReductionTrait | |||
*/ | |||
protected $behaviorTaxRate; | |||
public function getValue(): ?float | |||
{ | |||
return $this->value; |
@@ -3,6 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Factory\Address; | |||
use App\Entity\Address\Address; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
@@ -10,7 +11,7 @@ use Lc\SovBundle\Factory\AbstractFactory; | |||
class AddressFactory extends AbstractFactory | |||
{ | |||
public function create(MerchantInterface $merchant = null): AddressInterface | |||
public function create(MerchantInterface $merchant): AddressInterface | |||
{ | |||
$address = new Address(); | |||
@@ -6,18 +6,19 @@ use App\Entity\File\Document; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | |||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
class DocumentFactory extends AbstractFactory | |||
{ | |||
use MerchantFactoryTrait; | |||
public function create(string $type): DocumentInterface | |||
public function create(SectionInterface $section, string $type): DocumentInterface | |||
{ | |||
$document = new Document(); | |||
$document->setMerchant($this->merchant); | |||
$document->setSection($section); | |||
$document->setType($type); | |||
$document->setTitle(''); | |||
$document->setStatus(1); | |||
@@ -25,4 +26,4 @@ class DocumentFactory extends AbstractFactory | |||
return $document; | |||
} | |||
} | |||
} |
@@ -6,7 +6,7 @@ use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
trait MerchantFactoryTrait | |||
{ | |||
public ?MerchantInterface $merchant = null; | |||
protected MerchantInterface $merchant; | |||
public function setMerchant(MerchantInterface $merchant) | |||
{ | |||
@@ -14,5 +14,4 @@ trait MerchantFactoryTrait | |||
return $this; | |||
} | |||
} |
@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Factory\Order; | |||
use App\Entity\Order\OrderShop; | |||
use Lc\CaracoleBundle\Event\Order\OrderShopChangeStatusEvent; | |||
use Lc\CaracoleBundle\Factory\SectionFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||
@@ -15,16 +16,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; | |||
class OrderShopFactory extends AbstractFactory | |||
{ | |||
protected EventDispatcherInterface $eventDispatcher; | |||
protected OrderStatusHistoryFactory $orderStatusHistoryFactory; | |||
public function __construct( | |||
EventDispatcherInterface $eventDispatcher, | |||
OrderStatusHistoryFactory $orderStatusHistoryFactory | |||
) { | |||
$this->eventDispatcher = $eventDispatcher; | |||
$this->orderStatusHistoryFactory = $orderStatusHistoryFactory; | |||
} | |||
public function create( | |||
SectionInterface $section, |
@@ -3,6 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Factory\PointSale; | |||
use App\Entity\PointSale\PointSale; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; |
@@ -3,6 +3,8 @@ | |||
namespace Lc\CaracoleBundle\Factory\Product; | |||
use App\Entity\Product\ProductCategory; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Factory\SectionFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
@@ -11,11 +13,10 @@ use Lc\SovBundle\Factory\AbstractFactory; | |||
class ProductCategoryFactory extends AbstractFactory | |||
{ | |||
public function create(MerchantInterface $merchant, SectionInterface $section): ProductCategoryInterface | |||
public function create(SectionInterface $section): ProductCategoryInterface | |||
{ | |||
$productCategory = new ProductCategory(); | |||
$productCategory->setMerchant($merchant); | |||
$productCategory->setSection($section); | |||
return $productCategory; |
@@ -12,17 +12,11 @@ use Lc\SovBundle\Factory\AbstractFactory; | |||
class ProductFamilyFactory extends AbstractFactory | |||
{ | |||
use SectionFactoryTrait; | |||
public function create(SectionInterface $section = null): ProductFamilyInterface | |||
public function create(SectionInterface $section): ProductFamilyInterface | |||
{ | |||
$productFamily = new ProductFamily(); | |||
if(is_null($section)) { | |||
$productFamily->setSection($this->section); | |||
}else{ | |||
$productFamily->setSection($section); | |||
} | |||
$productFamily->setSection($section); | |||
return $productFamily; | |||
} |
@@ -3,18 +3,20 @@ | |||
namespace Lc\CaracoleBundle\Factory\Reduction; | |||
use App\Entity\Reduction\ReductionCart; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
class ReductionCartFactory extends AbstractFactory | |||
{ | |||
public function create(MerchantInterface $merchant): ReductionCartInterface | |||
public function create(SectionInterface $section): ReductionCartInterface | |||
{ | |||
$reductionCart = new ReductionCart(); | |||
$reductionCart->setMerchant($merchant); | |||
$reductionCart->setSection($section); | |||
return $reductionCart; | |||
} |
@@ -3,18 +3,20 @@ | |||
namespace Lc\CaracoleBundle\Factory\Reduction; | |||
use App\Entity\Reduction\ReductionCatalog; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
class ReductionCatalogFactory extends AbstractFactory | |||
{ | |||
public function create(MerchantInterface $merchant): ReductionCatalogInterface | |||
public function create(SectionInterface $section): ReductionCatalogInterface | |||
{ | |||
$reductionCatalog = new ReductionCatalog(); | |||
$reductionCatalog->setMerchant($merchant); | |||
$reductionCatalog->setSection($section); | |||
return $reductionCatalog; | |||
} |
@@ -3,18 +3,20 @@ | |||
namespace Lc\CaracoleBundle\Factory\Reduction; | |||
use App\Entity\Reduction\ReductionCredit; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
class ReductionCreditFactory extends AbstractFactory | |||
{ | |||
public function create(MerchantInterface $merchant): ReductionCreditInterface | |||
public function create(SectionInterface $section): ReductionCreditInterface | |||
{ | |||
$reductionCredit = new ReductionCredit(); | |||
$reductionCredit->setMerchant($merchant); | |||
$reductionCredit->setSection($section); | |||
return $reductionCredit; | |||
} |
@@ -2,8 +2,11 @@ | |||
namespace Lc\CaracoleBundle\Factory\Reminder; | |||
use App\Entity\Merchant\Merchant; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Factory\SectionFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\Reminder\ReminderFactory as SovReminderFactory; | |||
use Lc\SovBundle\Model\Reminder\ReminderInterface; | |||
@@ -12,12 +15,16 @@ class ReminderFactory extends SovReminderFactory | |||
use MerchantFactoryTrait; | |||
use SectionFactoryTrait; | |||
public function create(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null): ReminderInterface | |||
{ | |||
public function create( | |||
string $crudAction = null, | |||
string $crudControllerFqcn = null, | |||
int $entityId = null | |||
): ReminderInterface { | |||
$reminder = parent::create($crudAction, $crudControllerFqcn, $entityId); | |||
$reminder->setMerchant($this->merchant) ; | |||
$reminder->setSection($this->section) ; | |||
$reminder->setMerchant($this->merchant); | |||
$reminder->setSection($this->section); | |||
return $reminder; | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Factory\Section; | |||
use App\Entity\Section\Opening; | |||
use Lc\CaracoleBundle\Factory\SectionFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
use Lc\SovBundle\Model\User\GroupUserInterface; | |||
@@ -12,7 +13,7 @@ class OpeningFactory extends AbstractFactory | |||
public function create( | |||
SectionInterface $section, | |||
int $day, | |||
int $day = null, | |||
\DateTime $timeStart = null, | |||
\DateTime $timeEnd = null, | |||
GroupUserInterface $groupUser = null |
@@ -3,6 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Factory\Section; | |||
use App\Entity\Section\Section; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; |
@@ -6,7 +6,7 @@ use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
trait SectionFactoryTrait | |||
{ | |||
public ?SectionInterface $section = null; | |||
protected SectionInterface $section; | |||
public function setSection(SectionInterface $section) | |||
{ | |||
@@ -14,5 +14,4 @@ trait SectionFactoryTrait | |||
return $this; | |||
} | |||
} |
@@ -3,6 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Factory\Site; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\SovBundle\Factory\Site\NewsFactory as SovNewsFactory; | |||
use Lc\SovBundle\Model\Site\NewsInterface; | |||
@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Factory\Site; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Factory\SectionFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\Site\PageFactory as SovPageFactory; | |||
use Lc\SovBundle\Model\Site\PageInterface; | |||
@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Factory\Ticket; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Factory\SectionFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\SovBundle\Factory\Ticket\TicketFactory as SovTicketFactory; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
@@ -3,6 +3,7 @@ | |||
namespace Lc\CaracoleBundle\Factory\User; | |||
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\SovBundle\Model\User\GroupUserInterface; | |||
use Lc\SovBundle\Factory\User\GroupUserFactory as SovGroupUserFactory; | |||
@@ -11,14 +11,12 @@ use Lc\SovBundle\Model\User\UserInterface; | |||
class UserMerchantFactory extends AbstractFactory | |||
{ | |||
use MerchantFactoryTrait; | |||
// createUserMerchant | |||
public function create(UserInterface $user): UserMerchantInterface | |||
public function create(MerchantInterface $merchant, UserInterface $user = null): UserMerchantInterface | |||
{ | |||
$userMerchant = new UserMerchant(); | |||
$userMerchant->setMerchant($this->merchant); | |||
$userMerchant->setMerchant($merchant); | |||
$userMerchant->setUser($user); | |||
return $userMerchant; |
@@ -8,7 +8,7 @@ use Lc\SovBundle\Factory\AbstractFactory; | |||
class VisitorFactory extends AbstractFactory | |||
{ | |||
public function create(string $cookie, string $ip): VisitorInterface | |||
public static function create(string $cookie, string $ip): VisitorInterface | |||
{ | |||
$visitor = new Visitor(); | |||
@@ -91,6 +91,27 @@ abstract class AddressModel extends AbstractLightEntity implements StatusInterfa | |||
*/ | |||
protected $phone; | |||
/** | |||
* @ORM\Column(type="string", length=32, nullable=true) | |||
*/ | |||
protected $latitude; | |||
/** | |||
* @ORM\Column(type="string", length=32, nullable=true) | |||
*/ | |||
protected $longitude; | |||
/** | |||
* @ORM\Column(type="string", length=32, nullable=true) | |||
*/ | |||
protected $latitudeOverride; | |||
/** | |||
* @ORM\Column(type="string", length=32, nullable=true) | |||
*/ | |||
protected $longitudeOverride; | |||
/** | |||
* @ORM\Column(type="text", nullable=true) | |||
*/ | |||
@@ -121,40 +142,6 @@ abstract class AddressModel extends AbstractLightEntity implements StatusInterfa | |||
return $this->getTitle() . ' - ' . $this->getZip() . ' ' . $this->getCity(); | |||
} | |||
// getAddressSummary | |||
public function getSummaryShort() | |||
{ | |||
return $this->getAddress() . ' - ' . $this->getZip() . ' ' . $this->getCity(); | |||
} | |||
public function getSummary($withTitle = true) | |||
{ | |||
$html = ''; | |||
if ($this->getTitle() && $withTitle) { | |||
$html .= $this->getTitle() . '<br />'; | |||
} | |||
if ($this->getLastname() || $this->getFirstname()) { | |||
$html .= $this->getLastname() . ' ' . $this->getFirstname() . '<br />'; | |||
} | |||
if ($this->getAddress()) { | |||
$html .= $this->getAddress() . '<br />'; | |||
} | |||
if ($this->getZip() || $this->getCity()) { | |||
$html .= $this->getZip() . ' ' . $this->getCity() . '<br />'; | |||
} | |||
if ($this->getPhone()) { | |||
foreach ($this->getPhone() as $phone) { | |||
$html .= 'Tél. ' . $phone . '<br />'; | |||
} | |||
} | |||
return $html; | |||
} | |||
public function getUser(): ?UserInterface | |||
{ | |||
@@ -276,6 +263,55 @@ abstract class AddressModel extends AbstractLightEntity implements StatusInterfa | |||
return $this; | |||
} | |||
public function getLatitude(): ?string | |||
{ | |||
return $this->latitude; | |||
} | |||
public function setLatitude(?string $latitude): self | |||
{ | |||
$this->latitude = $latitude; | |||
return $this; | |||
} | |||
public function getLongitude(): ?string | |||
{ | |||
return $this->longitude; | |||
} | |||
public function setLongitude(?string $longitude): self | |||
{ | |||
$this->longitude = $longitude; | |||
return $this; | |||
} | |||
public function getLatitudeOverride(): ?string | |||
{ | |||
return $this->latitudeOverride; | |||
} | |||
public function setLatitudeOverride(?string $latitudeOverride): self | |||
{ | |||
$this->latitudeOverride = $latitudeOverride; | |||
return $this; | |||
} | |||
public function getLongitudeOverride(): ?string | |||
{ | |||
return $this->longitudeOverride; | |||
} | |||
public function setLongitudeOverride(?string $longitudeOverride): self | |||
{ | |||
$this->longitudeOverride = $longitudeOverride; | |||
return $this; | |||
} | |||
public function getCompany(): ?string | |||
{ | |||
return $this->company; |
@@ -9,6 +9,7 @@ use Lc\CaracoleBundle\Model\Order\OrderRefundInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\PayoffInterface; | |||
use Lc\CaracoleBundle\Model\User\UserMerchantInterface; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||
/** | |||
@@ -17,18 +18,17 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||
abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffInterface | |||
{ | |||
use PayoffTrait; | |||
use BlameableNullableTrait; | |||
const TYPE_CREDIT = 'credit'; | |||
const TYPE_DEBIT = 'debit'; | |||
const MEAN_PAYMENT_CREDIT_CARD = 'cb'; | |||
const MEAN_PAYMENT_CHEQUE = 'cheque'; | |||
const MEAN_PAYMENT_CREDIT = 'credit'; | |||
const MEAN_PAYMENT_TRANSFER = 'transfer'; | |||
const MEAN_PAYMENT_CASH = 'cash'; | |||
/**$merchant | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
@@ -55,20 +55,6 @@ abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffI | |||
*/ | |||
protected $orderRefund; | |||
/** | |||
* @Gedmo\Blameable(on="create") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $createdBy; | |||
/** | |||
* @Gedmo\Blameable(on="update") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $updatedBy; | |||
public function __toString(){ | |||
//Todo a écrire | |||
return $this->getType(); |
@@ -11,6 +11,8 @@ use Lc\CaracoleBundle\Model\Address\AddressInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderRefundInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
/** | |||
@@ -18,16 +20,18 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
*/ | |||
abstract class DocumentModel extends AbstractFullEntity implements FilterMerchantInterface | |||
{ | |||
use BlameableNullableTrait; | |||
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\Merchant\MerchantInterface") | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
protected $section; | |||
/** | |||
* @ORM\Column(type="string", length=64) | |||
@@ -82,26 +86,11 @@ abstract class DocumentModel extends AbstractFullEntity implements FilterMerchan | |||
*/ | |||
protected $orderShops; | |||
/** | |||
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"}) | |||
*/ | |||
protected $orderRefund; | |||
/** | |||
* @Gedmo\Blameable(on="create") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $createdBy; | |||
/** | |||
* @Gedmo\Blameable(on="update") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $updatedBy; | |||
public function __construct() | |||
{ | |||
$this->orderShops = new ArrayCollection(); | |||
@@ -112,14 +101,14 @@ abstract class DocumentModel extends AbstractFullEntity implements FilterMerchan | |||
return $this->getReference(); | |||
} | |||
public function getMerchant(): ?MerchantInterface | |||
public function getSection(): ?SectionInterface | |||
{ | |||
return $this->merchant; | |||
return $this->section; | |||
} | |||
public function setMerchant(?MerchantInterface $merchant): self | |||
public function setSection(?SectionInterface $section): self | |||
{ | |||
$this->merchant = $merchant; | |||
$this->section = $section; | |||
return $this; | |||
} |
@@ -37,37 +37,12 @@ abstract class MerchantModel extends AbstractFullEntity | |||
*/ | |||
protected $pointSales; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface", mappedBy="merchant") | |||
*/ | |||
protected $productFamilies; | |||
/** | |||
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="merchant", cascade={"persist", "remove"}) | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $address; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", mappedBy="merchant", orphanRemoval=true) | |||
*/ | |||
protected $productCategories; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\NewsInterface", mappedBy="merchant", orphanRemoval=true) | |||
*/ | |||
protected $news; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\PageInterface", mappedBy="merchant", orphanRemoval=true) | |||
*/ | |||
protected $pages; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", mappedBy="merchant") | |||
*/ | |||
protected $newsletters; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\User\GroupUserInterface", mappedBy="merchant") | |||
*/ | |||
@@ -78,15 +53,10 @@ abstract class MerchantModel extends AbstractFullEntity | |||
*/ | |||
protected $settings; | |||
public function __construct() | |||
{ | |||
$this->pointSales = new ArrayCollection(); | |||
$this->productFamilies = new ArrayCollection(); | |||
$this->productCategories = new ArrayCollection(); | |||
$this->news = new ArrayCollection(); | |||
$this->groupUsers = new ArrayCollection(); | |||
$this->newsletters = new ArrayCollection(); | |||
} | |||
public function __toString() | |||
@@ -134,37 +104,6 @@ abstract class MerchantModel extends AbstractFullEntity | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|ProductFamilyInterface[] | |||
*/ | |||
public function getProductFamilies(): Collection | |||
{ | |||
return $this->productFamilies; | |||
} | |||
public function addProductFamily(ProductFamilyInterface $productFamily): self | |||
{ | |||
if (!$this->productFamilies->contains($productFamily)) { | |||
$this->productFamilies[] = $productFamily; | |||
$productFamily->setMerchant($this); | |||
} | |||
return $this; | |||
} | |||
public function removeProductFamily(ProductFamilyInterface $productFamily): self | |||
{ | |||
if ($this->productFamilies->contains($productFamily)) { | |||
$this->productFamilies->removeElement($productFamily); | |||
// set the owning side to null (unless already changed) | |||
if ($productFamily->getMerchant() === $this) { | |||
$productFamily->setMerchant(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|MerchantSettingInterface[] | |||
*/ | |||
@@ -208,143 +147,6 @@ abstract class MerchantModel extends AbstractFullEntity | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|ProductCategoryInterface[] | |||
*/ | |||
public function getProductCategories(): Collection | |||
{ | |||
return $this->productCategories; | |||
} | |||
public function addProductCategory(ProductCategoryInterface $productCategory): self | |||
{ | |||
if (!$this->productCategories->contains($productCategory)) { | |||
$this->productCategories[] = $productCategory; | |||
$productCategory->setMerchant($this); | |||
} | |||
return $this; | |||
} | |||
public function removeProductCategory(ProductCategoryInterface $productCategory): self | |||
{ | |||
if ($this->productCategories->contains($productCategory)) { | |||
$this->productCategories->removeElement($productCategory); | |||
// set the owning side to null (unless already changed) | |||
if ($productCategory->getMerchant() === $this) { | |||
$productCategory->setMerchant(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|NewsInterface[] | |||
*/ | |||
public function getNews(): Collection | |||
{ | |||
return $this->news; | |||
} | |||
public function addNews(NewsInterface $news): self | |||
{ | |||
if (!$this->news->contains($news)) { | |||
$this->news[] = $news; | |||
$news->setMerchant($this); | |||
} | |||
return $this; | |||
} | |||
public function removeNews(NewsInterface $news): self | |||
{ | |||
if ($this->news->contains($news)) { | |||
$this->news->removeElement($news); | |||
// set the owning side to null (unless already changed) | |||
if ($news->getMerchant() === $this) { | |||
$news->setMerchant(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|PageInterface[] | |||
*/ | |||
public function getPages(): Collection | |||
{ | |||
return $this->pages; | |||
} | |||
public function addPage(PageInterface $page): self | |||
{ | |||
if (!$this->pages->contains($page)) { | |||
$this->pages[] = $page; | |||
$page->setMerchant($this); | |||
} | |||
return $this; | |||
} | |||
public function removePage(PageInterface $page): self | |||
{ | |||
if ($this->pages->contains($page)) { | |||
$this->pages->removeElement($page); | |||
// set the owning side to null (unless already changed) | |||
if ($page->getMerchant() === $this) { | |||
$page->setMerchant(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|NewsletterInterface[] | |||
*/ | |||
public function getNewsletters(): Collection | |||
{ | |||
return $this->newsletters; | |||
} | |||
public function addNewsletter(NewsletterInterface $newsletter): self | |||
{ | |||
if (!$this->newsletters->contains($newsletter)) { | |||
$this->newsletters[] = $newsletter; | |||
$newsletter->setMerchant($this); | |||
} | |||
return $this; | |||
} | |||
public function removeNewsletter(NewsletterInterface $newsletter): self | |||
{ | |||
if ($this->newsletters->contains($newsletter)) { | |||
$this->newsletters->removeElement($newsletter); | |||
// set the owning side to null (unless already changed) | |||
if ($newsletter->getMerchant() === $this) { | |||
$newsletter->setMerchant(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
public function getNewsletter() | |||
{ | |||
$newsletters = $this->getNewsletters(); | |||
foreach ($newsletters as $newsletter) { | |||
if ($newsletter->getIsMain()) { | |||
return $newsletter; | |||
} | |||
} | |||
return false; | |||
} | |||
/** | |||
* @return Collection|GroupUserInterface[] | |||
*/ |
@@ -19,7 +19,6 @@ abstract class NewsletterModel extends SovNewsletterModel implements FilterSecti | |||
*/ | |||
protected $section; | |||
public function getSection(): ?SectionInterface | |||
{ | |||
return $this->section; |
@@ -28,29 +28,4 @@ abstract class OrderProductReductionCatalogModel | |||
return $this; | |||
} | |||
// getSummaryOrderProductReductionCatalog | |||
public function getSummary() | |||
{ | |||
$text = ''; | |||
if ($this->getUnit() == 'amount') { | |||
$text .= '- ' . $this->getValue() . ' €'; | |||
} | |||
if ($this->getUnit() == 'percent') { | |||
$text .= '- ' . $this->getValue() . ' %'; | |||
} | |||
return $text; | |||
} | |||
// compareOrderProductReductionCatalog | |||
public function compare($orderProductReductionCatalog) | |||
{ | |||
return $orderProductReductionCatalog | |||
&& $this->getUnit() == $orderProductReductionCatalog->getUnit() | |||
&& (string)$this->getValue() == (string)$orderProductReductionCatalog->getValue() | |||
&& $this->getBehaviorTaxRate() == $orderProductReductionCatalog->getBehaviorTaxRate(); | |||
} | |||
} |
@@ -28,13 +28,17 @@ abstract class OrderReductionCartModel implements ReductionInterface, ReductionC | |||
*/ | |||
protected $orderShop; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $reductionCart; | |||
/** | |||
* @ORM\Column(type="string", length=255, nullable=true) | |||
*/ | |||
protected $codeUsed; | |||
public function __toString() | |||
{ | |||
return $this->title; | |||
@@ -75,6 +79,17 @@ abstract class OrderReductionCartModel implements ReductionInterface, ReductionC | |||
return $this; | |||
} | |||
public function getCodeUsed(): ?string | |||
{ | |||
return $this->codeUsed; | |||
} | |||
public function setCodeUsed(?string $codeUsed): self | |||
{ | |||
$this->codeUsed = $codeUsed; | |||
return $this; | |||
} | |||
} |
@@ -19,7 +19,6 @@ abstract class OrderReductionCreditModel implements ReductionInterface | |||
*/ | |||
protected $title; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", inversedBy="orderReductionCredits") | |||
* @ORM\JoinColumn(nullable=false) | |||
@@ -32,13 +31,11 @@ abstract class OrderReductionCreditModel implements ReductionInterface | |||
*/ | |||
protected $reductionCredit; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $type; | |||
public function __toString() | |||
{ | |||
return $this->title; |
@@ -8,12 +8,11 @@ use Gedmo\Mapping\Annotation as Gedmo; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Model\Address\AddressInterface; | |||
use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface; | |||
use Lc\CaracoleBundle\Model\Config\TaxRateInterface; | |||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | |||
use Lc\CaracoleBundle\Model\File\DocumentModel; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
use Lc\CaracoleBundle\Model\User\VisitorInterface; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||
@@ -24,8 +23,13 @@ use Lc\SovBundle\Model\User\UserInterface; | |||
*/ | |||
abstract class OrderShopModel extends AbstractLightEntity implements FilterSectionInterface | |||
{ | |||
use BlameableNullableTrait; | |||
const DELIVERY_TYPE_HOME = 'home'; | |||
const DELIVERY_TYPE_POINTSALE = 'point-sale'; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orders", fetch="EAGER") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orderShops", fetch="EAGER") | |||
*/ | |||
protected $user; | |||
@@ -54,11 +58,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
*/ | |||
protected $comment; | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $autoPayment; | |||
/** | |||
* @ORM\Column(type="string", length=31, nullable=true) | |||
*/ | |||
@@ -105,20 +104,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
*/ | |||
protected $documents; | |||
/** | |||
* @Gedmo\Blameable(on="create") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $createdBy; | |||
/** | |||
* @Gedmo\Blameable(on="update") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $updatedBy; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Ticket\TicketInterface", mappedBy="orderShop") | |||
*/ | |||
@@ -135,103 +120,134 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
*/ | |||
protected $cycleId; | |||
public function __construct() | |||
{ | |||
$this->orderStatusHistories = new ArrayCollection(); | |||
$this->orderPayments = new ArrayCollection(); | |||
$this->orderProducts = new ArrayCollection(); | |||
$this->creditHistories = new ArrayCollection(); | |||
$this->orderReductionCarts = new ArrayCollection(); | |||
$this->orderReductionCredits = new ArrayCollection(); | |||
$this->documents = new ArrayCollection(); | |||
} | |||
/** | |||
* @ORM\Column(type="integer", nullable=true) | |||
*/ | |||
protected $cycleNumber; | |||
public function __toString() | |||
{ | |||
if ($this->getValidationDate()) { | |||
return 'Commande du ' . $this->getValidationDate()->format('d/m/Y'); | |||
} else { | |||
return 'Commande #' . $this->getId(); | |||
} | |||
} | |||
/** | |||
* @ORM\Column(type="datetime", nullable=true) | |||
*/ | |||
protected $orderShopCreatedAt; | |||
public function countQuantities() | |||
{ | |||
return self::countQuantitiesByOrderProducts($this->getOrderProducts()); | |||
} | |||
/** | |||
* @ORM\Column(type="integer", nullable=true) | |||
*/ | |||
protected $idValidOrder; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="App\Entity\Address\Address") | |||
*/ | |||
protected $deliveryAddress; | |||
public static function countQuantitiesByOrderProducts($orderProducts = []) | |||
{ | |||
$count = 0; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="App\Entity\PointSale\PointSale") | |||
*/ | |||
protected $deliveryPointSale; | |||
foreach ($orderProducts as $orderProduct) { | |||
$count += $orderProduct->getQuantityOrder(); | |||
} | |||
/** | |||
* @ORM\Column(type="text", nullable=true) | |||
*/ | |||
protected $deliveryAddressText; | |||
return $count; | |||
} | |||
/** | |||
* @ORM\Column(type="string", length=255, nullable=true) | |||
*/ | |||
protected $deliveryType; | |||
public function getOrderProductsByParentCategory() | |||
{ | |||
$categoriesArray = []; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $deliveryPrice; | |||
foreach ($this->getOrderProducts() as $orderProduct) { | |||
$productCategories = $orderProduct->getProduct()->getProductFamily()->getProductCategories(); | |||
$category = $productCategories[0]->getParentCategory(); | |||
$labelCategory = $category->getTitle(); | |||
if (!isset($categoriesArray[$labelCategory])) { | |||
$categoriesArray[$labelCategory] = []; | |||
} | |||
$categoriesArray[$labelCategory][] = $orderProduct; | |||
} | |||
/** | |||
* @ORM\ManyToOne(targetEntity="App\Entity\Config\TaxRate") | |||
*/ | |||
protected $deliveryTaxRate; | |||
return $categoriesArray; | |||
} | |||
/** | |||
* @ORM\Column(type="string", length=20, nullable=true) | |||
*/ | |||
protected $reference; | |||
public function hasOrderProductAlreadyInCart($orderProductTest) | |||
{ | |||
foreach ($this->getOrderProducts() as $orderProduct) { | |||
if ($orderProduct->getProduct() == $orderProductTest->getProduct()) { | |||
return $orderProduct; | |||
} | |||
} | |||
/** | |||
* @ORM\ManyToOne(targetEntity="App\Entity\Order\OrderShop", inversedBy="complementaryOrderShops") | |||
*/ | |||
protected $mainOrderShop; | |||
return false; | |||
} | |||
/** | |||
* @ORM\OneToMany(targetEntity="App\Entity\Order\OrderShop", mappedBy="mainOrderShop") | |||
*/ | |||
protected $complementaryOrderShops; | |||
public function getOrderProductsByProductFamily($productFamily) | |||
{ | |||
$arrayOrderProducts = []; | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $declineComplementaryOrderShop; | |||
foreach ($this->getOrderProducts() as $orderProduct) { | |||
if ($orderProduct->getProduct()->getProductFamily() == $productFamily) { | |||
$arrayOrderProducts[] = $orderProduct; | |||
} | |||
} | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $orderAllowByAdmin; | |||
return $arrayOrderProducts; | |||
} | |||
/** | |||
* @ORM\Column(type="integer", nullable=true) | |||
*/ | |||
protected $hasReach; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $statTotal; | |||
public function getQuantityOrderByProduct(ProductInterface $product, $byWeight = false) | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $statTotalWithTax; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $statTotalOrderProductsWithReductions; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $statTotalOrderProductsWithTaxAndReductions; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $statMarginOrderProductsWithReductions; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $statDeliveryPriceWithReduction; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $statDeliveryPriceWithTaxAndReduction; | |||
public function __construct() | |||
{ | |||
$quantity = 0; | |||
$productFamily = $product->getProductFamily(); | |||
$behaviorCountStock = $productFamily->getBehaviorCountStock(); | |||
$this->orderStatusHistories = new ArrayCollection(); | |||
$this->orderPayments = new ArrayCollection(); | |||
$this->orderProducts = new ArrayCollection(); | |||
$this->orderReductionCarts = new ArrayCollection(); | |||
$this->orderReductionCredits = new ArrayCollection(); | |||
$this->documents = new ArrayCollection(); | |||
$this->complementaryOrderShops = new ArrayCollection(); | |||
$this->tickets = new ArrayCollection(); | |||
} | |||
foreach ($this->getOrderProducts() as $orderProduct) { | |||
if ($orderProduct->getProduct()->getId() == $product->getId() | |||
|| (($behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY || $behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE) | |||
&& $orderProduct->getProduct()->getProductFamily()->getId() == $productFamily->getId())) { | |||
if ($byWeight) { | |||
$quantity += $orderProduct->getQuantityOrder() * ($orderProduct->getQuantityProduct( | |||
) / $orderProduct->getProduct()->getUnitInherited()->getCoefficient()); | |||
} else { | |||
$quantity += $orderProduct->getQuantityOrder(); | |||
} | |||
} | |||
public function __toString() | |||
{ | |||
if ($this->getValidationDate()) { | |||
return 'Commande du ' . $this->getValidationDate()->format('d/m/Y'); | |||
} else { | |||
return 'Commande #' . $this->getId(); | |||
} | |||
return $quantity; | |||
} | |||
public function getValidationDate(): ?\DateTimeInterface | |||
@@ -246,30 +262,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
return $this; | |||
} | |||
public function getDateCreated() | |||
{ | |||
$orderStatusHistory = $this->getOrderStatusHistory(OrderStatusModel::ALIAS_WAITING_DELIVERY); | |||
if ($orderStatusHistory) { | |||
return $orderStatusHistory->getCreatedAt(); | |||
} | |||
return null; | |||
} | |||
public function getOrderStatusHistory($status) | |||
{ | |||
$orderStatusHistories = $this->getOrderStatusHistories(); | |||
if (count($orderStatusHistories) > 0) { | |||
foreach ($orderStatusHistories as $orderStatusHistory) { | |||
if ($orderStatusHistory->getOrderStatus() == $status) { | |||
return $orderStatusHistory; | |||
} | |||
} | |||
} | |||
return null; | |||
} | |||
public function getUser(): ?UserInterface | |||
{ | |||
return $this->user; | |||
@@ -318,18 +310,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
return $this; | |||
} | |||
public function getAutoPayment(): ?bool | |||
{ | |||
return $this->autoPayment; | |||
} | |||
public function setAutoPayment(bool $autoPayment): self | |||
{ | |||
$this->autoPayment = $autoPayment; | |||
return $this; | |||
} | |||
public function getMeanPayment(): ?string | |||
{ | |||
return $this->meanPayment; | |||
@@ -447,37 +427,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|CreditHistoryInterface[] | |||
*/ | |||
public function getCreditHistories(): Collection | |||
{ | |||
return $this->creditHistories; | |||
} | |||
public function addCreditHistory(CreditHistoryInterface $creditHistory): self | |||
{ | |||
if (!$this->creditHistories->contains($creditHistory)) { | |||
$this->creditHistories[] = $creditHistory; | |||
$creditHistory->setOrderShop($this); | |||
} | |||
return $this; | |||
} | |||
public function removeCreditHistory(CreditHistoryInterface $creditHistory): self | |||
{ | |||
if ($this->creditHistories->contains($creditHistory)) { | |||
$this->creditHistories->removeElement($creditHistory); | |||
// set the owning side to null (unless already changed) | |||
if ($creditHistory->getOrderShop() === $this) { | |||
$creditHistory->setOrderShop(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
public function getVisitor(): ?VisitorInterface | |||
{ | |||
return $this->visitor; | |||
@@ -515,7 +464,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|OrderReductionCartInterface[] | |||
*/ | |||
@@ -604,17 +552,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
return $this; | |||
} | |||
public function getDocumentInvoice(): DocumentInterface | |||
{ | |||
foreach ($this->getDocuments() as $document) { | |||
if ($document->getType() == DocumentModel::TYPE_INVOICE) { | |||
return $document; | |||
} | |||
} | |||
return false; | |||
} | |||
/** | |||
* @return Collection|TicketInterface[] | |||
*/ | |||
@@ -646,52 +583,318 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
return $this; | |||
} | |||
public function isValid() | |||
public function getSection(): ?SectionInterface | |||
{ | |||
return $this->section; | |||
} | |||
public function setSection(?SectionInterface $section): self | |||
{ | |||
$this->section = $section; | |||
return $this; | |||
} | |||
public function getCycleId(): ?int | |||
{ | |||
return $this->cycleId; | |||
} | |||
public function setCycleId(?int $cycleId): self | |||
{ | |||
$this->cycleId = $cycleId; | |||
return $this; | |||
} | |||
public function getCycleNumber(): ?int | |||
{ | |||
return $this->cycleNumber; | |||
} | |||
public function setCycleNumber(?int $cycleNumber): self | |||
{ | |||
$this->cycleNumber = $cycleNumber; | |||
return $this; | |||
} | |||
public function getOrderShopCreatedAt(): ?\DateTimeInterface | |||
{ | |||
return $this->orderShopCreatedAt; | |||
} | |||
public function setOrderShopCreatedAt(?\DateTimeInterface $orderShopCreatedAt): self | |||
{ | |||
$this->orderShopCreatedAt = $orderShopCreatedAt; | |||
return $this; | |||
} | |||
public function getIdValidOrder(): ?int | |||
{ | |||
return $this->idValidOrder; | |||
} | |||
public function setIdValidOrder(?int $idValidOrder): self | |||
{ | |||
$this->idValidOrder = $idValidOrder; | |||
return $this; | |||
} | |||
public function getDeliveryAddress(): ?AddressInterface | |||
{ | |||
if ($this->getOrderStatus() && in_array( | |||
$this->getOrderStatus()->getAlias(), | |||
OrderStatusModel::$statusAliasAsValid | |||
) > 0) { | |||
return true; | |||
return $this->deliveryAddress; | |||
} | |||
public function setDeliveryAddress(?AddressInterface $deliveryAddress): self | |||
{ | |||
$this->deliveryAddress = $deliveryAddress; | |||
return $this; | |||
} | |||
public function getDeliveryAddressText(): ?string | |||
{ | |||
return $this->deliveryAddressText; | |||
} | |||
public function setDeliveryAddressText(string $deliveryAddressText): self | |||
{ | |||
$this->deliveryAddressText = $deliveryAddressText; | |||
return $this; | |||
} | |||
public function getDeliveryPointSale(): ?PointSaleInterface | |||
{ | |||
return $this->deliveryPointSale; | |||
} | |||
public function setDeliveryPointSale(?PointSaleInterface $deliveryPointSale): self | |||
{ | |||
$this->deliveryPointSale = $deliveryPointSale; | |||
return $this; | |||
} | |||
public function getDeliveryType(): ?string | |||
{ | |||
return $this->deliveryType; | |||
} | |||
public function setDeliveryType(?string $deliveryType): self | |||
{ | |||
$this->deliveryType = $deliveryType; | |||
return $this; | |||
} | |||
public function getDeliveryPrice(): ?float | |||
{ | |||
return $this->deliveryPrice; | |||
} | |||
public function setDeliveryPrice(?float $deliveryPrice): self | |||
{ | |||
$this->deliveryPrice = $deliveryPrice; | |||
return $this; | |||
} | |||
public function getDeliveryTaxRate(): ?TaxRateInterface | |||
{ | |||
return $this->deliveryTaxRate; | |||
} | |||
public function setDeliveryTaxRate(?TaxRateInterface $deliveryTaxRate): self | |||
{ | |||
$this->deliveryTaxRate = $deliveryTaxRate; | |||
return $this; | |||
} | |||
public function getReference(): ?string | |||
{ | |||
return $this->reference; | |||
} | |||
public function setReference(?string $reference): self | |||
{ | |||
$this->reference = $reference; | |||
return $this; | |||
} | |||
public function getMainOrderShop(): ?self | |||
{ | |||
return $this->mainOrderShop; | |||
} | |||
public function setMainOrderShop(?self $mainOrderShop): self | |||
{ | |||
$this->mainOrderShop = $mainOrderShop; | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|OrderShopInterface[] | |||
*/ | |||
public function getComplementaryOrderShops(): Collection | |||
{ | |||
$arrayComplementaryOrderShops = new ArrayCollection(); | |||
foreach ($this->complementaryOrderShops as $complementaryOrderShop) { | |||
if ($complementaryOrderShop->isValid()) { | |||
$arrayComplementaryOrderShops[] = $complementaryOrderShop; | |||
} | |||
} | |||
return $arrayComplementaryOrderShops; | |||
} | |||
return false; | |||
public function addComplementaryOrderShop(self $complementaryOrderShop): self | |||
{ | |||
if (!$this->complementaryOrderShops->contains($complementaryOrderShop)) { | |||
$this->complementaryOrderShops[] = $complementaryOrderShop; | |||
$complementaryOrderShop->setMainOrderShop($this); | |||
} | |||
return $this; | |||
} | |||
public function isCart() | |||
public function removeComplementaryOrderShop(self $complementaryOrderShop): self | |||
{ | |||
if ($this->getOrderStatus() && in_array( | |||
$this->getOrderStatus()->getAlias(), | |||
OrderStatusModel::$statusAliasAsCart | |||
) > 0) { | |||
return true; | |||
if ($this->complementaryOrderShops->contains($complementaryOrderShop)) { | |||
$this->complementaryOrderShops->removeElement($complementaryOrderShop); | |||
// set the owning side to null (unless already changed) | |||
if ($complementaryOrderShop->getMainOrderShop() === $this) { | |||
$complementaryOrderShop->setMainOrderShop(null); | |||
} | |||
} | |||
return false; | |||
return $this; | |||
} | |||
public function getSection(): ?SectionInterface | |||
public function getDeclineComplementaryOrderShop(): ?bool | |||
{ | |||
return $this->section; | |||
return $this->declineComplementaryOrderShop; | |||
} | |||
public function setSection(?SectionInterface $section): self | |||
public function setDeclineComplementaryOrderShop(?bool $declineComplementaryOrderShop): self | |||
{ | |||
$this->section = $section; | |||
$this->declineComplementaryOrderShop = $declineComplementaryOrderShop; | |||
return $this; | |||
} | |||
public function getCycleId(): ?int | |||
public function getOrderAllowByAdmin(): ?bool | |||
{ | |||
return $this->cycleId; | |||
return $this->orderAllowByAdmin; | |||
} | |||
public function setCycleId(?int $cycleId): self | |||
public function setOrderAllowByAdmin(?bool $orderAllowByAdmin): self | |||
{ | |||
$this->cycleId = $cycleId; | |||
$this->orderAllowByAdmin = $orderAllowByAdmin; | |||
return $this; | |||
} | |||
public function getHasReach(): ?int | |||
{ | |||
return $this->hasReach; | |||
} | |||
public function setHasReach(?int $hasReach): self | |||
{ | |||
$this->hasReach = $hasReach; | |||
return $this; | |||
} | |||
public function getStatTotal(): ?float | |||
{ | |||
return $this->statTotal; | |||
} | |||
public function setStatTotal(?float $statTotal): self | |||
{ | |||
$this->statTotal = $statTotal; | |||
return $this; | |||
} | |||
public function getStatTotalWithTax(): ?float | |||
{ | |||
return $this->statTotalWithTax; | |||
} | |||
public function setStatTotalWithTax(?float $statTotalWithTax): self | |||
{ | |||
$this->statTotalWithTax = $statTotalWithTax; | |||
return $this; | |||
} | |||
public function getStatTotalOrderProductsWithReductions(): ?float | |||
{ | |||
return $this->statTotalOrderProductsWithReductions; | |||
} | |||
public function setStatTotalOrderProductsWithReductions(?float $statTotalOrderProductsWithReductions): self | |||
{ | |||
$this->statTotalOrderProductsWithReductions = $statTotalOrderProductsWithReductions; | |||
return $this; | |||
} | |||
public function getStatTotalOrderProductsWithTaxAndReductions(): ?float | |||
{ | |||
return $this->statTotalOrderProductsWithTaxAndReductions; | |||
} | |||
public function setStatTotalOrderProductsWithTaxAndReductions(?float $statTotalOrderProductsWithTaxAndReductions): self | |||
{ | |||
$this->statTotalOrderProductsWithTaxAndReductions = $statTotalOrderProductsWithTaxAndReductions; | |||
return $this; | |||
} | |||
public function getStatMarginOrderProductsWithReductions(): ?float | |||
{ | |||
return $this->statMarginOrderProductsWithReductions; | |||
} | |||
public function setStatMarginOrderProductsWithReductions(?float $statMarginOrderProductsWithReductions): self | |||
{ | |||
$this->statMarginOrderProductsWithReductions = $statMarginOrderProductsWithReductions; | |||
return $this; | |||
} | |||
public function getStatDeliveryPriceWithReduction(): ?float | |||
{ | |||
return $this->statDeliveryPriceWithReduction; | |||
} | |||
public function setStatDeliveryPriceWithReduction(?float $statDeliveryPriceWithReduction): self | |||
{ | |||
$this->statDeliveryPriceWithReduction = $statDeliveryPriceWithReduction; | |||
return $this; | |||
} | |||
public function getStatDeliveryPriceWithTaxAndReduction(): ?float | |||
{ | |||
return $this->statDeliveryPriceWithTaxAndReduction; | |||
} | |||
public function setStatDeliveryPriceWithTaxAndReduction(?float $statDeliveryPriceWithTaxAndReduction): self | |||
{ | |||
$this->statDeliveryPriceWithTaxAndReduction = $statDeliveryPriceWithTaxAndReduction; | |||
return $this; | |||
} | |||
} |
@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Model\Order; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||
@@ -12,6 +13,8 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||
*/ | |||
abstract class OrderStatusHistoryModel extends AbstractLightEntity | |||
{ | |||
use BlameableNullableTrait; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", inversedBy="orderStatusHistories") | |||
* @ORM\JoinColumn(nullable=false) | |||
@@ -33,20 +36,6 @@ abstract class OrderStatusHistoryModel extends AbstractLightEntity | |||
*/ | |||
protected $origin; | |||
/** | |||
* @Gedmo\Blameable(on="create") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $createdBy; | |||
/** | |||
* @Gedmo\Blameable(on="update") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $updatedBy; | |||
public function __toString() | |||
{ | |||
return $this->getOrderStatus()->getAlias() . ' le : ' . $this->getCreatedAt()->format( |
@@ -27,7 +27,6 @@ abstract class OrderStatusModel implements EntityInterface | |||
const ALIAS_CANCELED_WAITING_REFUND = 'canceled-waiting-refund'; | |||
const ALIAS_REFUND = 'refund'; | |||
//TODO : AJOUTER un champ valid ds orderSTATUS | |||
static $statusAliasAsValid = [ | |||
self::ALIAS_PAID, | |||
@@ -70,6 +69,11 @@ abstract class OrderStatusModel implements EntityInterface | |||
*/ | |||
protected $alias; | |||
/** | |||
* @ORM\Column(type="string", length=255, nullable=true) | |||
*/ | |||
protected $color; | |||
public function __toString() | |||
{ | |||
return $this->title . ' [' . $this->alias . ']'; | |||
@@ -142,5 +146,15 @@ abstract class OrderStatusModel implements EntityInterface | |||
return $this; | |||
} | |||
public function getColor(): ?string | |||
{ | |||
return $this->color; | |||
} | |||
public function setColor(?string $color): self | |||
{ | |||
$this->color = $color; | |||
return $this; | |||
} | |||
} |
@@ -33,6 +33,16 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip | |||
*/ | |||
protected $code; | |||
/** | |||
* @ORM\Column(type="float") | |||
*/ | |||
protected $deliveryPrice; | |||
/** | |||
* @ORM\Column(type="boolean") | |||
*/ | |||
protected $isPublic; | |||
/** | |||
* @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Address\AddressInterface", inversedBy="pointSale", cascade={"persist", "remove"}) | |||
* @ORM\JoinColumn(nullable=false) | |||
@@ -60,11 +70,6 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip | |||
return $this->getTitle(); | |||
} | |||
public function labelAdminChoice() | |||
{ | |||
return $this->getTitle(); | |||
} | |||
/** | |||
* @return Collection|MerchantInterface[] | |||
*/ | |||
@@ -103,6 +108,31 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip | |||
return $this; | |||
} | |||
public function getDeliveryPrice(): ?float | |||
{ | |||
return $this->deliveryPrice; | |||
} | |||
public function setDeliveryPrice(float $deliveryPrice): self | |||
{ | |||
$this->deliveryPrice = $deliveryPrice; | |||
return $this; | |||
} | |||
public function getIsPublic(): ?bool | |||
{ | |||
return $this->isPublic; | |||
} | |||
public function setIsPublic(bool $isPublic): self | |||
{ | |||
$this->isPublic = $isPublic; | |||
return $this; | |||
} | |||
public function getAddress(): ?AddressInterface | |||
{ | |||
return $this->address; |
@@ -15,7 +15,6 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
*/ | |||
abstract class ProductCategoryModel extends AbstractFullEntity implements TreeInterface, FilterSectionInterface | |||
{ | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
@@ -43,7 +42,6 @@ abstract class ProductCategoryModel extends AbstractFullEntity implements TreeIn | |||
*/ | |||
protected $saleStatus; | |||
public function __construct() | |||
{ | |||
$this->childrens = new ArrayCollection(); | |||
@@ -70,7 +68,6 @@ abstract class ProductCategoryModel extends AbstractFullEntity implements TreeIn | |||
return $this; | |||
} | |||
public function getParent(): ?self | |||
{ | |||
return $this->parent; | |||
@@ -97,13 +94,14 @@ abstract class ProductCategoryModel extends AbstractFullEntity implements TreeIn | |||
*/ | |||
public function getChildrens(): Collection | |||
{ | |||
//TODO les lignes ci-dessous ne devraient pas exister, sert à résoudre le problème d'ordre dans le menu | |||
// @TODO : les lignes ci-dessous ne devraient pas exister, sert à résoudre le problème d'ordre dans le menu | |||
$iterator = $this->childrens->getIterator(); | |||
$iterator->uasort( | |||
function ($a, $b) { | |||
return ($a->getPosition() < $b->getPosition()) ? -1 : 1; | |||
} | |||
); | |||
return new ArrayCollection(iterator_to_array($iterator)); | |||
} | |||
@@ -12,7 +12,9 @@ use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
use Lc\SovBundle\Model\File\FileInterface; | |||
/** | |||
@@ -21,8 +23,8 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
abstract class ProductFamilyModel extends AbstractFullEntity implements ProductPropertyInterface, PriceInterface, | |||
FilterSectionInterface | |||
{ | |||
use ProductPropertyTrait; | |||
use BlameableNullableTrait; | |||
const BEHAVIOR_COUNT_STOCK_UNLIMITED = 'unlimited'; | |||
const BEHAVIOR_COUNT_STOCK_BY_MEASURE = 'by-measure'; | |||
@@ -39,8 +41,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
]; | |||
} | |||
const BEHAVIOR_DISPLAY_SALE_BY_MEASURE = 'by-measure'; | |||
const BEHAVIOR_DISPLAY_SALE_BY_QUANTITY = 'by-quantity'; | |||
@@ -52,21 +52,19 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
]; | |||
} | |||
const BEHAVIOR_STOCK_CYCLE_RENEWABLE = 'renewable'; | |||
const BEHAVIOR_STOCK_CYCLE_RENEWABLE_VALIDATION = 'renewable-with-validation'; | |||
const BEHAVIOR_STOCK_CYCLE_NON_RENEWABLE = 'non-renewable'; | |||
const BEHAVIOR_STOCK_WEEK_RENEWABLE = 'renewable'; | |||
const BEHAVIOR_STOCK_WEEK_RENEWABLE_VALIDATION = 'renewable-with-validation'; | |||
const BEHAVIOR_STOCK_WEEK_NON_RENEWABLE = 'non-renewable'; | |||
public function getBehaviorStockWeekChoices(): array | |||
public function getBehaviorStockCycleChoices(): array | |||
{ | |||
return [ | |||
self::BEHAVIOR_STOCK_WEEK_NON_RENEWABLE, | |||
self::BEHAVIOR_STOCK_WEEK_RENEWABLE, | |||
self::BEHAVIOR_STOCK_WEEK_RENEWABLE_VALIDATION, | |||
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'; | |||
@@ -81,6 +79,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
self::WARNING_MESSAGE_TYPE_WARNING, | |||
]; | |||
} | |||
const BEHAVIOR_ADD_TO_CART_SIMPLE = 'simple'; | |||
const BEHAVIOR_ADD_TO_CART_MULTIPLE = 'multiple'; | |||
@@ -91,6 +90,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
self::BEHAVIOR_ADD_TO_CART_SIMPLE, | |||
]; | |||
} | |||
const BEHAVIOR_PRICE_BY_PIECE = 'by-piece'; | |||
const BEHAVIOR_PRICE_BY_REFERENCE_UNIT = 'by-reference-unit'; | |||
@@ -101,6 +101,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
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'; | |||
@@ -116,7 +117,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
]; | |||
} | |||
const TYPE_EXPIRATION_DATE_DLC = 'dlc'; | |||
const TYPE_EXPIRATION_DATE_DDM = 'ddm'; | |||
const TYPE_EXPIRATION_DATE_DLUO = 'dluo'; | |||
@@ -130,36 +130,20 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
]; | |||
} | |||
const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY = 'by-product-family'; | |||
const BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT = 'by-product'; | |||
public function getBehaviorExpirationDateChoices():array{ | |||
public function getBehaviorExpirationDateChoices(): array | |||
{ | |||
return [ | |||
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT_FAMILY, | |||
self::BEHAVIOR_EXPIRATION_DATE_BY_PRODUCT | |||
]; | |||
} | |||
//Champ hydraté par ProductFamilyUtils | |||
// @TODO : Champ hydraté par ProductFamilyBuilder ? | |||
protected $reductionCatalog; | |||
/** | |||
* @Gedmo\Blameable(on="create") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $createdBy; | |||
/** | |||
* @Gedmo\Blameable(on="update") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $updatedBy; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductCategoryInterface", inversedBy="productFamilies") | |||
*/ | |||
@@ -221,11 +205,31 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
*/ | |||
protected $behaviorCountStock; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $behaviorStockWeek; | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $availabilityRenewedThisWeek; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
protected $behaviorDisplaySale; | |||
/** | |||
* @ORM\Column(type="string", length=255, nullable=true) | |||
*/ | |||
protected $exportTitle; | |||
/** | |||
* @ORM\Column(type="text", nullable=true) | |||
*/ | |||
protected $exportNote; | |||
/** | |||
* @ORM\Column(type="date", nullable=true) | |||
*/ | |||
@@ -312,13 +316,17 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
*/ | |||
protected $saleStatus; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $section; | |||
/** | |||
* @ORM\ManyToOne((targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"}) | |||
*/ | |||
protected $image; | |||
public function __construct() | |||
{ | |||
$this->productCategories = new ArrayCollection(); | |||
@@ -342,6 +350,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function getAvailableQuantityInherited() | |||
{ | |||
$availableQuantity = 0; | |||
@@ -368,6 +377,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $availableQuantity; | |||
} | |||
//TODO move | |||
public function getTaxRateInherited() | |||
{ | |||
if ($this->getTaxRate()) { | |||
@@ -376,6 +386,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this->getSection()->getMerchant()->getTaxRate(); | |||
} | |||
} | |||
public function getActiveProducts(): ?bool | |||
{ | |||
return $this->activeProducts; | |||
@@ -432,6 +443,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this->products; | |||
} | |||
//TODO move | |||
public function getProductsOnline(): Collection | |||
{ | |||
$products = $this->getProducts(); | |||
@@ -474,6 +486,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this->reductionCatalog; | |||
} | |||
//TODO move | |||
public function getReductionCatalogInherited(): ?ReductionCatalogInterface | |||
{ | |||
return $this->getReductionCatalog(); | |||
@@ -517,6 +530,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function getProductCategoryParent() | |||
{ | |||
$productCategories = $this->getProductCategories(); | |||
@@ -528,6 +542,8 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return false; | |||
} | |||
//TODO move | |||
public function getProductCategoryChild() | |||
{ | |||
$productCategories = $this->getProductCategories(); | |||
@@ -614,6 +630,54 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
public function getExportTitle(): ?string | |||
{ | |||
return $this->exportTitle; | |||
} | |||
public function setExportTitle(?string $exportTitle): self | |||
{ | |||
$this->exportTitle = $exportTitle; | |||
return $this; | |||
} | |||
public function getExportNote(): ?string | |||
{ | |||
return $this->exportNote; | |||
} | |||
public function setExportNote(?string $exportNote): self | |||
{ | |||
$this->exportNote = $exportNote; | |||
return $this; | |||
} | |||
public function getBehaviorStockWeek(): ?string | |||
{ | |||
return $this->behaviorStockWeek; | |||
} | |||
public function setBehaviorStockWeek(string $behaviorStockWeek): self | |||
{ | |||
$this->behaviorStockWeek = $behaviorStockWeek; | |||
return $this; | |||
} | |||
public function getAvailabilityRenewedThisWeek(): ?bool | |||
{ | |||
return $this->availabilityRenewedThisWeek; | |||
} | |||
public function setAvailabilityRenewedThisWeek(?bool $availabilityRenewedThisWeek): self | |||
{ | |||
$this->availabilityRenewedThisWeek = $availabilityRenewedThisWeek; | |||
return $this; | |||
} | |||
public function getBehaviorDisplaySale(): ?string | |||
{ | |||
return $this->behaviorDisplaySale; | |||
@@ -626,6 +690,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function isPropertyNoveltyOnline(): ?bool | |||
{ | |||
if ($this->getPropertyNoveltyExpirationDate()) { | |||
@@ -698,6 +763,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function countProperties(): bool | |||
{ | |||
$count = 0; | |||
@@ -847,6 +913,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this->behaviorPrice; | |||
} | |||
//TODO move | |||
public function getBehaviorPriceInherited() | |||
{ | |||
return $this->getBehaviorPrice(); | |||
@@ -859,7 +926,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function hasProductsWithVariousWeight() | |||
{ | |||
if ($this->getActiveProducts()) { | |||
@@ -885,6 +952,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return false; | |||
} | |||
//TODO move | |||
public function getProductsGroupByTitle() | |||
{ | |||
$arrayProductsGroupByTitle = []; | |||
@@ -903,6 +971,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $arrayProductsGroupByTitle; | |||
} | |||
//TODO move | |||
public function getOriginProduct() | |||
{ | |||
$products = $this->getProducts(); | |||
@@ -914,6 +983,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
} | |||
} | |||
//TODO move | |||
public function getOriginProductOnline() | |||
{ | |||
$originProduct = $this->getOriginProduct(); | |||
@@ -925,6 +995,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
} | |||
} | |||
//TODO move | |||
public function hasOneProductOnline() | |||
{ | |||
if (($this->getActiveProducts() && count($this->getProductsOnline()) > 0) | |||
@@ -947,7 +1018,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function getFieldBuyingPrice() | |||
{ | |||
if ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_PIECE) { | |||
@@ -957,6 +1028,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
} | |||
} | |||
//TODO move | |||
public function getFieldPrice() | |||
{ | |||
if ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_PIECE) { | |||
@@ -965,4 +1037,18 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return 'priceByRefUnit'; | |||
} | |||
} | |||
public function getImage(): ?FileInterface | |||
{ | |||
return $this->image; | |||
} | |||
public function setImage(?FileInterface $image): self | |||
{ | |||
$this->image = $image; | |||
return $this; | |||
} | |||
} |
@@ -9,6 +9,7 @@ use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ProductPropertyInterface; | |||
use Gedmo\Mapping\Annotation as Gedmo; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\SovBundle\Doctrine\Extension\BlameableNullableTrait; | |||
use Lc\SovBundle\Doctrine\Extension\SortableInterface; | |||
use Lc\SovBundle\Doctrine\Extension\SortableTrait; | |||
use Lc\SovBundle\Doctrine\Extension\StatusTrait; | |||
@@ -23,20 +24,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
use SortableTrait; | |||
use ProductPropertyTrait; | |||
use StatusTrait; | |||
/** | |||
* @Gedmo\Blameable(on="create") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $createdBy; | |||
/** | |||
* @Gedmo\Blameable(on="update") | |||
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface") | |||
* @ORM\JoinColumn(nullable=true) | |||
*/ | |||
protected $updatedBy; | |||
use BlameableNullableTrait; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface", inversedBy="products", cascade={"persist"}) | |||
@@ -54,6 +42,16 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
*/ | |||
protected $originProduct; | |||
/** | |||
* @ORM\Column(type="string", length=255, nullable=true) | |||
*/ | |||
protected $exportTitle; | |||
/** | |||
* @ORM\Column(type="text", nullable=true) | |||
*/ | |||
protected $exportNote; | |||
public function __construct() | |||
{ | |||
$this->orderProducts = new ArrayCollection(); | |||
@@ -75,92 +73,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
return $title; | |||
} | |||
public function isProductSaleStatusOn() | |||
{ | |||
if ($this->getProductFamily()->getSaleStatus() != 1) { | |||
return false; | |||
} | |||
$allCategoriesSalesOff = true; | |||
$unavailableSpecificDay = false; | |||
foreach ($this->getProductFamily()->getProductCategories() as $category) { | |||
if ($category->getParent()) { | |||
if ($category->getSaleStatus() && $category->getParent()->getSaleStatus()) { | |||
$allCategoriesSalesOff = false; | |||
} | |||
} else { | |||
if ($category->getSaleStatus()) { | |||
$allCategoriesSalesOff = false; | |||
} | |||
} | |||
// specific day | |||
// @TODO : spécifique pdl ? | |||
$displaySpecificDay = $category->getDisplaySpecificDay(); | |||
if ($displaySpecificDay && $displaySpecificDay != date('N')) { | |||
$unavailableSpecificDay = true; | |||
} | |||
} | |||
if ($allCategoriesSalesOff) { | |||
return false; | |||
} | |||
if ($unavailableSpecificDay) { | |||
return false; | |||
} | |||
return true; | |||
} | |||
// isProductAvailable | |||
public function isAvailable($quantityOrder = 0, $checkCart = false, $orderShop = null) | |||
{ | |||
if ($this->getStatus() != 1 || $this->getProductFamily()->getStatus() != 1 || !$this->isProductSaleStatusOn()) { | |||
return false; | |||
} | |||
// @TODO : orderShop à définir où est appelé isProductAvailable | |||
if ($checkCart && !$orderShop) { | |||
throw new \Exception("Attention jeune padawan : définir le orderShop à l'endroit où est appelé isProductAvailable"); | |||
} | |||
$productFamily = $this->getProductFamily(); | |||
$quantityAsked = $quantityOrder; | |||
if ($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE) { | |||
if (!$quantityOrder) { | |||
$quantityAsked = $orderShop->getQuantityOrderByProduct($this, true); | |||
} else { | |||
$quantityAsked = ($this->getQuantityInherited() / $this->getUnitInherited()->getCoefficient()) * $quantityOrder; | |||
} | |||
if ($checkCart) { | |||
$quantityAsked += $orderShop->getQuantityOrderByProduct($this, true); | |||
} | |||
} | |||
if (($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY | |||
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT)) { | |||
if (!$quantityOrder) { | |||
$quantityAsked = $orderShop->getQuantityOrderByProduct($this); | |||
} | |||
if ($checkCart) { | |||
$quantityAsked += $orderShop->getQuantityOrderByProduct($this); | |||
} | |||
} | |||
if ($this->getAvailableQuantityInherited() >= $quantityAsked | |||
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_UNLIMITED) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
} | |||
// @TODO : move | |||
// getProductQuantityMaxAddCart | |||
public function getQuantityMaxAddCart(OrderShopInterface $orderShop) | |||
{ | |||
@@ -174,6 +87,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
return $this->getAvailableQuantityInherited() - $orderShop->getQuantityOrderByProduct($this, $byWeight); | |||
} | |||
// @TODO : move | |||
// getProductQuantity | |||
public function getProductQuantity() | |||
{ | |||
@@ -186,6 +100,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getBuyingPriceInherited() | |||
{ | |||
if ($this->getBuyingPrice()) { | |||
@@ -195,6 +110,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getBuyingPriceByRefUnitInherited() | |||
{ | |||
if ($this->getBuyingPriceByRefUnit()) { | |||
@@ -204,6 +120,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getPriceInherited() | |||
{ | |||
if ($this->getPrice()) { | |||
@@ -213,6 +130,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getPriceByRefUnitInherited() | |||
{ | |||
if ($this->getPriceByRefUnit()) { | |||
@@ -222,16 +140,19 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getBehaviorPriceInherited() | |||
{ | |||
return $this->getProductFamily()->getBehaviorPrice(); | |||
} | |||
// @TODO : move | |||
public function getReductionCatalogInherited() | |||
{ | |||
return $this->getProductFamily()->getReductionCatalog(); | |||
} | |||
// @TODO : move | |||
public function getUnitInherited() | |||
{ | |||
if ($this->getUnit()) { | |||
@@ -241,6 +162,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getTitleInherited() | |||
{ | |||
if ($this->getTitle()) { | |||
@@ -250,6 +172,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getQuantityInherited() | |||
{ | |||
if ($this->getQuantity()) { | |||
@@ -259,6 +182,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getQuantityLabelInherited() | |||
{ | |||
$quantity = $this->getQuantityInherited(); | |||
@@ -266,6 +190,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
return $quantity . $unit->getWordingShort(); | |||
} | |||
// @TODO : move | |||
public function getQuantityTitle($productFamily) | |||
{ | |||
$title = $this->getQuantityLabelInherited(); | |||
@@ -275,6 +200,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
return $title; | |||
} | |||
// @TODO : move | |||
public function getAvailableQuantityInherited() | |||
{ | |||
switch ($this->getProductFamily()->getBehaviorCountStock()) { | |||
@@ -291,6 +217,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getTaxRateInherited() | |||
{ | |||
return $this->getProductFamily()->getTaxRateInherited(); | |||
@@ -331,4 +258,60 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
return $this; | |||
} | |||
public function getExportTitle(): ?string | |||
{ | |||
return $this->exportTitle; | |||
} | |||
//TODO move | |||
public function getExportTitleInherited(): ?string | |||
{ | |||
$exportTitle = $this->getExportTitle(); | |||
if ($exportTitle && strlen($exportTitle)) { | |||
return $exportTitle; | |||
} else { | |||
$productFamily = $this->getProductFamily(); | |||
if ($productFamily) { | |||
return $productFamily->getExportTitle(); | |||
} | |||
} | |||
return null; | |||
} | |||
public function setExportTitle(?string $exportTitle): self | |||
{ | |||
$this->exportTitle = $exportTitle; | |||
return $this; | |||
} | |||
public function getExportNote(): ?string | |||
{ | |||
return $this->exportNote; | |||
} | |||
//TODO move | |||
public function getExportNoteInherited(): ?string | |||
{ | |||
$exportNote = $this->getExportNote(); | |||
if ($exportNote && strlen($exportNote)) { | |||
return $exportNote; | |||
} else { | |||
$productFamily = $this->getProductFamily(); | |||
if ($productFamily) { | |||
return $productFamily->getExportNote(); | |||
} | |||
} | |||
return null; | |||
} | |||
public function setExportNote(?string $exportNote): self | |||
{ | |||
$this->exportNote = $exportNote; | |||
return $this; | |||
} | |||
} |