Browse Source

[Backend] Produits : édition avancée

feature/tableau_edition_avancee
Guillaume 4 years ago
parent
commit
cb3b576e53
7 changed files with 76 additions and 18 deletions
  1. +5
    -0
      ShopBundle/Model/PriceTrait.php
  2. +20
    -0
      ShopBundle/Model/ProductFamily.php
  3. +5
    -3
      ShopBundle/Model/ProductPropertyTrait.php
  4. +18
    -12
      ShopBundle/Resources/views/backend/default/block/actions.html.twig
  5. +1
    -1
      ShopBundle/Resources/views/backend/default/list.html.twig
  6. +12
    -2
      ShopBundle/Services/Price/ProductPriceUtils.php
  7. +15
    -0
      ShopBundle/Services/ProductFamilyUtils.php

+ 5
- 0
ShopBundle/Model/PriceTrait.php View File

@@ -46,6 +46,11 @@ trait PriceTrait
return $this->getTaxRate() ;
}

public function getBuyingPriceInherited(): ?float
{
return $this->getBuyingPrice() ;
}

public function getBuyingPrice(): ?float
{
return $this->buyingPrice;

+ 20
- 0
ShopBundle/Model/ProductFamily.php View File

@@ -840,4 +840,24 @@ abstract class ProductFamily extends AbstractDocumentEntity implements ProductPr

return false ;
}

public function getFieldBuyingPrice()
{
if($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_PIECE) {
return 'buyingPrice' ;
}
elseif($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT) {
return 'buyingPriceByRefUnit' ;
}
}

public function getFieldPrice()
{
if($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_PIECE) {
return 'price' ;
}
elseif($this->getBehaviorPrice() === self::BEHAVIOR_PRICE_BY_REFERENCE_UNIT) {
return 'priceByRefUnit' ;
}
}
}

+ 5
- 3
ShopBundle/Model/ProductPropertyTrait.php View File

@@ -40,14 +40,16 @@ trait ProductPropertyTrait
*/
protected $propertyExpirationDate;




public function getBuyingPriceByRefUnit(): ?float
{
return $this->buyingPriceByRefUnit;
}

public function getBuyingPriceByRefUnitInherited(): ?float
{
return $this->getBuyingPriceByRefUnit() ;
}

public function setBuyingPriceByRefUnit(?float $buyingPriceByRefUnit): self
{
$this->buyingPriceByRefUnit = $buyingPriceByRefUnit;

+ 18
- 12
ShopBundle/Resources/views/backend/default/block/actions.html.twig View File

@@ -1,30 +1,36 @@
{% set dropdownAction ={} %}
{% for action in actions %}


{% if action.group is defined and action.group==true %}
{% set dropdownAction = dropdownAction|merge({(loop.index0): action}) %}
{% else %}
{% set display_button = true %}

{% if 'list' == action.name %}
{% set action_href = request_parameters.referer|default('') ? request_parameters.referer|easyadmin_urldecode : path('easyadmin', request_parameters|merge({ action: 'list' })) %}
{% elseif 'method' == action.type %}
{% set action_href = path('easyadmin', request_parameters|merge({ action: action.name, id: item_id })) %}
{% elseif 'route' == action.type %}
{% set action_href = path(action.name, request_parameters|merge({ action: action.name, id: item_id })) %}
{% elseif 'advanced_editing' == action.type %}
{% elseif 'productfamily_advanced_editing' == action.type %}
{% set action_href = path('easyadmin', request_parameters|merge({ action: action.action, id: item_id })) %}
{% if action.name == 'products' and not item.activeProducts %}
{% set display_button = false %}
{% endif %}
{% endif %}

{{ include(action.template, {
action: action,
action_href: action_href,
is_dropdown: is_dropdown|default(false),
item: item,
item_id: item_id,
request_parameters: request_parameters,
translation_domain: translation_domain,
trans_parameters: trans_parameters,
}, with_context = false) }}
{% if display_button %}
{{ include(action.template, {
action: action,
action_href: action_href,
is_dropdown: is_dropdown|default(false),
item: item,
item_id: item_id,
request_parameters: request_parameters,
translation_domain: translation_domain,
trans_parameters: trans_parameters,
}, with_context = false) }}
{% endif %}
{% endif %}
{% endfor %}
{% if dropdownAction|length > 0 %}

+ 1
- 1
ShopBundle/Resources/views/backend/default/list.html.twig View File

@@ -294,7 +294,7 @@


<td class="{{ isSortingField ? 'sorted' }} {{ metadata.dataType|lower }} {{ metadata.css_class }}" {{ easyadmin_config('design.rtl') ? 'dir="rtl"' }}>
{% if (field == 'title' or field== 'id') and (metadata.dataType=="string" or metadata.dataType=="integer") %}
{% if (field == 'title' or field== 'id') and (metadata.dataType=="string" or metadata.dataType=="integer") and _entity_config.name != 'ProductFamilyAdvancedEditing' %}
<a class="link-as-text"
href="{{ path('easyadmin', {'action':'edit', 'entity':_entity_config.name, 'id': item.id}) }}">
{{ easyadmin_render_field_for_list_view(_entity_config.name, item, metadata) }}

+ 12
- 2
ShopBundle/Services/Price/ProductPriceUtils.php View File

@@ -85,13 +85,23 @@ class ProductPriceUtils

if ($product->getQuantityInherited() > 0) {
return $product->getBuyingPriceByRefUnitInherited() * ($product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient());
}else{
}
else{
return 0;
}
}
}

public function getMultiplyingFactor(ProductPropertyInterface $product){
public function getBuyingPriceWithTax(ProductPropertyInterface $product)
{
return $this->applyTax(
$this->getBuyingPrice($product),
$product->getTaxRateInherited()->getValue()
);
}

public function getMultiplyingFactor(ProductPropertyInterface $product)
{
return $this->round($this->getPriceWithTax($product) / $this->getBuyingPrice($product));
}


+ 15
- 0
ShopBundle/Services/ProductFamilyUtils.php View File

@@ -176,4 +176,19 @@ class ProductFamilyUtils
}
}

public function getMultiplyingFactor($productFamily)
{
if($productFamily->getBehaviorPrice() == ProductFamily::BEHAVIOR_PRICE_BY_PIECE) {
if($productFamily->getBuyingPrice() > 0) {
return number_format($this->priceUtils->getPriceWithTax($productFamily) / $productFamily->getBuyingPrice(), 3) ;
}
}
elseif($productFamily->getBehaviorPrice() == ProductFamily::BEHAVIOR_PRICE_BY_REFERENCE_UNIT) {
if($productFamily->getBuyingPriceByRefUnit() > 0) {
return number_format($this->priceUtils->getPriceByRefUnitWithTax($productFamily) / $productFamily->getBuyingPriceByRefUnit(), 3) ;
}
}

}

}

Loading…
Cancel
Save