Browse Source

Modifications PriceUtils, OrderShop, Address

feature/export_comptable
Guillaume 4 years ago
parent
commit
0958ace284
4 changed files with 61 additions and 15 deletions
  1. +8
    -0
      ShopBundle/Context/PriceUtilsInterface.php
  2. +1
    -1
      ShopBundle/Model/Address.php
  3. +17
    -0
      ShopBundle/Model/OrderShop.php
  4. +35
    -14
      ShopBundle/Services/PriceUtils.php

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

<?php

namespace Lc\ShopBundle\Context ;

interface PriceUtilsInterface
{

}

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



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


public function getUser(): ?User public function getUser(): ?User

+ 17
- 0
ShopBundle/Model/OrderShop.php View File

*/ */
protected $documentDeliveryNote; protected $documentDeliveryNote;


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

public function __construct() public function __construct()
{ {
$this->orderStatusHistories = new ArrayCollection(); $this->orderStatusHistories = new ArrayCollection();


return $this; return $this;
} }

public function getInfosShipping(): ?string
{
return $this->infosShipping;
}

public function setInfosShipping(?string $infosShipping): self
{
$this->infosShipping = $infosShipping;

return $this;
}
} }

+ 35
- 14
ShopBundle/Services/PriceUtils.php View File



namespace Lc\ShopBundle\Services ; namespace Lc\ShopBundle\Services ;


use Doctrine\Common\Collections\Collection;
use Lc\ShopBundle\Context\OrderProductInterface; use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderShopInterface; use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface; use Lc\ShopBundle\Context\ProductFamilyInterface;
return $total ; return $total ;
} }
if($entity instanceof OrderShopInterface) { if($entity instanceof OrderShopInterface) {
return $this->getTotalWithTaxByOrderProducts($entity->getOrderProducts()) ;
return $this->getTotalOrderProducts($entity->getOrderProducts(), true) ;
} }
return null ; return null ;
} }
} }


if($entity instanceof OrderShopInterface) { 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) {
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 public function getPriceWithTaxAndReductionCatalog($entity, $price, $priceWithTax, $reductionCatalog = null): ?float

Loading…
Cancel
Save