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[] |
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') |
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 |
</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> |
</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 %} | ||||
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 ; | |||||
} | |||||
} | } | ||||
$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."); |