@@ -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( |
@@ -24,7 +24,7 @@ class OrderProductBuilder | |||
$this->orderProductStore = $orderProductStore; | |||
} | |||
public function init(OrderProductInterface $orderProduct) | |||
public function init(OrderProductInterface $orderProduct) :OrderProductInterface | |||
{ | |||
$orderProduct->setTitle($orderProduct->getTitleOrderShop()); | |||
$orderProduct->setPrice($this->priceSolver->getPrice($orderProduct->getProduct())); |
@@ -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; | |||
@@ -37,6 +40,7 @@ class OrderShopBuilder | |||
protected EntityManagerInterface $entityManager; | |||
protected OrderStatusStore $orderStatusStore; | |||
protected OrderProductStore $orderProductStore; | |||
protected OrderShopStore $orderShopStore; | |||
protected ProductFamilyStore $productFamilyStore; | |||
protected PriceSolver $priceSolver; | |||
protected OrderProductBuilder $orderProductBuilder; | |||
@@ -72,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; | |||
} | |||
@@ -85,7 +92,7 @@ class OrderShopBuilder | |||
SectionInterface $section, | |||
UserInterface $user = null, | |||
VisitorInterface $visitor = null | |||
) { | |||
): OrderShopInterface { | |||
$cart = $this->orderShopStore->getCartBy( | |||
[ | |||
'section' => $section, | |||
@@ -101,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 { | |||
@@ -122,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 | |||
@@ -145,7 +154,7 @@ class OrderShopBuilder | |||
OrderShopInterface $orderShop, | |||
OrderProductInterface $orderProductAdd, | |||
bool $persist = true | |||
) { | |||
): bool { | |||
$return = false; | |||
if ($this->orderProductStore->isOrderProductAvailableAddCart($orderProductAdd, $orderShop)) { | |||
@@ -200,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; | |||
@@ -243,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); | |||
@@ -259,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(); | |||
} | |||
@@ -273,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); | |||
@@ -290,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); | |||
@@ -314,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); | |||
@@ -334,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( |
@@ -19,18 +19,20 @@ class OrderChecker | |||
$this->orderShopSolver = $orderShopSolver; | |||
} | |||
public function hasOrderProductAlreadyInCart(OrderShopInterface $orderShop, OrderProductInterface $orderProductTest) | |||
{ | |||
public function hasOrderProductAlreadyInCart( | |||
OrderShopInterface $orderShop, | |||
OrderProductInterface $orderProductTest | |||
): ?OrderProductInterface { | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
if ($orderProduct->getProduct() == $orderProductTest->getProduct()) { | |||
return $orderProduct; | |||
} | |||
} | |||
return false; | |||
return null; | |||
} | |||
public function isValid(OrderShopInterface $orderShop) | |||
public function isValid(OrderShopInterface $orderShop): bool | |||
{ | |||
if ($orderShop->getOrderStatus() && in_array( | |||
$orderShop->getOrderStatus()->getAlias(), | |||
@@ -42,7 +44,7 @@ class OrderChecker | |||
return false; | |||
} | |||
public function isCart(OrderShopInterface $orderShop) | |||
public function isCart(OrderShopInterface $orderShop): bool | |||
{ | |||
if ($orderShop->getOrderStatus() && in_array( | |||
$orderShop->getOrderStatus()->getAlias(), | |||
@@ -55,12 +57,12 @@ class OrderChecker | |||
} | |||
// isOrderShopPositiveAmount | |||
public function isPositiveAmount(OrderShopInterface $orderShop) | |||
public function isPositiveAmount(OrderShopInterface $orderShop): bool | |||
{ | |||
return $this->priceSolver->getTotalWithTax($orderShop) >= 0; | |||
} | |||
public function isPaid(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false) | |||
public function isPaid(OrderShopInterface $orderShop, $mergeComplementaryOrderShop = false): bool | |||
{ | |||
$totalOrderPayments = $this->orderShopSolver->getTotalOrderPayments($orderShop, $mergeComplementaryOrderShop); | |||
$totalOrder = $this->priceSolver->getTotalWithTax($orderShop); | |||
@@ -80,7 +82,7 @@ class OrderChecker | |||
return $this->orderShopSolver->getTotalRemainingToBePaid($orderShop) > 0; | |||
} | |||
public function isCartAllowToBeOrder(OrderShopInterface $orderShop) | |||
public function isCartAllowToBeOrder(OrderShopInterface $orderShop): bool | |||
{ | |||
return true; | |||
} |
@@ -5,19 +5,23 @@ 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; | |||
} | |||
@@ -27,6 +31,11 @@ class OrderProductReductionCatalogContainer | |||
return $this->factory; | |||
} | |||
public function getSolver(): OrderProductReductionCatalogSolver | |||
{ | |||
return $this->solver; | |||
} | |||
public function getRepositoryQuery(): OrderProductReductionCatalogRepositoryQuery | |||
{ | |||
return $this->repositoryQuery; |
@@ -81,13 +81,8 @@ trait AdminControllerTrait | |||
return array_merge( | |||
parent::getSubscribedServices(), | |||
[ | |||
'merchant_resolver' => MerchantResolver::class, | |||
'section_resolver' => SectionResolver::class, | |||
'user_factory' => UserFactory::class, | |||
'user_merchant_factory' => UserMerchantFactory::class, | |||
MerchantResolver::class => MerchantResolver::class, | |||
SectionResolver::class => SectionResolver::class, | |||
SectionResolver::class=> SectionResolver::class, | |||
AddressContainer::class => AddressContainer::class, | |||
TaxRateContainer::class => TaxRateContainer::class, | |||
UnitContainer::class => UnitContainer::class, |
@@ -20,6 +20,7 @@ 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; | |||
@@ -31,7 +32,7 @@ use Lc\SovBundle\Translation\TranslatorAdmin; | |||
abstract class CreditHistoryAdminController extends AbstractAdminController | |||
{ | |||
use AdminControllerTrait; | |||
public function overrideGlobalActions(?ActionCollection $actions): void | |||
{ | |||
parent::overrideGlobalActions($actions); | |||
@@ -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) { |
@@ -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() | |||
{ | |||
} | |||
} |
@@ -48,7 +48,6 @@ abstract class PointSaleAdminController extends AbstractAdminController | |||
{ | |||
return $this->get(PointSaleContainer::class) | |||
->getFactory() | |||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) | |||
->create(); | |||
->create($this->get(MerchantResolver::class)->getCurrent()); | |||
} | |||
} |
@@ -17,5 +17,4 @@ abstract class ProductFamilyAdminController extends AbstractAdminController | |||
{ | |||
use AdminControllerTrait; | |||
} |
@@ -16,7 +16,6 @@ class ReminderAdminController extends SovReminderAdminController | |||
public function createEntity(string $crudAction = null, string $crudControllerFqcn = null, int $entityId = null) | |||
{ | |||
$reminderFactory = new ReminderFactory(); | |||
return $this->get(ReminderContainer::class) | |||
->getFactory() | |||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) |
@@ -60,8 +60,7 @@ abstract class OpeningAdminController extends AbstractAdminController | |||
{ | |||
return $this->get(OpeningContainer::class) | |||
->getFactory() | |||
->setSection($this->get(SectionResolver::class)->getCurrent()) | |||
->create(); | |||
->create($this->get(SectionResolver::class)->getCurrent()); | |||
} | |||
} |
@@ -61,8 +61,7 @@ abstract class SectionAdminController extends AbstractAdminController | |||
{ | |||
return $this->get(SectionContainer::class) | |||
->getFactory() | |||
->setMerchant($this->get(MerchantResolver::class)->getCurrent()) | |||
->create(); | |||
->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( |
@@ -31,6 +31,7 @@ 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; | |||
@@ -42,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 | |||
{ | |||
@@ -57,7 +50,7 @@ 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) { | |||
@@ -84,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'); | |||
@@ -119,13 +112,12 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
public function new(AdminContext $context): Response | |||
{ | |||
$entityManager = $this->get('em'); | |||
$userRepository = $entityManager->getRepository(UserInterface::class); | |||
$entityManager = $this->get(EntityManagerInterface::class); | |||
$merchantResolver = $this->get(MerchantResolver::class); | |||
$userMerchant = $this->get(UserMerchantContainer::class) | |||
->getFactory() | |||
->setMerchant($merchantResolver->getCurrent()) | |||
->create(); | |||
->create($merchantResolver->getCurrent()); | |||
$form = $this->createForm(UserMerchantFormType::class, $userMerchant); | |||
@@ -134,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(); | |||
@@ -142,7 +134,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
$param['lastname'] = $form->get('firstname')->getData(); | |||
$param['roles'] = array(); | |||
// @TODO : à adapter | |||
// @TODO : à adapter l'array de valeur passer au factory | |||
$userFactory = new UserFactory(); | |||
$user = $userFactory->create($param); | |||
@@ -150,7 +142,7 @@ abstract class UserMerchantAdminController extends AbstractAdminController | |||
$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); | |||
@@ -162,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')); | |||
} | |||
} | |||
} | |||
@@ -183,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(); | |||
@@ -203,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; |
@@ -5,17 +5,17 @@ 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; | |||
class AddressFactory extends AbstractFactory | |||
{ | |||
use MerchantFactoryTrait; | |||
public function create(): AddressInterface | |||
public function create(MerchantInterface $merchant): AddressInterface | |||
{ | |||
$address = new Address(); | |||
$address->setMerchant($this->merchant); | |||
$address->setMerchant($merchant); | |||
return $address; | |||
} |
@@ -7,18 +7,18 @@ 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); |
@@ -16,16 +16,16 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; | |||
class OrderShopFactory extends AbstractFactory | |||
{ | |||
use SectionFactoryTrait; | |||
public function create( | |||
SectionInterface $section, | |||
UserInterface $user = null, | |||
VisitorInterface $visitor = null | |||
): OrderShopInterface { | |||
$orderShop = new OrderShop(); | |||
$orderShop->setSection($this->section); | |||
$orderShop->setSection($section); | |||
$orderShopBelongTo = false; | |||
@@ -10,13 +10,12 @@ use Lc\SovBundle\Factory\AbstractFactory; | |||
class PointSaleFactory extends AbstractFactory | |||
{ | |||
use MerchantFactoryTrait; | |||
public function create(): PointSaleInterface | |||
public function create(MerchantInterface $merchant): PointSaleInterface | |||
{ | |||
$pointSale = new PointSale(); | |||
$pointSale->addMerchant($this->merchant); | |||
$pointSale->addMerchant($merchant); | |||
return $pointSale; | |||
} |
@@ -12,15 +12,12 @@ use Lc\SovBundle\Factory\AbstractFactory; | |||
class ProductCategoryFactory extends AbstractFactory | |||
{ | |||
use MerchantFactoryTrait; | |||
use SectionFactoryTrait; | |||
public function create(): ProductCategoryInterface | |||
public function create(SectionInterface $section): ProductCategoryInterface | |||
{ | |||
$productCategory = new ProductCategory(); | |||
$productCategory->setMerchant($this->merchant); | |||
$productCategory->setSection($this->section); | |||
$productCategory->setSection($section); | |||
return $productCategory; | |||
} |
@@ -11,13 +11,12 @@ use Lc\SovBundle\Factory\AbstractFactory; | |||
class ProductFamilyFactory extends AbstractFactory | |||
{ | |||
use SectionFactoryTrait; | |||
public function create(): ProductFamilyInterface | |||
public function create(SectionInterface $section): ProductFamilyInterface | |||
{ | |||
$productFamily = new ProductFamily(); | |||
$productFamily->setSection($this->section); | |||
$productFamily->setSection($section); | |||
return $productFamily; | |||
} |
@@ -6,17 +6,17 @@ 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 | |||
{ | |||
use MerchantFactoryTrait; | |||
public function create(): ReductionCartInterface | |||
public function create(SectionInterface $section): ReductionCartInterface | |||
{ | |||
$reductionCart = new ReductionCart(); | |||
$reductionCart->setMerchant($this->merchant); | |||
$reductionCart->setSection($section); | |||
return $reductionCart; | |||
} |
@@ -6,17 +6,17 @@ 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 | |||
{ | |||
use MerchantFactoryTrait; | |||
public function create(): ReductionCatalogInterface | |||
public function create(SectionInterface $section): ReductionCatalogInterface | |||
{ | |||
$reductionCatalog = new ReductionCatalog(); | |||
$reductionCatalog->setMerchant($this->merchant); | |||
$reductionCatalog->setSection($section); | |||
return $reductionCatalog; | |||
} |
@@ -6,17 +6,17 @@ 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 | |||
{ | |||
use MerchantFactoryTrait; | |||
public function create(): ReductionCreditInterface | |||
public function create(SectionInterface $section): ReductionCreditInterface | |||
{ | |||
$reductionCredit = new ReductionCredit(); | |||
$reductionCredit->setMerchant($this->merchant); | |||
$reductionCredit->setSection($section); | |||
return $reductionCredit; | |||
} |
@@ -4,14 +4,15 @@ 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; | |||
class OpeningFactory extends AbstractFactory | |||
{ | |||
use SectionFactoryTrait; | |||
public function create( | |||
SectionInterface $section, | |||
int $day = null, | |||
\DateTime $timeStart = null, | |||
\DateTime $timeEnd = null, | |||
@@ -19,7 +20,7 @@ class OpeningFactory extends AbstractFactory | |||
): Opening { | |||
$opening = new Opening(); | |||
$opening->setSection($this->section); | |||
$opening->setSection($section); | |||
$opening->setDay($day); | |||
$opening->setTimeStart($timeStart); | |||
$opening->setTimeEnd($timeEnd); |
@@ -4,18 +4,18 @@ 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; | |||
class SectionFactory extends AbstractFactory | |||
{ | |||
use MerchantFactoryTrait; | |||
public function create(): SectionInterface | |||
public function create(MerchantInterface $merchant): SectionInterface | |||
{ | |||
$section = new Section(); | |||
$section->setMerchant($this->merchant); | |||
$section->setMerchant($merchant); | |||
return $section; | |||
} |
@@ -10,13 +10,12 @@ use Lc\SovBundle\Model\File\FileInterface; | |||
class MerchantSettingFactory extends AbstractFactory | |||
{ | |||
use MerchantFactoryTrait; | |||
public function create(string $name, string $text = null, \DateTime $date = null, FileInterface $file = null) | |||
public function create(MerchantInterface $merchant, string $name, string $text = null, \DateTime $date = null, FileInterface $file = null) | |||
{ | |||
$merchantSetting = new MerchantSetting(); | |||
$merchantSetting->setMerchant($this->merchant); | |||
$merchantSetting->setMerchant($merchant); | |||
$merchantSetting->setName($name); | |||
$merchantSetting->setText($text); | |||
$merchantSetting->setDate($date); |
@@ -10,13 +10,12 @@ use Lc\SovBundle\Model\File\FileInterface; | |||
class SectionSettingFactory extends AbstractFactory | |||
{ | |||
use SectionFactoryTrait; | |||
public function create(string $name, string $text = null, \DateTime $date = null, FileInterface $file = null) | |||
public function create(SectionInterface $section, string $name, string $text = null, \DateTime $date = null, FileInterface $file = null) | |||
{ | |||
$merchantSetting = new SectionSetting(); | |||
$merchantSetting->setSection($this->section); | |||
$merchantSetting->setSection($section); | |||
$merchantSetting->setName($name); | |||
$merchantSetting->setText($text); | |||
$merchantSetting->setDate($date); |
@@ -11,14 +11,12 @@ use Lc\SovBundle\Model\User\UserInterface; | |||
class UserMerchantFactory extends AbstractFactory | |||
{ | |||
use MerchantFactoryTrait; | |||
// createUserMerchant | |||
public function create(UserInterface $user = null): 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; |
@@ -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) | |||
*/ | |||
private $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; |
@@ -15,6 +15,7 @@ use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||
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; | |||
@@ -25,8 +26,10 @@ use Lc\SovBundle\Model\User\UserInterface; | |||
*/ | |||
abstract class OrderShopModel extends AbstractLightEntity implements FilterSectionInterface | |||
{ | |||
use BlameableNullableTrait; | |||
/** | |||
* @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; | |||
@@ -55,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) | |||
*/ | |||
@@ -106,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") | |||
*/ | |||
@@ -141,7 +125,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
$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(); | |||
@@ -168,30 +151,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; | |||
@@ -240,18 +199,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; | |||
@@ -369,37 +316,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; | |||
@@ -437,7 +353,6 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|OrderReductionCartInterface[] | |||
*/ | |||
@@ -526,17 +441,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[] | |||
*/ |
@@ -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, |
@@ -60,11 +60,6 @@ abstract class PointSaleModel extends AbstractFullEntity implements FilterMultip | |||
return $this->getTitle(); | |||
} | |||
public function labelAdminChoice() | |||
{ | |||
return $this->getTitle(); | |||
} | |||
/** | |||
* @return Collection|MerchantInterface[] | |||
*/ |
@@ -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,6 +12,7 @@ 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; | |||
@@ -21,8 +22,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 +40,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 +51,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 +78,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 +89,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 +100,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 +116,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,7 +129,6 @@ 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'; | |||
@@ -141,25 +139,9 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
]; | |||
} | |||
//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") | |||
*/ | |||
@@ -312,7 +294,6 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
*/ | |||
protected $saleStatus; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
@@ -341,7 +322,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function getAvailableQuantityInherited() | |||
{ | |||
$availableQuantity = 0; | |||
@@ -367,7 +348,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $availableQuantity; | |||
} | |||
//TODO move | |||
public function getTaxRateInherited() | |||
{ | |||
if ($this->getTaxRate()) { | |||
@@ -376,6 +357,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this->getSection()->getMerchant()->getTaxRate(); | |||
} | |||
} | |||
public function getActiveProducts(): ?bool | |||
{ | |||
return $this->activeProducts; | |||
@@ -431,7 +413,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
{ | |||
return $this->products; | |||
} | |||
//TODO move | |||
public function getProductsOnline(): Collection | |||
{ | |||
$products = $this->getProducts(); | |||
@@ -473,7 +455,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
{ | |||
return $this->reductionCatalog; | |||
} | |||
//TODO move | |||
public function getReductionCatalogInherited(): ?ReductionCatalogInterface | |||
{ | |||
return $this->getReductionCatalog(); | |||
@@ -516,7 +498,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function getProductCategoryParent() | |||
{ | |||
$productCategories = $this->getProductCategories(); | |||
@@ -528,6 +510,8 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return false; | |||
} | |||
//TODO move | |||
public function getProductCategoryChild() | |||
{ | |||
$productCategories = $this->getProductCategories(); | |||
@@ -625,7 +609,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function isPropertyNoveltyOnline(): ?bool | |||
{ | |||
if ($this->getPropertyNoveltyExpirationDate()) { | |||
@@ -697,7 +681,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function countProperties(): bool | |||
{ | |||
$count = 0; | |||
@@ -846,7 +830,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
{ | |||
return $this->behaviorPrice; | |||
} | |||
//TODO move | |||
public function getBehaviorPriceInherited() | |||
{ | |||
return $this->getBehaviorPrice(); | |||
@@ -859,7 +843,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $this; | |||
} | |||
//TODO move | |||
public function hasProductsWithVariousWeight() | |||
{ | |||
if ($this->getActiveProducts()) { | |||
@@ -884,7 +868,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return false; | |||
} | |||
//TODO move | |||
public function getProductsGroupByTitle() | |||
{ | |||
$arrayProductsGroupByTitle = []; | |||
@@ -902,7 +886,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return $arrayProductsGroupByTitle; | |||
} | |||
//TODO move | |||
public function getOriginProduct() | |||
{ | |||
$products = $this->getProducts(); | |||
@@ -913,7 +897,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
} | |||
} | |||
} | |||
//TODO move | |||
public function getOriginProductOnline() | |||
{ | |||
$originProduct = $this->getOriginProduct(); | |||
@@ -924,7 +908,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
return false; | |||
} | |||
} | |||
//TODO move | |||
public function hasOneProductOnline() | |||
{ | |||
if (($this->getActiveProducts() && count($this->getProductsOnline()) > 0) | |||
@@ -947,7 +931,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 +941,7 @@ abstract class ProductFamilyModel extends AbstractFullEntity implements ProductP | |||
} | |||
} | |||
//TODO move | |||
public function getFieldPrice() | |||
{ | |||
if ($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_PIECE) { |
@@ -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"}) | |||
@@ -75,6 +63,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
return $title; | |||
} | |||
// @TODO : move | |||
// getProductQuantityMaxAddCart | |||
public function getQuantityMaxAddCart(OrderShopInterface $orderShop) | |||
{ | |||
@@ -88,6 +77,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
return $this->getAvailableQuantityInherited() - $orderShop->getQuantityOrderByProduct($this, $byWeight); | |||
} | |||
// @TODO : move | |||
// getProductQuantity | |||
public function getProductQuantity() | |||
{ | |||
@@ -100,6 +90,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getBuyingPriceInherited() | |||
{ | |||
if ($this->getBuyingPrice()) { | |||
@@ -109,6 +100,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getBuyingPriceByRefUnitInherited() | |||
{ | |||
if ($this->getBuyingPriceByRefUnit()) { | |||
@@ -118,6 +110,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getPriceInherited() | |||
{ | |||
if ($this->getPrice()) { | |||
@@ -127,6 +120,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getPriceByRefUnitInherited() | |||
{ | |||
if ($this->getPriceByRefUnit()) { | |||
@@ -136,16 +130,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()) { | |||
@@ -155,6 +152,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getTitleInherited() | |||
{ | |||
if ($this->getTitle()) { | |||
@@ -164,6 +162,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getQuantityInherited() | |||
{ | |||
if ($this->getQuantity()) { | |||
@@ -173,6 +172,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getQuantityLabelInherited() | |||
{ | |||
$quantity = $this->getQuantityInherited(); | |||
@@ -180,6 +180,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
return $quantity . $unit->getWordingShort(); | |||
} | |||
// @TODO : move | |||
public function getQuantityTitle($productFamily) | |||
{ | |||
$title = $this->getQuantityLabelInherited(); | |||
@@ -189,6 +190,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
return $title; | |||
} | |||
// @TODO : move | |||
public function getAvailableQuantityInherited() | |||
{ | |||
switch ($this->getProductFamily()->getBehaviorCountStock()) { | |||
@@ -205,6 +207,7 @@ abstract class ProductModel extends AbstractLightEntity implements SortableInter | |||
} | |||
} | |||
// @TODO : move | |||
public function getTaxRateInherited() | |||
{ | |||
return $this->getProductFamily()->getTaxRateInherited(); |
@@ -35,7 +35,6 @@ abstract class ReductionCartModel extends AbstractLightEntity implements Reducti | |||
const APPLIED_TO_DELIVERY = 'delivery'; | |||
const APPLIED_TO_ORDER_PRODUCTS = 'order-products'; | |||
use StatusTrait; | |||
use OrderAmountMinTrait; | |||
use ReductionTrait; | |||
@@ -49,7 +48,6 @@ abstract class ReductionCartModel extends AbstractLightEntity implements Reducti | |||
*/ | |||
protected $title; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
@@ -103,42 +101,6 @@ abstract class ReductionCartModel extends AbstractLightEntity implements Reducti | |||
$this->uncombinables = new ArrayCollection(); | |||
} | |||
// isReductionCartMatchWithUser | |||
public function matchWithUser(UserInterface $user) | |||
{ | |||
$conditionUser = false; | |||
if ($user) { | |||
if ($this->getUsers()->isEmpty() || $this->getUsers()->contains($user)) { | |||
$conditionUser = true; | |||
} | |||
} | |||
return $conditionUser; | |||
} | |||
// isReductionCartMatchWithGroupUser | |||
public function matchWithGroupUser(UserInterface $user) | |||
{ | |||
$conditionGroupUser = false; | |||
if ($user) { | |||
if ($user->getGroupUsers() && count($user->getGroupUsers()) > 0) { | |||
foreach ($user->getGroupUsers() as $groupUser) { | |||
if ($this->getGroupUsers()->isEmpty() || $this->getGroupUsers()->contains($groupUser)) { | |||
$conditionGroupUser = true; | |||
} | |||
} | |||
} else { | |||
if ($reductionCart->getGroupUsers()->isEmpty()) { | |||
$conditionGroupUser = true; | |||
} | |||
} | |||
} | |||
return $conditionGroupUser; | |||
} | |||
public function getTitle(): ?string | |||
{ | |||
return $this->title; | |||
@@ -252,7 +214,6 @@ abstract class ReductionCartModel extends AbstractLightEntity implements Reducti | |||
return $this; | |||
} | |||
public function getUncombinableTypes(): ?array | |||
{ | |||
return $this->uncombinableTypes; |
@@ -35,7 +35,6 @@ abstract class ReductionCatalogModel extends AbstractLightEntity implements Redu | |||
*/ | |||
protected $title; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
@@ -57,7 +56,6 @@ abstract class ReductionCatalogModel extends AbstractLightEntity implements Redu | |||
*/ | |||
protected $productCategories; | |||
public function __construct() | |||
{ | |||
$this->__reductionPropertyConstruct(); | |||
@@ -77,7 +75,6 @@ abstract class ReductionCatalogModel extends AbstractLightEntity implements Redu | |||
return $this; | |||
} | |||
public function getSection(): SectionInterface | |||
{ | |||
return $this->section; | |||
@@ -90,7 +87,6 @@ abstract class ReductionCatalogModel extends AbstractLightEntity implements Redu | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|ProductFamilyInterface[] | |||
*/ | |||
@@ -130,7 +126,6 @@ abstract class ReductionCatalogModel extends AbstractLightEntity implements Redu | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|ProductCategoryInterface[] | |||
*/ |
@@ -9,6 +9,7 @@ use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | |||
use Lc\CaracoleBundle\Model\Config\UnitModel; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | |||
@@ -25,11 +26,9 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc | |||
const TYPE_CREDIT = 'credit'; | |||
const TYPE_GIFT = 'gift'; | |||
use ReductionTrait; | |||
use StatusTrait; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
*/ | |||
@@ -64,7 +63,7 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc | |||
public function __construct() | |||
{ | |||
$this->users = new ArrayCollection(); | |||
$this->unit = 'amount'; | |||
$this->unit = UnitModel::UNIT_AMOUNT; | |||
} | |||
public function __toString() | |||
@@ -84,7 +83,6 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc | |||
return $this; | |||
} | |||
public function getSection(): SectionInterface | |||
{ | |||
return $this->section; | |||
@@ -97,7 +95,6 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc | |||
return $this; | |||
} | |||
public function getType(): ?string | |||
{ | |||
return $this->type; | |||
@@ -136,7 +133,6 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc | |||
return $this; | |||
} | |||
public function getSended(): ?bool | |||
{ | |||
return $this->sended; | |||
@@ -149,7 +145,6 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc | |||
return $this; | |||
} | |||
public function getOwner(): ?UserInterface | |||
{ | |||
return $this->owner; |
@@ -25,6 +25,18 @@ abstract class ReminderModel extends SovReminderModel implements FilterMerchantI | |||
*/ | |||
protected $section; | |||
public function getMerchant(): ?MerchantInterface | |||
{ | |||
return $this->merchant; | |||
} | |||
public function setMerchant(?MerchantInterface $merchant): self | |||
{ | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getSection(): ?SectionInterface | |||
{ | |||
return $this->section; |
@@ -11,7 +11,9 @@ use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Model\Setting\SectionSettingInterface; | |||
use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||
use Lc\SovBundle\Model\Setting\EntitySettingTrait; | |||
use Lc\SovBundle\Model\Site\NewsInterface; | |||
use Lc\SovBundle\Model\Site\PageInterface; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractFullEntity; | |||
@@ -43,7 +45,6 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
*/ | |||
protected $isDefault; | |||
/** | |||
* @ORM\Column(type="string", length=32) | |||
*/ | |||
@@ -64,6 +65,16 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
*/ | |||
protected $productCategories; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\NewsInterface", mappedBy="section", orphanRemoval=true) | |||
*/ | |||
protected $news; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", mappedBy="section") | |||
*/ | |||
protected $newsletters; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Site\PageInterface", mappedBy="section") | |||
*/ | |||
@@ -83,8 +94,12 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
{ | |||
$this->productFamilies = new ArrayCollection(); | |||
$this->orderShops = new ArrayCollection(); | |||
$this->openings = new ArrayCollection(); | |||
$this->productCategories = new ArrayCollection(); | |||
$this->news = new ArrayCollection(); | |||
$this->newsletters = new ArrayCollection(); | |||
$this->pages = new ArrayCollection(); | |||
$this->settings = new ArrayCollection(); | |||
$this->openings = new ArrayCollection(); | |||
} | |||
public function __toString() | |||
@@ -218,7 +233,6 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|PageInterface[] | |||
*/ | |||
@@ -249,6 +263,68 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
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->setSection($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->getSection() === $this) { | |||
$news->setSection(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->setSection($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->getSection() === $this) { | |||
$newsletter->setSection(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
public function getIsDefault(): ?bool | |||
{ | |||
return $this->isDefault; | |||
@@ -273,7 +349,7 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
{ | |||
if (!$this->settings->contains($sectionSetting)) { | |||
$this->settings[] = $sectionSetting; | |||
$sectionSetting->setMerchant($this); | |||
$sectionSetting->setSection($this); | |||
} | |||
return $this; | |||
@@ -284,8 +360,8 @@ abstract class SectionModel extends AbstractFullEntity implements FilterMerchant | |||
if ($this->settings->contains($sectionSetting)) { | |||
$this->settings->removeElement($sectionSetting); | |||
// set the owning side to null (unless already changed) | |||
if ($sectionSetting->getMerchant() === $this) { | |||
$sectionSetting->setMerchant(null); | |||
if ($sectionSetting->getSection() === $this) { | |||
$sectionSetting->setSection(null); | |||
} | |||
} | |||
@@ -4,7 +4,7 @@ namespace Lc\CaracoleBundle\Model\Site; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Model\Site\NewsModel as SovNewsModel; | |||
/** | |||
@@ -13,19 +13,19 @@ use Lc\SovBundle\Model\Site\NewsModel as SovNewsModel; | |||
abstract class NewsModel extends SovNewsModel implements FilterMerchantInterface | |||
{ | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="news") | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="news") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
protected $section; | |||
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; | |||
} |
@@ -19,7 +19,6 @@ abstract class PageModel extends SovPageModel implements FilterSectionInterface | |||
*/ | |||
protected $section; | |||
public function getSection(): SectionInterface | |||
{ | |||
return $this->section; |
@@ -4,8 +4,8 @@ namespace Lc\CaracoleBundle\Model\Ticket; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Model\Ticket\TicketModel as SovTicketModel; | |||
/** | |||
@@ -17,35 +17,24 @@ abstract class TicketModel extends SovTicketModel implements FilterMerchantInter | |||
const TYPE_PRODUCT_ERROR = 'product-error'; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface", inversedBy="pages") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $merchant; | |||
protected $section; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", inversedBy="tickets") | |||
*/ | |||
protected $orderShop; | |||
public function getTypeChoices(): array | |||
public function getSection(): SectionInterface | |||
{ | |||
$choices = parent::getTypeChoices(); | |||
$choicesProduct = [ | |||
TicketModel::TYPE_PRODUCT_UNAVAILABLE, | |||
TicketModel::TYPE_PRODUCT_ERROR | |||
]; | |||
return array_merge($choices, $choicesProduct); | |||
} | |||
public function getMerchant(): MerchantInterface | |||
{ | |||
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; | |||
} |
@@ -12,7 +12,7 @@ use Lc\SovBundle\Model\Newsletter\NewsletterInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | |||
use Lc\SovBundle\Model\User\User as SovUserModel; | |||
use Lc\SovBundle\Model\User\UserModel as SovUserModel; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
@@ -22,11 +22,6 @@ use Lc\SovBundle\Model\Ticket\TicketInterface; | |||
*/ | |||
abstract class UserModel extends SovUserModel | |||
{ | |||
/** | |||
* @ORM\Column(type="string", length=20, nullable=true) | |||
*/ | |||
protected $phone; | |||
/** | |||
* @ORM\Column(type="string", length=64, nullable=true) | |||
*/ | |||
@@ -45,29 +40,13 @@ abstract class UserModel extends SovUserModel | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\CaracoleBundle\Model\Order\OrderShopInterface", mappedBy="user") | |||
*/ | |||
protected $orders; | |||
/** | |||
* @ORM\Column(type="string", length=64, nullable=true) | |||
*/ | |||
protected $firstname; | |||
/** | |||
* @ORM\Column(type="string", length=64, nullable=true) | |||
*/ | |||
protected $lastname; | |||
/** | |||
* @ORM\Column(type="boolean", nullable=true) | |||
*/ | |||
protected $gender; | |||
protected $orderShops; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\SovBundle\Model\Newsletter\NewsletterInterface", inversedBy="users") | |||
*/ | |||
protected $newsletters; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface") | |||
*/ | |||
@@ -83,62 +62,22 @@ abstract class UserModel extends SovUserModel | |||
*/ | |||
protected $userMerchants; | |||
/** | |||
* @ORM\OneToMany(targetEntity="Lc\SovBundle\Model\Ticket\TicketInterface", mappedBy="user") | |||
*/ | |||
protected $tickets; | |||
/** | |||
* @ORM\Column(type="array", nullable=true) | |||
*/ | |||
protected $ticketTypesNotification = []; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface", mappedBy="users") | |||
*/ | |||
protected $reductionCredits; | |||
public function __construct() | |||
{ | |||
$this->addresses = new ArrayCollection(); | |||
$this->orders = new ArrayCollection(); | |||
$this->orderShops = new ArrayCollection(); | |||
$this->groupUsers = new ArrayCollection(); | |||
$this->newsletters = new ArrayCollection(); | |||
$this->favoriteProductFamilies = new ArrayCollection(); | |||
$this->userPointSales = new ArrayCollection(); | |||
$this->userMerchants = new ArrayCollection(); | |||
$this->reductionCredits = new ArrayCollection(); | |||
$this->tickets = new ArrayCollection(); | |||
} | |||
public function __toString() | |||
{ | |||
return $this->getSummary(); | |||
} | |||
public function getSummary() | |||
{ | |||
return '#' . $this->getId() . ' ' . strtoupper($this->getLastname()) . ' ' . $this->getFirstname( | |||
) . ' (' . $this->getEmail() . ')'; | |||
} | |||
public function getName(): ?string | |||
{ | |||
return (string)ucfirst(strtolower($this->getFirstname())) . ' ' . strtoupper($this->getLastname()); | |||
} | |||
// isUserLinkedToPointSale | |||
public function isLinkedToPointSale(PointSaleInterface $pointSale) | |||
{ | |||
foreach ($this->getUserPointSales() as $userPointSale) { | |||
if ($userPointSale->getPointSale()->getId() == $pointSale->getId()) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
public function getPhone(): ?string | |||
@@ -221,69 +160,34 @@ abstract class UserModel extends SovUserModel | |||
/** | |||
* @return Collection|OrderShopInterface[] | |||
*/ | |||
public function getOrders(): Collection | |||
public function getOrderShops(): Collection | |||
{ | |||
return $this->orders; | |||
return $this->orderShops; | |||
} | |||
public function addOrder(OrderShopInterface $order): self | |||
public function addOrderShop(OrderShopInterface $orderShop): self | |||
{ | |||
if (!$this->orders->contains($order)) { | |||
$this->orders[] = $order; | |||
$order->setUser($this); | |||
if (!$this->orderShops->contains($orderShop)) { | |||
$this->orderShops[] = $orderShop; | |||
$orderShop->setUser($this); | |||
} | |||
return $this; | |||
} | |||
public function removeOrder(OrderShopInterface $order): self | |||
public function removeOrderShop(OrderShopInterface $orderShop): self | |||
{ | |||
if ($this->orders->contains($order)) { | |||
$this->orders->removeElement($order); | |||
if ($this->orderShops->contains($orderShop)) { | |||
$this->orderShops->removeElement($orderShop); | |||
// set the owning side to null (unless already changed) | |||
if ($order->getUser() === $this) { | |||
$order->setUser(null); | |||
if ($orderShop->getUser() === $this) { | |||
$orderShop->setUser(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
public function getFirstname(): ?string | |||
{ | |||
return $this->firstname; | |||
} | |||
public function setFirstname(?string $firstname): self | |||
{ | |||
$this->firstname = $firstname; | |||
return $this; | |||
} | |||
public function getLastname(): ?string | |||
{ | |||
return $this->lastname; | |||
} | |||
public function setLastname(?string $lastname): self | |||
{ | |||
$this->lastname = $lastname; | |||
return $this; | |||
} | |||
public function getGender(): ?bool | |||
{ | |||
return $this->gender; | |||
} | |||
public function setGender(?bool $gender): self | |||
{ | |||
$this->gender = $gender; | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|NewsletterInterface[] | |||
@@ -369,74 +273,6 @@ abstract class UserModel extends SovUserModel | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|TicketInterface[] | |||
*/ | |||
public function getTickets(): Collection | |||
{ | |||
return $this->tickets; | |||
} | |||
public function addTicket(TicketInterface $ticket): self | |||
{ | |||
if (!$this->tickets->contains($ticket)) { | |||
$this->tickets[] = $ticket; | |||
$ticket->setUser($this); | |||
} | |||
return $this; | |||
} | |||
public function removeTicket(TicketInterface $ticket): self | |||
{ | |||
if ($this->tickets->contains($ticket)) { | |||
$this->tickets->removeElement($ticket); | |||
// set the owning side to null (unless already changed) | |||
if ($ticket->getUser() === $this) { | |||
$ticket->setUser(null); | |||
} | |||
} | |||
return $this; | |||
} | |||
public function getCreatedAt(): ?\DateTimeInterface | |||
{ | |||
return $this->createdAt; | |||
} | |||
public function setCreatedAt(\DateTimeInterface $createdAt): self | |||
{ | |||
$this->createdAt = $createdAt; | |||
return $this; | |||
} | |||
public function getUpdatedAt(): ?\DateTimeInterface | |||
{ | |||
return $this->updatedAt; | |||
} | |||
public function setUpdatedAt(\DateTimeInterface $updatedAt): self | |||
{ | |||
$this->updatedAt = $updatedAt; | |||
return $this; | |||
} | |||
public function getTicketTypesNotification(): ?array | |||
{ | |||
return $this->ticketTypesNotification; | |||
} | |||
public function setTicketTypesNotification(?array $ticketTypesNotification): self | |||
{ | |||
$this->ticketTypesNotification = $ticketTypesNotification; | |||
return $this; | |||
} | |||
/** | |||
* @return Collection|ReductionCreditInterface[] | |||
*/ |
@@ -12,10 +12,4 @@ class MerchantRepositoryQuery extends AbstractRepositoryQuery | |||
parent::__construct($repository, 'r', $paginator); | |||
} | |||
public function filterByDevAlias(string $devAlias) | |||
{ | |||
return $this->andWhere('.devAlias LIKE :devAlias') | |||
->setParameter('devAlias', $devAlias); | |||
} | |||
} |
@@ -15,10 +15,4 @@ class SectionRepositoryQuery extends AbstractRepositoryQuery | |||
parent::__construct($repository, 'r', $paginator); | |||
} | |||
public function filterByDevAlias(string $devAlias) | |||
{ | |||
return $this | |||
->andWhere('.devAlias LIKE :devAlias') | |||
->setParameter('devAlias', $devAlias); | |||
} | |||
} |
@@ -12,11 +12,6 @@ class PageRepositoryQuery extends SovPageRepositoryQuery | |||
use SectionRepositoryQueryTrait; | |||
use StatusRepositoryQueryTrait; | |||
public function filterByDevAlias(string $devAlias): self | |||
{ | |||
return $this | |||
->andWhere('.devAlias = :devAlias') | |||
->setParameter('devAlias', $devAlias); | |||
} | |||
} |
@@ -0,0 +1,63 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Solver\Address; | |||
class AddressSolver | |||
{ | |||
// 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 getLongitudeInherit() | |||
{ | |||
if ($this->getLongitudeOverride()) { | |||
return $this->getLongitudeOverride(); | |||
} else { | |||
return $this->getLongitude(); | |||
} | |||
} | |||
public function getLatitudeInherit() | |||
{ | |||
if ($this->getLatitudeOverride()) { | |||
return $this->getLatitudeOverride(); | |||
} else { | |||
return $this->getLatitude(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Solver\Order; | |||
use Lc\CaracoleBundle\Model\Order\OrderProductReductionCatalogInterface; | |||
class OrderProductReductionCatalogSolver | |||
{ | |||
// getSummaryOrderProductReductionCatalog | |||
public function getSummary(OrderProductReductionCatalogInterface $orderProductReductionCatalog) | |||
{ | |||
$text = ''; | |||
if ($orderProductReductionCatalog->getUnit() == 'amount') { | |||
$text .= '- ' . $orderProductReductionCatalog->getValue() . ' €'; | |||
} | |||
if ($orderProductReductionCatalog->getUnit() == 'percent') { | |||
$text .= '- ' . $orderProductReductionCatalog->getValue() . ' %'; | |||
} | |||
return $text; | |||
} | |||
// compareOrderProductReductionCatalog | |||
public function compare( | |||
OrderProductReductionCatalogInterface $orderProductReductionCatalog, | |||
OrderProductReductionCatalogInterface $orderProductReductionCatalogCompare | |||
) { | |||
return $orderProductReductionCatalogCompare | |||
&& $orderProductReductionCatalog->getUnit() == $orderProductReductionCatalogCompare->getUnit() | |||
&& (string)$orderProductReductionCatalog->getValue( | |||
) == (string)$orderProductReductionCatalogCompare->getValue() | |||
&& $orderProductReductionCatalog->getBehaviorTaxRate( | |||
) == $orderProductReductionCatalogCompare->getBehaviorTaxRate(); | |||
} | |||
} |
@@ -2,7 +2,11 @@ | |||
namespace Lc\CaracoleBundle\Solver\Order; | |||
use Lc\CaracoleBundle\Model\File\DocumentInterface; | |||
use Lc\CaracoleBundle\Model\File\DocumentModel; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderStatusInterface; | |||
use Lc\CaracoleBundle\Model\Order\OrderStatusModel; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||
use Lc\CaracoleBundle\Model\Product\ProductInterface; | |||
@@ -113,4 +117,29 @@ class OrderShopSolver | |||
return $this->priceSolver->getTotalWithTax($orderShop) - $this->getTotalOrderPayments($orderShop); | |||
} | |||
public function getOrderStatusHistory(OrderShopInterface $orderShop, OrderStatusInterface $status) | |||
{ | |||
$orderStatusHistories = $orderShop->getOrderStatusHistories(); | |||
if (count($orderStatusHistories) > 0) { | |||
foreach ($orderStatusHistories as $orderStatusHistory) { | |||
if ($orderStatusHistory->getOrderStatus() === $status) { | |||
return $orderStatusHistory; | |||
} | |||
} | |||
} | |||
return null; | |||
} | |||
public function getDocumentInvoice(OrderShopInterface $orderShop): ?DocumentInterface | |||
{ | |||
foreach ($orderShop->getDocuments() as $document) { | |||
if ($document->getType() == DocumentModel::TYPE_INVOICE) { | |||
return $document; | |||
} | |||
} | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,46 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Solver\Reduction; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
class ReductionCartSolver | |||
{ | |||
// isReductionCartMatchWithUser | |||
public function matchWithUser(ReductionCartInterface $reductionCart, UserInterface $user) | |||
{ | |||
$conditionUser = false; | |||
if ($user) { | |||
if ($reductionCart->getUsers()->isEmpty() || $reductionCart->getUsers()->contains($user)) { | |||
$conditionUser = true; | |||
} | |||
} | |||
return $conditionUser; | |||
} | |||
// isReductionCartMatchWithGroupUser | |||
public function matchWithGroupUser(ReductionCartInterface $reductionCart, UserInterface $user) | |||
{ | |||
$conditionGroupUser = false; | |||
if ($user) { | |||
if ($user->getGroupUsers() && count($user->getGroupUsers()) > 0) { | |||
foreach ($user->getGroupUsers() as $groupUser) { | |||
if ($reductionCart->getGroupUsers()->isEmpty() || $reductionCart->getGroupUsers()->contains($groupUser)) { | |||
$conditionGroupUser = true; | |||
} | |||
} | |||
} else { | |||
if ($reductionCart->getGroupUsers()->isEmpty()) { | |||
$conditionGroupUser = true; | |||
} | |||
} | |||
} | |||
return $conditionGroupUser; | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Solver\Section; | |||
class SectionSolver | |||
{ | |||
// @TODO : à voir si pertinent | |||
public function getNewsletter() | |||
{ | |||
$newsletters = $this->getNewsletters(); | |||
foreach ($newsletters as $newsletter) { | |||
if ($newsletter->getIsMain()) { | |||
return $newsletter; | |||
} | |||
} | |||
return false; | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Solver\Ticket; | |||
use Lc\CaracoleBundle\Model\Ticket\TicketModel; | |||
use Lc\SovBundle\Solver\Ticket\TicketSolver as SovTicketSolver; | |||
class TicketSolver extends SovTicketSolver | |||
{ | |||
public function getTypeChoices(): array | |||
{ | |||
$choices = parent::getTypeChoices(); | |||
$choicesProduct = [ | |||
TicketModel::TYPE_PRODUCT_UNAVAILABLE, | |||
TicketModel::TYPE_PRODUCT_ERROR | |||
]; | |||
return array_merge($choices, $choicesProduct); | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
<?php | |||
namespace Lc\CaracoleBundle\Solver\User; | |||
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Solver\User\UserSolver as SovUserSolver; | |||
class UserSolver extends SovUserSolver | |||
{ | |||
// isUserLinkedToPointSale | |||
public function isLinkedToPointSale(UserInterface $user, PointSaleInterface $pointSale): bool | |||
{ | |||
foreach ($user->getUserPointSales() as $userPointSale) { | |||
if ($userPointSale->getPointSale()->getId() == $pointSale->getId()) { | |||
return true; | |||
} | |||
} | |||
return false; | |||
} | |||
} |