Browse Source

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/LcShopBundle into develop

feature/export_comptable
Fab 4 years ago
parent
commit
8fb4fede07
28 changed files with 497 additions and 64 deletions
  1. +8
    -0
      ShopBundle/Context/DeliveryUtilsInterface.php
  2. +8
    -0
      ShopBundle/Context/PointSaleUtilsInterface.php
  3. +8
    -0
      ShopBundle/Context/PriceUtilsInterface.php
  4. +8
    -0
      ShopBundle/Context/UserPointSaleInterface.php
  5. +4
    -1
      ShopBundle/Controller/Admin/AdminController.php
  6. +2
    -2
      ShopBundle/Controller/CitiesController.php
  7. +1
    -1
      ShopBundle/Controller/Frontend/CartController.php
  8. +13
    -7
      ShopBundle/EventSubscriber/EditEventSubscriber.php
  9. +1
    -1
      ShopBundle/Model/Address.php
  10. +18
    -1
      ShopBundle/Model/OrderShop.php
  11. +43
    -3
      ShopBundle/Model/PointSale.php
  12. +9
    -0
      ShopBundle/Model/Product.php
  13. +38
    -0
      ShopBundle/Model/User.php
  14. +64
    -0
      ShopBundle/Model/UserPointSale.php
  15. +33
    -0
      ShopBundle/Repository/OrderShopRepository.php
  16. +0
    -11
      ShopBundle/Repository/PointSaleRepository.php
  17. +22
    -0
      ShopBundle/Repository/UserPointSaleRepository.php
  18. +3
    -3
      ShopBundle/Resources/views/backend/default/layout/layout.html.twig
  19. +41
    -0
      ShopBundle/Services/AddressUtils.php
  20. +17
    -1
      ShopBundle/Services/CityUtils.php
  21. +0
    -13
      ShopBundle/Services/CustomCKFinderAuth.phpRENAME
  22. +54
    -0
      ShopBundle/Services/DateUtils.php
  23. +18
    -0
      ShopBundle/Services/DeliveryUtils.php
  24. +3
    -3
      ShopBundle/Services/OrderUtils.php
  25. +43
    -0
      ShopBundle/Services/PointSaleUtils.php
  26. +36
    -15
      ShopBundle/Services/PriceUtils.php
  27. +1
    -1
      ShopBundle/Services/Utils.php
  28. +1
    -1
      ShopBundle/Twig/FrontendTwigExtension.php

+ 8
- 0
ShopBundle/Context/DeliveryUtilsInterface.php View File

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context ;

interface DeliveryUtilsInterface
{

}

+ 8
- 0
ShopBundle/Context/PointSaleUtilsInterface.php View File

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context;

interface PointSaleUtilsInterface
{

}

+ 8
- 0
ShopBundle/Context/PriceUtilsInterface.php View File

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context ;

interface PriceUtilsInterface
{

}

+ 8
- 0
ShopBundle/Context/UserPointSaleInterface.php View File

@@ -0,0 +1,8 @@
<?php

namespace Lc\ShopBundle\Context;

interface UserPointSaleInterface
{

}

+ 4
- 1
ShopBundle/Controller/Admin/AdminController.php View File

@@ -10,6 +10,7 @@ use FOS\UserBundle\Model\UserManagerInterface;
use Lc\ShopBundle\Context\FilterMultipleMerchantsInterface;
use Lc\ShopBundle\Context\MerchantInterface;
use Lc\ShopBundle\Context\MerchantUtilsInterface;
use Lc\ShopBundle\Context\OrderUtilsInterface;
use Lc\ShopBundle\Context\StatusInterface;
use Lc\ShopBundle\Context\TreeInterface;
use Lc\ShopBundle\Form\AbstractEditPositionType;
@@ -30,9 +31,10 @@ class AdminController extends EasyAdminController
protected $utils;
protected $merchantUtils ;
protected $mailjetTransport ;
protected $orderUtils ;

