Browse Source

Merge Export comptable

feature/tableau_edition_avancee
Fab 4 years ago
parent
commit
7c09238d20
7 changed files with 123 additions and 34 deletions
  1. +10
    -0
      ShopBundle/Model/OrderShop.php
  2. +14
    -0
      ShopBundle/Repository/CreditHistoryRepository.php
  3. +2
    -0
      ShopBundle/Resources/translations/lcshop.fr.yaml
  4. +1
    -1
      ShopBundle/Resources/views/backend/default/layout/layout.html.twig
  5. +18
    -9
      ShopBundle/Resources/views/backend/form/custom_bootstrap_4.html.twig
  6. +76
    -22
      ShopBundle/Services/Price/OrderShopPriceUtils.php
  7. +2
    -2
      ShopBundle/Services/Price/PriceUtils.php

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

return $this; return $this;
} }


public function getDocumentInvoice(): Document
{
foreach($this->getDocuments() as $document) {
if($document->getType() == Document::TYPE_INVOICE) {
return $document ;
}
}

return false ;
}


/** /**
* @return Collection|Ticket[] * @return Collection|Ticket[]

+ 14
- 0
ShopBundle/Repository/CreditHistoryRepository.php View File

return CreditHistoryInterface::class; return CreditHistoryInterface::class;
} }


public function findAllByDateStartEnd($merchant, $dateStart, $dateEnd)
{
return $this->createQueryBuilder('e')
->innerJoin('e.userMerchant', 'user_merchant')
->andWhere('user_merchant.merchant = :merchant')
->setParameter(':merchant', $merchant)
->andWhere('e.createdAt >= :dateStart')
->andWhere('e.createdAt <= :dateEnd')
->setParameter(':dateStart', $dateStart)
->setParameter(':dateEnd', $dateEnd)
->addOrderBy('e.createdAt', 'ASC')
->getQuery()->getResult();
}

public function findAllByUserMerchant($userMerchant) public function findAllByUserMerchant($userMerchant)
{ {
return $this->createQueryBuilder('e') return $this->createQueryBuilder('e')

+ 2
- 0
ShopBundle/Resources/translations/lcshop.fr.yaml View File

total: Total total: Total
products: Produits products: Produits
purchaseOrderEmailContent: "Contenu par défaut de l'email envoyé aux producteurs" purchaseOrderEmailContent: "Contenu par défaut de l'email envoyé aux producteurs"
dateStart: Date de début
dateEnd: Date de fin


PointSale: PointSale:
code: Code code: Code

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

</div> </div>


{% block content_reminders %} {% block content_reminders %}
{% if reminders|length >0 %}
{% if reminders is defined and reminders|length >0 %}
<div class="head-reminders card card-outline card-danger"> <div class="head-reminders card card-outline card-danger">
{% include '@LcShop/backend/default/block/list_reminders.html.twig' %} {% include '@LcShop/backend/default/block/list_reminders.html.twig' %}
</div> </div>

+ 18
- 9
ShopBundle/Resources/views/backend/form/custom_bootstrap_4.html.twig View File

</div> </div>
{% endif %}#} {% endif %}#}


{# {% set labelHelp = 'field.'~easyadmin['entity']['name']~'.'~name~'Help' %}
{% if labelHelp|trans({}, 'lcshop') == labelHelp %}{% set labelHelp = 'form.field.default.'~name~'Help' %}{% endif %}
{% if labelHelp|trans({}, 'lcshop') != labelHelp %}
<small class="form-text text-muted">{{ labelHelp|trans({}, 'lcshop')|raw }}</small>

{% if easyadmin is defined %}
{% set labelHelp = 'field.'~easyadmin['entity']['name']~'.'~name~'Help' %}
{% if labelHelp|trans({}, 'lcshop') == labelHelp %}{% set labelHelp = 'form.field.default.'~name~'Help' %}{% endif %}
{% if labelHelp|trans({}, 'lcshop') != labelHelp %}
<small class="form-text text-muted">{{ labelHelp|trans({}, 'lcshop')|raw }}</small>
{% endif %}
{% endif %} {% endif %}
#}
{{- form_errors(form) -}} {{- form_errors(form) -}}
</div> </div>
</div> </div>
{% if 'field.MerchantConfig.' in label %} {% if 'field.MerchantConfig.' in label %}
{% set name_trad = label|replace({'field.MerchantConfig.': ''}) %} {% set name_trad = label|replace({'field.MerchantConfig.': ''}) %}
{% set trad = name_trad|lc_trad(easyadmin['entity']['name'], 'field') %} {% set trad = name_trad|lc_trad(easyadmin['entity']['name'], 'field') %}
{% elseif easyadmin['entity']['name'] is defined %}
{% set trad = name|lc_trad(easyadmin['entity']['name'], 'field') %}

{% else %} {% else %}
{% set trad = label %}
{% if easyadmin is defined %}
{% set trad = name|lc_trad(easyadmin['entity']['name'], 'field') %}
{% else %}
{% set trad = name|lc_trad('', 'field') %}
{% endif %}

{% endif %} {% endif %}


{%- endif -%} {%- endif -%}
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ trad }}</{{ element|default('label') }}>
{% if trad is defined %}
<{{ element|default('label') }}{% if label_attr %}{% with { attr: label_attr } %}{{ block('attributes') }}{% endwith %}{% endif %}>{{ trad }}</{{ element|default('label') }}>
{% endif %}
{%- endif -%} {%- endif -%}
{%- endblock form_label %} {%- endblock form_label %}



+ 76
- 22
ShopBundle/Services/Price/OrderShopPriceUtils.php View File

return $total; return $total;
} }



//Inclus les ReductionCatalog des OrderProducts //Inclus les ReductionCatalog des OrderProducts
public function getMarginOrderProducts(OrderShopInterface $orderShop): float public function getMarginOrderProducts(OrderShopInterface $orderShop): float
{ {
return $total; return $total;
} }


public function getMarginOrderProductsWithReductions(OrderShopInterface $orderShop): float
{
$total = $this->getMarginOrderProducts($orderShop);

$totalReductionAmount = 0;
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$totalReductionAmount += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart);
}

foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$totalReductionAmount += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit);
}

$total -= $totalReductionAmount;

return $total;
}

public function getMarginOrderProductsWithReductionsPercent(OrderShopInterface $orderShop): float
{
if ($this->getTotalOrderProducts($orderShop)) {
return $this->round($this->getMarginOrderProductsWithReductions($orderShop) / $this->getTotalOrderProductsWithReductions($orderShop) * 100);
} else {
return 0;
}
}

public function getMarginOrderProductsPercent(OrderShopInterface $orderShop): float public function getMarginOrderProductsPercent(OrderShopInterface $orderShop): float
{ {
if ($this->getTotalOrderProducts($orderShop)) { if ($this->getTotalOrderProducts($orderShop)) {
} else { } else {
return 0; return 0;
} }

} }


public function getBrandTaxesOrderProductsWithReductionsPercent(OrderShopInterface $orderShop): float
{
if ($this->getTotalOrderProducts($orderShop)) {
return $this->round($this->getMarginOrderProducts($orderShop) / $this->getTotalBuyingPriceOrderProducts($orderShop->getOrderProducts()) * 100);
} else {
return 0;
}
}


public function getTotalOrderProductsWithTax(OrderShopInterface $orderShop): float public function getTotalOrderProductsWithTax(OrderShopInterface $orderShop): float
{ {
return $this->getTotalOrderProductsWithTaxByOrderProducts($orderShop->getOrderProducts()); return $this->getTotalOrderProductsWithTaxByOrderProducts($orderShop->getOrderProducts());
} }


public function getTotalBuyingPriceOrderProducts($orderProducts): float
{
$total = 0;

foreach ($orderProducts as $orderProduct) {
$total += $this->orderProductPriceUtils->getTotalBuyingPrice($orderProduct);
}

return $total;
}

public function getTotalBuyingPriceOrderProductsWithTax($orderProducts): float public function getTotalBuyingPriceOrderProductsWithTax($orderProducts): float
{ {
$total = 0; $total = 0;
return $total; return $total;
} }



public function getMarginOrderProductsWithReductions(OrderShopInterface $orderShop): float
{
$total = $this->getMarginOrderProducts($orderShop);

$totalReductionAmount = 0;
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$totalReductionAmount += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart);
}

foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$totalReductionAmount += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit);
}

$total -= $totalReductionAmount;

return $total;
}


public function getTotalOrderProductsWithTaxAndReductionCarts(OrderShopInterface $orderShop) public function getTotalOrderProductsWithTaxAndReductionCarts(OrderShopInterface $orderShop)
{ {
$total = $this->getTotalOrderProductsWithTax($orderShop); $total = $this->getTotalOrderProductsWithTax($orderShop);


return $amountWithTax; return $amountWithTax;
} }

public function getTotalReductions(OrderShopInterface $orderShop)
{
$total = 0 ;

foreach($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$total += $this->getOrderProductsReductionCartAmountWithoutTax($orderShop, $orderReductionCart) ;
}

foreach($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$total += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit) ;
}

return $total ;
}

public function getTotalReductionsWithTax(OrderShopInterface $orderShop)
{
$total = 0 ;

foreach($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$total += $this->getOrderProductsReductionCartAmountWithTax($orderShop, $orderReductionCart) ;
}

foreach($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
$total += $this->getOrderProductsReductionCreditAmountWithTax($orderShop, $orderReductionCredit) ;
}

return $total ;
}
} }



+ 2
- 2
ShopBundle/Services/Price/PriceUtils.php View File

$service = 'orderProductPriceUtils'; $service = 'orderProductPriceUtils';
} }


if ($entity instanceof OrderShopInterface || is_array($entity)) {
if ($entity instanceof OrderShopInterface || is_iterable($entity) || is_array($entity)) {
$service = 'orderShopPriceUtils'; $service = 'orderShopPriceUtils';
} }


} }
} else { } else {
if (!strlen($service)) { if (!strlen($service)) {
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré.");
throw new \ErrorException("PriceUtils : le type d'entité n'est pas géré");
} else { } else {
if (!method_exists($this->$service, $name)) { if (!method_exists($this->$service, $name)) {
throw new \ErrorException("PriceUtils : la méthode " . $name . " du service " . $service . " n'existe pas."); throw new \ErrorException("PriceUtils : la méthode " . $name . " du service " . $service . " n'existe pas.");

Loading…
Cancel
Save