Explorar el Código

Modifications PriceUtils, OrderShop, Address

feature/export_comptable
Guillaume hace 4 años
padre
commit
0958ace284
Se han modificado 4 ficheros con 61 adiciones y 15 borrados
  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 Ver fichero

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

namespace Lc\ShopBundle\Context ;

interface PriceUtilsInterface
{

}

+ 1
- 1
ShopBundle/Model/Address.php Ver fichero

@@ -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

+ 17
- 0
ShopBundle/Model/OrderShop.php Ver fichero

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

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

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

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 Ver fichero

@@ -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) {
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

Cargando…
Cancelar
Guardar