소스 검색

Modifications PriceUtils, OrderShop, Address

feature/export_comptable
Guillaume 4 년 전
부모
커밋
0958ace284
4개의 변경된 파일61개의 추가작업 그리고 15개의 파일을 삭제
  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 파일 보기

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

namespace Lc\ShopBundle\Context ;

interface PriceUtilsInterface
{

}

+ 1
- 1
ShopBundle/Model/Address.php 파일 보기

@@ -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 파일 보기

@@ -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 파일 보기

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

Loading…
취소
저장