public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils,
MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport)
MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils)
{
$this->security = $security;
$this->userManager = $userManager;
@@ -40,6 +42,7 @@ class AdminController extends EasyAdminController
$this->utils = $utils;
$this->merchantUtils = $merchantUtils ;
$this->mailjetTransport = $mailjetTransport ;
$this->orderUtils = $orderUtils ;
}

/**

+ 2
- 2
ShopBundle/Controller/CitiesController.php View File

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Controller ;

use Lc\ShopBundle\Services\Cities;
use Lc\ShopBundle\Services\CityUtils;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
@@ -11,7 +11,7 @@ class CitiesController extends AbstractController
{
protected $cities ;

public function __construct(Cities $cities)
public function __construct(CityUtils $cities)
{
$this->cities = $cities ;
}

+ 1
- 1
ShopBundle/Controller/Frontend/CartController.php View File

@@ -47,7 +47,7 @@ class CartController extends BaseController
foreach($data as $orderProduct) {
if($orderProduct instanceof OrderProductInterface) {
$this->orderUtils->addOrderProduct($orderShop, $orderProduct) ;
if($orderProduct->getQuantityorder() > 0) {
if($orderProduct->getQuantityOrder() > 0) {
$this->orderProducts[] = $orderProduct ;
}
}

+ 13
- 7
ShopBundle/EventSubscriber/EditEventSubscriber.php View File

@@ -67,12 +67,14 @@ class EditEventSubscriber implements EventSubscriberInterface
return $entity;
}

private function setSortableProperty($entity, $entityRepo){
private function setSortableProperty($entity, $entityRepo)
{
if ($entity instanceof TreeInterface) {
if ($entity->getParent()) {
$total = $entityRepo->count(array('status' => 1, 'parent' => $entity->getParent()->getId()));
$entity->setPosition($entity->getParent()->getId() . '_' . $total);
} else {
$entity->setPosition((float) $entity->getParent()->getId() . '.' . str_pad($total, 2, '0', STR_PAD_LEFT));
}
else {
if ($entity instanceof FilterMerchantInterface) {
$total = $entityRepo->count(array('status' => 1, 'parent' => null, 'merchant' => $this->merchantUtils->getMerchantCurrent()));
}else{
@@ -80,10 +82,12 @@ class EditEventSubscriber implements EventSubscriberInterface
}
$entity->setPosition($total);
}
} else {
}
else {
if ($entity instanceof FilterMerchantInterface) {
$total = $entityRepo->count(array('status' => 1, 'merchant' => $this->merchantUtils->getMerchantCurrent()));
}else{
}
else {
$total = $entityRepo->count(array('status' => 1));
}
$entity->setPosition($total);
@@ -91,11 +95,13 @@ class EditEventSubscriber implements EventSubscriberInterface
return $entity;
}

private function setMerchantProperty($entity){
private function setMerchantProperty($entity)
{
$entity->setMerchant($this->merchantUtils->getMerchantCurrent());
}

private function setMultipleMerchantProperty($entity){
private function setMultipleMerchantProperty($entity)
{
if ($entity->getMerchants()->isEmpty()) {
$entity->addMerchant($this->merchantUtils->getMerchantCurrent());
}

+ 1
- 1
ShopBundle/Model/Address.php View File

@@ -98,7 +98,7 @@ abstract class Address extends AbstractEntity

public function __toString()
{
return $this->getTitle() ;
return $this->getTitle().' - '.$this->getZip().' '.$this->getCity() ;
}

public function getUser(): ?User

+ 18
- 1
ShopBundle/Model/OrderShop.php View File

@@ -11,7 +11,7 @@ use Lc\ShopBundle\Context\FilterMerchantInterface;
/**
* @ORM\MappedSuperclass()
*/
abstract class OrderShop implements FilterMerchantInterface
abstract class OrderShop extends AbstractEntity implements FilterMerchantInterface
{

/**
@@ -85,6 +85,11 @@ abstract class OrderShop implements FilterMerchantInterface
*/
protected $documentDeliveryNote;

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

public function __construct()
{
$this->orderStatusHistories = new ArrayCollection();
@@ -304,4 +309,16 @@ abstract class OrderShop implements FilterMerchantInterface

return $this;
}

public function getInfosDelivery(): ?string
{
return $this->infosDelivery;
}

public function setInfosDelivery(?string $infosDelivery): self
{
$this->infosDelivery = $infosDelivery;

return $this;
}
}

