Selaa lähdekoodia

PriceUtils : adaptations totaux

feature/export_comptable
Guillaume 4 vuotta sitten
vanhempi
commit
6b357eef22
4 muutettua tiedostoa jossa 70 lisäystä ja 22 poistoa
  1. +2
    -1
      ShopBundle/Model/OrderProduct.php
  2. +0
    -1
      ShopBundle/Model/OrderProductReductionCatalog.php
  3. +18
    -17
      ShopBundle/Services/OrderUtils.php
  4. +50
    -3
      ShopBundle/Services/PriceUtils.php

+ 2
- 1
ShopBundle/Model/OrderProduct.php Näytä tiedosto

@@ -58,7 +58,8 @@ abstract class OrderProduct implements PriceInterface
{
$product = $this->getProduct() ;
$productFamily = $product->getProductFamily() ;
$titleProduct = $product->getTitleInherited() ;

$titleProduct = $product->getTitle() ;
$titleProductFamily = $productFamily->getTitle() ;

if(strlen($titleProduct) > 0 && strlen($titleProductFamily) > 0) {

+ 0
- 1
ShopBundle/Model/OrderProductReductionCatalog.php Näytä tiedosto

@@ -17,7 +17,6 @@ abstract class OrderProductReductionCatalog implements OrderProductReductionCata
*/
protected $title;


public function getTitle(): ?string
{
return $this->title;

+ 18
- 17
ShopBundle/Services/OrderUtils.php Näytä tiedosto

@@ -162,22 +162,6 @@ class OrderUtils
return $count;
}

public function calculateTotalWithTax($orderShop)
{
return $this->calculateTotalWithTaxByOrderProducts($orderShop->getOrderProducts());
}

public function calculateTotalWithTaxByOrderProducts($orderProducts = [])
{
$totalWithTax = 0;

foreach ($orderProducts as $orderProduct) {
$totalWithTax += $this->priceUtils->getPriceWithTax($orderProduct) * $orderProduct->getQuantityOrder();
}

return $totalWithTax;
}

public function orderProductsByParentCategory($orderShop = null)
{
$categoriesArray = [];
@@ -202,10 +186,27 @@ class OrderUtils

$data = [] ;
$data['count'] = $this->countQuantities($orderShop) ;
$data['total_with_tax'] = $this->calculateTotalWithTax($orderShop) ;
$data['total_with_tax'] = $this->priceUtils->getTotalWithTaxAndReduction($orderShop) ;
$data['categories'] = $this->orderProductsByParentCategory($orderShop) ;

return $data ;
}

public function getSummaryOrderProductReductionCatalog($orderProductReductionCatalog)
{
$text = '' ;

if($orderProductReductionCatalog) {
if($orderProductReductionCatalog->getUnit() == 'amount') {
$text .= '- '.$orderProductReductionCatalog->getValue().' €' ;
}

if($orderProductReductionCatalog->getUnit() == 'percent') {
$text .= '- '.$orderProductReductionCatalog->getValue().' %' ;
}
}

return $text ;
}

}

+ 50
- 3
ShopBundle/Services/PriceUtils.php Näytä tiedosto

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

use Lc\ShopBundle\Context\OrderProductInterface;
use Lc\ShopBundle\Context\OrderShopInterface;
use Lc\ShopBundle\Context\ProductFamilyInterface;
use Lc\ShopBundle\Context\ProductInterface;
use Lc\ShopBundle\Context\ProductPropertyInterface;
@@ -88,6 +89,13 @@ class PriceUtils
if($entity instanceof OrderProductInterface) {
return $entity->getQuantityOrder() * $this->getPrice($entity) ;
}
if($entity instanceof OrderShopInterface) {
$total = 0 ;
foreach($entity->getOrderProducts() as $orderProduct) {
$total += $this->getTotal($orderProduct) ;
}
return $total ;
}
return null ;
}

@@ -99,6 +107,16 @@ class PriceUtils
$entity->getTaxRateInherited()->getValue()
) ;
}
if($entity instanceof OrderShopInterface) {
$total = 0 ;
foreach($entity->getOrderProducts() as $orderProduct) {
$total += $this->getTotalWithTax($orderProduct) ;
}
return $total ;
}
if($entity instanceof OrderShopInterface) {
return $this->getTotalWithTaxByOrderProducts($entity->getOrderProducts()) ;
}
return null ;
}

@@ -111,6 +129,32 @@ class PriceUtils
$this->getTotalWithTax($entity)
) ;
}

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

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

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

return $totalWithTax;
}

public function getTotalWithTaxAndReductionByOrderProducts($orderProducts)
{
$totalWithTax = 0;

foreach ($orderProducts as $orderProduct) {
$totalWithTax += $this->getTotalWithTaxAndReduction($orderProduct);
}

return $totalWithTax;
}

public function getPriceWithTaxAndReductionCatalog($entity, $price, $priceWithTax, $reductionCatalog = null): ?float
@@ -132,8 +176,12 @@ class PriceUtils
}

if($entity instanceof OrderProductInterface) {
// OrderProductReductionCatalog
$reductionCatalog = null ;
$orderProductReductionCatalog = $entity->getOrderProductReductionCatalog() ;
if($orderProductReductionCatalog) {
$reductionCatalogValue = $orderProductReductionCatalog->getValue() ;
$reductionCatalogUnit = $orderProductReductionCatalog->getUnit() ;
$reductionCatalogBehaviorTaxRate = $orderProductReductionCatalog->getBehaviorTaxRate() ;
}
}
}

@@ -166,7 +214,6 @@ class PriceUtils
return $priceWithTax ;
}


public function applyTax($price, $taxRateValue)
{
return $this->round($this->applyPercent($price, $taxRateValue)) ;

Loading…
Peruuta
Tallenna