+ 43
- 3
ShopBundle/Model/PointSale.php View File

@@ -2,6 +2,8 @@

namespace Lc\ShopBundle\Model;

use App\Entity\User;
use App\Entity\UserPointSale;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -36,15 +38,17 @@ abstract class PointSale extends AbstractDocumentEntity implements FilterMultipl
*/
protected $address;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\UserPointSaleInterface", mappedBy="pointSale", orphanRemoval=true)
*/
protected $userPointSales;

public function labelAdminChoice(){
return $this->getTitle();
}

public function __construct()
{
$this->merchants = new ArrayCollection();
$this->pointSaleDayInfos = new ArrayCollection();
$this->userPointSales = new ArrayCollection();
}

public function __toString()
@@ -52,6 +56,11 @@ abstract class PointSale extends AbstractDocumentEntity implements FilterMultipl
return $this->getTitle() ;
}

public function labelAdminChoice()
{
return $this->getTitle();
}

/**
* @return Collection|Merchant[]
*/
@@ -132,4 +141,35 @@ abstract class PointSale extends AbstractDocumentEntity implements FilterMultipl

return $this;
}

/**
* @return Collection|UserPointSale[]
*/
public function getUserPointSales(): Collection
{
return $this->userPointSales;
}

public function addUserPointSale(UserPointSale $userPointSale): self
{
if (!$this->userPointSales->contains($userPointSale)) {
$this->userPointSales[] = $userPointSale;
$userPointSale->setPointSale($this);
}

return $this;
}

public function removeUserPointSale(UserPointSale $userPointSale): self
{
if ($this->userPointSales->contains($userPointSale)) {
$this->userPointSales->removeElement($userPointSale);
// set the owning side to null (unless already changed)
if ($userPointSale->getPointSale() === $this) {
$userPointSale->setPointSale(null);
}
}

return $this;
}
}

+ 9
- 0
ShopBundle/Model/Product.php View File

@@ -108,6 +108,15 @@ abstract class Product extends AbstractEntity implements SortableInterface, Prod
return $quantity.$unit->getWordingShort() ;
}

public function getQuantityTitle($productFamily)
{
$title = $this->getQuantityLabelInherited() ;
if($productFamily->hasProductsWithVariousWeight()) {
$title .= ', '.$this->getTitleInherited() ;
}
return $title ;
}

public function getAvailableQuantityInherited()
{
if($this->getProductFamily()->getBehaviorCountStock()) {

+ 38
- 0
ShopBundle/Model/User.php View File

@@ -3,6 +3,7 @@
namespace Lc\ShopBundle\Model;

use App\Entity\Newsletter;
use App\Entity\UserPointSale;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@@ -80,6 +81,11 @@ abstract class User extends UserModelFOS
*/
protected $favoriteProductFamilies;

/**
* @ORM\OneToMany(targetEntity="Lc\ShopBundle\Context\UserPointSaleInterface", mappedBy="user", orphanRemoval=true)
*/
protected $userPointSales;


public function __construct()
{
@@ -91,6 +97,7 @@ abstract class User extends UserModelFOS
$this->groupUsers = new ArrayCollection();
$this->newsletters = new ArrayCollection();
$this->favoriteProductFamilies = new ArrayCollection();
$this->userPointSales = new ArrayCollection();
}

public function setEmail($email)
@@ -374,4 +381,35 @@ abstract class User extends UserModelFOS

return $this;
}

/**
* @return Collection|UserPointSale[]
*/
public function getUserPointSales(): Collection
{
return $this->userPointSales;
}

public function addUserPointSale(UserPointSale $userPointSale): self
{
if (!$this->userPointSales->contains($userPointSale)) {
$this->userPointSales[] = $userPointSale;
$userPointSale->setUser($this);
}

return $this;
}

public function removeUserPointSale(UserPointSale $userPointSale): self
{
if ($this->userPointSales->contains($userPointSale)) {
$this->userPointSales->removeElement($userPointSale);
// set the owning side to null (unless already changed)
if ($userPointSale->getUser() === $this) {
$userPointSale->setUser(null);
}
}

return $this;
}
}

+ 64
- 0
ShopBundle/Model/UserPointSale.php View File

@@ -0,0 +1,64 @@
<?php

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;

/**
* @ORM\MappedSuperclass
*/
abstract class UserPointSale
{
/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\UserInterface", inversedBy="userPointSales")
* @ORM\JoinColumn(nullable=false)
*/
protected $user;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\PointSaleInterface", inversedBy="userPointSales")
* @ORM\JoinColumn(nullable=false)
*/
protected $pointSale;

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

public function getUser(): ?User
{
return $this->user;
}

public function setUser(?User $user): self
{
$this->user = $user;

return $this;
}

public function getPointSale(): ?PointSale
{
return $this->pointSale;
}

public function setPointSale(?PointSale $pointSale): self
{
$this->pointSale = $pointSale;

return $this;
}

public function getComment(): ?string
{
return $this->comment;
}

public function setComment(?string $comment): self
{
$this->comment = $comment;

return $this;
}
}

+ 33
- 0
ShopBundle/Repository/OrderShopRepository.php View File

@@ -18,4 +18,37 @@ class OrderShopRepository extends BaseRepository implements DefaultRepositoryInt
return OrderShopInterface::class;
}

public function findCurrent($params)
{
$query = $this->createQueryBuilder('e') ;

if(isset($params['user'])) {
$query->andWhere('e.user = :user')->setParameter('user', $params['user']) ;
}

if(isset($params['visitor'])) {
$query->andWhere('e.visitor = :visitor')->setParameter('visitor', $params['visitor']) ;
}

$query->leftJoin('e.orderStatusHistories', 'orderStatusHistories')
->andWhere('SIZE(e.orderStatusHistories) = 0') ;

return $query->getQuery()->getOneOrNullResult() ;
}

public function findAllByDateStartEnd($dateStart, $dateEnd)
{
$query = $this->findByMerchantQuery()
->andWhere('e.createdAt >= :dateStart')
->setParameter('dateStart', $dateStart)
->andWhere('e.createdAt <= :dateEnd')
->setParameter('dateEnd', $dateEnd)
;

$query->leftJoin('e.orderStatusHistories', 'orderStatusHistories')
->andWhere('SIZE(e.orderStatusHistories) > 0') ;

return $query->getQuery()->getResult() ;
}

}

+ 0
- 11
ShopBundle/Repository/PointSaleRepository.php View File

@@ -19,17 +19,6 @@ class PointSaleRepository extends BaseRepository implements DefaultRepositoryInt
return PointSaleInterface::class;
}

public function findAllPublics()
{
return $this->createQueryBuilder('e')
->where(':currentMerchant MEMBER OF e.merchants')
->andWhere('e.isPublic = 1')
->andWhere('e.status = 1')
->setParameter('currentMerchant', $this->merchantUtils->getMerchantCurrent())
->getQuery()
->getResult() ;
}

public function findAllByMerchant()
{
return $this->createQueryBuilder('e')

+ 22
- 0
ShopBundle/Repository/UserPointSaleRepository.php View File

@@ -0,0 +1,22 @@
<?php

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\PointSaleInterface;


/**
* @method UserPointSaleInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method UserPointSaleInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method UserPointSaleInterface[] findAll()
* @method UserPointSaleInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class UserPointSaleRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return UserPointSaleInterface::class;
}

}

+ 3
- 3
ShopBundle/Resources/views/backend/default/layout/layout.html.twig View File

@@ -31,9 +31,10 @@
{% endblock %}

{% block head_custom_stylesheets %}

<link rel="stylesheet" href="{{ asset('bundles/lcshop/css/backend/custom.css') }}">

{% for asset_css in easyadmin_config('design.assets.css') %}
<link rel="stylesheet" href="{{ asset(asset_css) }}">
{% endfor %}
{% endblock head_custom_stylesheets %}

{#
@@ -48,7 +49,6 @@
{% set favicon = easyadmin_config('design.assets.favicon') %}
<link rel="icon" type="{{ favicon.mime_type }}" href="{{ asset(favicon.path) }}"/>
{% endblock %}

</head>

{% block body %}

+ 41
- 0
ShopBundle/Services/AddressUtils.php View File

@@ -0,0 +1,41 @@
<?php

namespace Lc\ShopBundle\Services ;

use Lc\ShopBundle\Context\AddressInterface;

class AddressUtils
{
public function getSummaryShort(AddressInterface $address)
{
return $address->getAddress().' - '.$address->getZip().' '.$address->getCity() ;
}

public function getSummary(AddressInterface $address)
{
$html = '' ;

if($address->getTitle()) {
$html .= $address->getTitle().'<br />' ;
}

if($address->getLastname() || $address->getFirstname()) {
$html .= $address->getLastname().' '.$address->getFirstname().'<br />' ;
}

if($address->getAddress()) {
$html .= $address->getAddress().'<br />' ;
}

if($address->getZip() || $address->getCity()) {
$html .= $address->getZip().' '.$address->getCity().'<br />' ;
}

if($address->getPhone()) {
$html .= 'Tél. '.$address->getPhone() ;
}

return $html ;
}

}

ShopBundle/Services/Cities.php → ShopBundle/Services/CityUtils.php View File

@@ -2,7 +2,7 @@

namespace Lc\ShopBundle\Services ;

class Cities
class CityUtils
{

function callApi($method, $url, $data = false)
@@ -39,4 +39,20 @@ class Cities

return $result;
}

public function getZipByCity($city)
{
$zip = null ;
$returnCitiesSearchZip = json_decode($this->callApi('get', 'communes', ['nom' => $city, 'fields' => 'nom,codesPostaux'])) ;

if($returnCitiesSearchZip) {
foreach($returnCitiesSearchZip as $citySearchZip) {
if(strtolower(trim($city)) == strtolower(trim($citySearchZip->nom))) {
$zip = $citySearchZip->codesPostaux[0] ;
}
}
}

return $zip ;
}
}

+ 0
- 13
ShopBundle/Services/CustomCKFinderAuth.phpRENAME View File

@@ -1,13 +0,0 @@
<?php

namespace Lc\ShopBundle\Services;

use CKSource\Bundle\CKFinderBundle\Authentication\Authentication as AuthenticationBase;

class CustomCKFinderAuth extends AuthenticationBase
{
public function authenticate()
{
return true;
}
}

+ 54
- 0
ShopBundle/Services/DateUtils.php View File

@@ -0,0 +1,54 @@
<?php

namespace Lc\ShopBundle\Services ;

class DateUtils
{
public function date($format, $timestamp)
{
setlocale(LC_TIME, 'fr_FR.UTF8', 'fr.UTF8', 'fr_FR.UTF-8', 'fr.UTF-8');
return strftime($format, $timestamp) ;
}

public function getNextDay($day)
{
return new \DateTime('next '.$day) ;
}

public function getNextDayByNumber($number)
{
return $this->getNextDay($this->getDayByNumber($number, 'en')) ;
}

public function getDayByNumber($number, $lang = 'fr')
{
if($lang == 'fr') {
$daysArray = [
1 => 'Lundi',
2 => 'Mardi',
3 => 'Mercredi',
4 => 'Jeudi',
5 => 'Vendredi',
6 => 'Samedi',
7 => 'Dimanche'
] ;
}
else {
$daysArray = [
1 => 'Monday',
2 => 'Tuesday',
3 => 'Wednesday',
4 => 'Thursday',
5 => 'Friday',
6 => 'Saturday',
7 => 'Sunday',
] ;
}

if(isset($daysArray[$number])) {
return $daysArray[$number] ;
}

return '' ;
}
}

+ 18
- 0
ShopBundle/Services/DeliveryUtils.php View File

@@ -0,0 +1,18 @@
<?php

namespace Lc\ShopBundle\Services ;

use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Security\Core\Security;

class DeliveryUtils
{
protected $em ;
protected $security ;

public function __construct(EntityManagerInterface $em, Security $security)
{
$this->em = $em ;
$this->security = $security ;
}
}

+ 3
- 3
ShopBundle/Services/OrderUtils.php View File

@@ -16,7 +16,7 @@ class OrderUtils
protected $security;
protected $userUtils;
protected $merchantUtils;
private $orderShopRepo;
protected $orderShopRepo;
protected $priceUtils ;
protected $productFamilyUtils ;

@@ -27,7 +27,7 @@ class OrderUtils
$this->security = $security;
$this->userUtils = $userUtils;
$this->merchantUtils = $merchantUtils;
$this->orderShopRepo = $this->em->getRepository(OrderShop::class);
$this->orderShopRepo = $this->em->getRepository($this->em->getClassMetadata(OrderShopInterface::class)->getName());
$this->priceUtils = $priceUtils ;
$this->productFamilyUtils = $productFamilyUtils ;
}
@@ -48,7 +48,7 @@ class OrderUtils
$paramsSearchOrderShop['visitor'] = $visitor;
}

$orderShop = $this->orderShopRepo->findOneBy($paramsSearchOrderShop);
$orderShop = $this->orderShopRepo->findCurrent($paramsSearchOrderShop);

if (!$orderShop) {
$orderShop = $this->createOrderShop([

+ 43
- 0
ShopBundle/Services/PointSaleUtils.php View File

@@ -0,0 +1,43 @@
<?php

namespace Lc\ShopBundle\Services ;

use Doctrine\ORM\EntityManagerInterface;
use Lc\ShopBundle\Context\PointSaleInterface;
use Lc\ShopBundle\Context\UserInterface;
use Lc\ShopBundle\Context\UserPointSaleInterface;

class PointSaleUtils
{
protected $em ;

public function __construct(EntityManagerInterface $em)
{
$this->em = $em ;
}

public function isUserLinkedToPointSale(UserInterface $user, PointSaleInterface $pointSale)
{
foreach($user->getUserPointSales() as $userPointSale) {
if($userPointSale->getPointSale()->getId() == $pointSale->getId()) {
return true ;
}
}
return false ;
}

public function linkUserToPointSale(UserInterface $user, PointSaleInterface $pointSale)
{
if(!$this->isUserLinkedToPointSale($user, $pointSale)) {
$userPointSaleClass = $this->em->getClassMetadata(UserPointSaleInterface::class)->getName();
$userPointSale = new $userPointSaleClass ;

$userPointSale->setUser($user) ;
$userPointSale->setPointSale($pointSale) ;

$this->em->persist($userPointSale);
$this->em->flush() ;
}
}

}

+ 36
- 15
ShopBundle/Services/PriceUtils.php View File

@@ -2,6 +2,7 @@

namespace Lc\ShopBundle\Services ;

use Doctrine\Common\Collections\Collection;
use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
@@ -115,7 +116,7 @@ class PriceUtils
return $total ;
}
if($entity instanceof OrderShopInterface) {
return $this->getTotalWithTaxByOrderProducts($entity->getOrderProducts()) ;
return $this->getTotalOrderProducts($entity->getOrderProducts(), true) ;
}
return null ;
}
@@ -131,30 +132,50 @@ class PriceUtils
}

if($entity instanceof OrderShopInterface) {
return $this->getTotalWithTaxAndReductionByOrderProducts($entity->getOrderProducts()) ;
return $this->getTotalOrderProductsWithTaxAndReduction($entity->getOrderProducts(), true, true) ;
}
}

public function getTotalWithTaxByOrderProducts($orderProducts)
public function getTotalOrderProducts($entity)
{
$totalWithTax = 0;

foreach ($orderProducts as $orderProduct) {
$totalWithTax += $this->getTotalWithTax($orderProduct);
}
return $this->getSumOrderProductsDispatch($entity) ;
}

return $totalWithTax;
public function getTotalOrderProductsWithTax($entity)
{
return $this->getSumOrderProductsDispatch($entity, true) ;
}

public function getTotalWithTaxAndReductionByOrderProducts($orderProducts)
public function getTotalOrderProductsWithTaxAndReduction($entity)
{
$totalWithTax = 0;
return $this->getSumOrderProductsDispatch($entity, true, true) ;
}

foreach ($orderProducts as $orderProduct) {
$totalWithTax += $this->getTotalWithTaxAndReduction($orderProduct);
public function getSumOrderProductsDispatch($entity, $withTax = false, $withReduction = false)
{
if($entity instanceof OrderShopInterface) {
return $this->getSumOrderProducts($entity->getOrderProducts(), $withTax, $withReduction) ;
}
if($entity instanceof Collection || is_array($entity)) {
return $this->getSumOrderProducts($entity, $withTax, $withReduction) ;
}
}

return $totalWithTax;
public function getSumOrderProducts($orderProducts, $withTax = false, $withReduction = false)
{
$total = 0 ;
foreach($orderProducts as $orderProduct) {
if($withTax && $withReduction) {
$total += $this->getTotalWithTaxAndReduction($orderProduct) ;
}
elseif($withTax) {
$total += $this->getTotalWithTax($orderProduct) ;
}
else {
$total += $this->getTotal($orderProduct) ;
}
}
return $total ;
}

public function getPriceWithTaxAndReductionCatalog($entity, $price, $priceWithTax, $reductionCatalog = null): ?float
@@ -199,7 +220,7 @@ class PriceUtils
$price,
$reductionCatalogValue
),
$this->getTaxRateInherited()->getValue()
$entity->getTaxRateInherited()->getValue()
);
}
elseif($reductionCatalogBehaviorTaxRate == 'tax-included') {

+ 1
- 1
ShopBundle/Services/Utils.php View File

@@ -22,6 +22,7 @@ class Utils
$this->parameterBag = $parameterBag ;
}

// @todo : À supprimer et passer dans DateUtils (gérer du coup le cas du modèle DeliverySlot qui dépend de cette fonction)
public static function getDayByNumber($number, $lang = 'fr')
{
if($lang == 'fr') {
@@ -54,7 +55,6 @@ class Utils
return '' ;
}


public function getElementByDevAlias($devAlias, $class = PageInterface::class)
{
$class = $this->em->getClassMetadata($class)->getName();

+ 1
- 1
ShopBundle/Twig/FrontendTwigExtension.php View File

@@ -96,7 +96,7 @@ class FrontendTwigExtension extends AbstractExtension

public function getProductCategories()
{
$categories = $this->productCategoryRepository->findAllParents($this->merchantUtils->getMerchantCurrent());
$categories = $this->productCategoryRepository->findAllParents(false);
return $categories;
}


Loading…
Cancel
Save