@@ -41,7 +41,7 @@ class AdminController extends EasyAdminController | |||
protected $translator; | |||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, | |||
MailjetTransport $mailjetTransport,UtilsManager $utilsManager, TranslatorInterface $translator) | |||
MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator) | |||
{ | |||
$this->security = $security; | |||
$this->userManager = $userManager; |
@@ -30,6 +30,7 @@ use Lc\ShopBundle\Model\CreditHistory; | |||
use Lc\ShopBundle\Model\OrderStatus; | |||
use Lc\ShopBundle\Services\CreditUtils; | |||
use Lc\ShopBundle\Services\Utils; | |||
use Lc\ShopBundle\Services\UtilsManager; | |||
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport; | |||
use Proxies\__CG__\App\Entity\OrderProduct; | |||
use Symfony\Bridge\Doctrine\Form\Type\EntityType; | |||
@@ -43,10 +44,10 @@ class OrderController extends AdminController | |||
{ | |||
protected $creditUtils; | |||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, Utils $utils, MerchantUtilsInterface $merchantUtils, MailjetTransport $mailjetTransport, OrderUtilsInterface $orderUtils, TranslatorInterface $translator, CreditUtils $creditUtils) | |||
public function __construct(Security $security, UserManagerInterface $userManager, EntityManagerInterface $em, MailjetTransport $mailjetTransport, UtilsManager $utilsManager, TranslatorInterface $translator) | |||
{ | |||
parent::__construct($security, $userManager, $em, $utils, $merchantUtils, $mailjetTransport, $orderUtils, $translator); | |||
$this->creditUtils = $creditUtils; | |||
$this->creditUtils = $utilsManager->getCreditUtils(); | |||
parent::__construct($security, $userManager, $em, $mailjetTransport, $utilsManager, $translator); | |||
} | |||
protected function createListQueryBuilder($entityClass, $sortDirection, $sortField = null, $dqlFilter = null) | |||
@@ -175,43 +176,7 @@ class OrderController extends AdminController | |||
return $this->createOrderAjaxReponse($orderShop); | |||
} | |||
public function orderProductsAction() | |||
{ | |||
$orderShop = $this->getOrderShopEntity(); | |||
$formOrderProducts = $this->createForm(OrderProductsType::class, $orderShop); | |||
$formOrderProducts->handleRequest($this->request); | |||
if ($formOrderProducts->isSubmitted() && $formOrderProducts->isValid()) { | |||
$error = false; | |||
// dump($formOrderProducts->get('orderProducts')->getData()); | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
if($orderProduct->isRedelivery() === false) { | |||
//TODO s'assurer que la commande n'est pas négativce | |||
if ($this->orderUtils->isProductAvailable($orderProduct->getProduct(), $orderProduct->getQuantityOrder())) { | |||
if ($orderProduct->getQuantityOrder() <= 0) { | |||
$this->em->remove($orderProduct); | |||
} else { | |||
$this->em->persist($orderProduct); | |||
} | |||
} else { | |||
$error = true; | |||
$this->utils->addFlash('error', 'error.order.productUnavailable'); | |||
} | |||
} | |||
} | |||
if (!$error) { | |||
$this->em->flush(); | |||
$this->utils->addFlash('success', 'success.order.editQuantity'); | |||
} | |||
} else { | |||
$this->utils->addFlash('error', 'error.form.submitted'); | |||
} | |||
return $this->createOrderAjaxReponse($orderShop); | |||
} | |||
public function orderInvoiceAddressAction() |
@@ -24,6 +24,13 @@ trait PriceTrait | |||
*/ | |||
protected $taxRate; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $buyingPrice; | |||
public function getPriceInherited(): ?float | |||
{ | |||
return $this->getPrice() ; | |||
@@ -39,6 +46,17 @@ trait PriceTrait | |||
return $this->getTaxRate() ; | |||
} | |||
public function getBuyingPrice(): ?float | |||
{ | |||
return $this->buyingPrice; | |||
} | |||
public function setBuyingPrice(?float $buyingPrice): self | |||
{ | |||
$this->buyingPrice = $buyingPrice; | |||
return $this; | |||
} | |||
public function getPrice(): ?float | |||
{ |
@@ -10,11 +10,6 @@ trait ProductPropertyTrait | |||
{ | |||
use PriceTrait ; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
protected $buyingPrice; | |||
/** | |||
* @ORM\Column(type="float", nullable=true) | |||
*/ | |||
@@ -46,17 +41,7 @@ trait ProductPropertyTrait | |||
protected $propertyExpirationDate; | |||
public function getBuyingPrice(): ?float | |||
{ | |||
return $this->buyingPrice; | |||
} | |||
public function setBuyingPrice(?float $buyingPrice): self | |||
{ | |||
$this->buyingPrice = $buyingPrice; | |||
return $this; | |||
} | |||
public function getBuyingPriceByRefUnit(): ?float | |||
{ |
@@ -247,3 +247,8 @@ table th .select2-container--default .select2-selection--single{padding:0.3rem 0 | |||
.todo-list > li .tools {position: absolute; top: 4px; right: 15px; } | |||
#addTicketMessageForm{margin-top: 30px; border-top:2px dotted #eee; padding-top: 30px} | |||
#dashboard .list-btn-statistic{display: flex; flex-wrap: wrap; justify-content: center;} | |||
#dashboard .btn-statistic{ width: 120px; height: 70px; text-align: center; border: 1px solid black; line-height: 1rem; } | |||
#dashboard .btn-statistic small{margin-bottom: 10px; display: block;} | |||
#dashboard .btn-statistic .value{display: block;} |
@@ -1,35 +1,33 @@ | |||
<ul class="todo-list ui-sortable" data-widget="todo-list"> | |||
{% for reminder in reminders %} | |||
<li class=""> | |||
<label class="big form-check-label"> | |||
<input type="checkbox" name="" value="1" | |||
class="form-check-input checkbox-valid-reminder" | |||
data-url="{{ path('easyadmin', { action: 'setReminderDone', entity: 'Reminder', id: reminder.id }) }}"> | |||
<span class="checkmark"></span> | |||
</label> | |||
<span class="text">{{ reminder.title }}</span> | |||
{% if reminder.dateReminder %} | |||
<small class="badge badge-info"> | |||
<i class="far fa-clock"></i> | |||
{{ reminder.dateReminder|date('d-m-Y') }} | |||
</small> | |||
{% endif %} | |||
<div class="tools"> | |||
<button type="button" class="btn-sm btn-success" data-toggle="modal" | |||
data-target="#modal-reminder-{{ reminder.id }}"> | |||
<i class="fas fa-eye"></i> | |||
</button> | |||
<button type="button" class="btn-sm btn-info btn-edit-reminder" | |||
data-url="{{ path('easyadmin', { action: 'edit', entity: 'Reminder', id: reminder.id }) }}"> | |||
<i class="fas fa-edit"></i> | |||
</button> | |||
</div> | |||
{% include '@LcShop/backend/default/modal/show_reminder.twig' %} | |||
</li> | |||
{% endfor %} | |||
<ul class="todo-list ui-sortable" data-widget="todo-list"> | |||
{% for reminder in reminders %} | |||
<li class=""> | |||
<label class="big form-check-label"> | |||
<input type="checkbox" name="" value="1" | |||
class="form-check-input checkbox-valid-reminder" | |||
data-url="{{ path('easyadmin', { action: 'setReminderDone', entity: 'Reminder', id: reminder.id }) }}"> | |||
<span class="checkmark"></span> | |||
</label> | |||
<span class="text">{{ reminder.title }}</span> | |||
{% if reminder.dateReminder %} | |||
<small class="badge badge-info"> | |||
<i class="far fa-clock"></i> | |||
{{ reminder.dateReminder|date('d-m-Y') }} | |||
</small> | |||
{% endif %} | |||
<div class="tools"> | |||
<button type="button" class="btn-sm btn-success" data-toggle="modal" | |||
data-target="#modal-reminder-{{ reminder.id }}"> | |||
<i class="fas fa-eye"></i> | |||
</button> | |||
<button type="button" class="btn-sm btn-info btn-edit-reminder" | |||
data-url="{{ path('easyadmin', { action: 'edit', entity: 'Reminder', id: reminder.id }) }}"> | |||
<i class="fas fa-edit"></i> | |||
</button> | |||
</div> | |||
{% include '@LcShop/backend/default/modal/show_reminder.twig' %} | |||
</li> | |||
{% endfor %} | |||
</ul> | |||
</ul> | |||
@@ -18,6 +18,9 @@ | |||
<th> | |||
<span>Prix TTC à l'unité </span> | |||
</th> | |||
<th> | |||
<span>Marge </span> | |||
</th> | |||
<th> | |||
<span>Disponibilité</span> | |||
</th> | |||
@@ -68,6 +71,11 @@ | |||
<td> | |||
{% verbatim %}{{orderProduct.priceWithTax}}{% endverbatim %}€ | |||
</td> | |||
<td> | |||
{% verbatim %}{{orderProduct.buyingPrice}}{% endverbatim %}€ <br /> | |||
{% verbatim %}{{orderProduct.totalMargin}}{% endverbatim %}€ / | |||
{% verbatim %}{{orderProduct.marginPercent}}{% endverbatim %}% | |||
</td> | |||
<td> | |||
{% verbatim %}{{orderProduct.availableQuantity}}{% endverbatim %} | |||
</td> |
@@ -124,6 +124,7 @@ class OrderUtils | |||
$orderProductAdd->setTitle($orderProductAdd->getTitleOrderShop()); | |||
$orderProductAdd->setPrice($this->priceUtils->getPrice($orderProductAdd->getProduct())); | |||
$orderProductAdd->setBuyingPrice($this->priceUtils->getBuyingPrice($orderProductAdd->getProduct())); | |||
$orderProductAdd->setUnit($orderProductAdd->getProduct()->getUnitInherited()); | |||
$orderProductAdd->setTaxRate($orderProductAdd->getProduct()->getTaxRateInherited()); | |||
$orderProductAdd->setQuantityProduct($orderProductAdd->getProduct()->getQuantityInherited()); |
@@ -27,6 +27,11 @@ class OrderProductPriceUtils | |||
return $orderProduct->getPrice(); | |||
} | |||
public function getBuyingPrice(OrderProductInterface $orderProduct) | |||
{ | |||
return $orderProduct->getBuyingPrice(); | |||
} | |||
public function getPriceWithTax(OrderProductInterface $orderProduct) | |||
{ | |||
return $this->applyTax( | |||
@@ -45,12 +50,45 @@ class OrderProductPriceUtils | |||
} | |||
public function getPriceWithReduction(OrderProductInterface $orderProduct) | |||
{ | |||
return $this->applyReductionCatalog( | |||
$orderProduct, | |||
$this->getPrice($orderProduct), | |||
$this->getPriceWithTax($orderProduct), | |||
null, | |||
false | |||
); | |||
} | |||
public function getTotal(OrderProductInterface $orderProduct) | |||
{ | |||
return $orderProduct->getQuantityOrder() * $this->getPrice($orderProduct); | |||
} | |||
public function getMargin(OrderProductInterface $orderProduct) | |||
{ | |||
return $this->getPriceWithReduction($orderProduct) - $this->getBuyingPrice($orderProduct); | |||
} | |||
public function getMarginPercent(OrderProductInterface $orderProduct) | |||
{ | |||
if($this->getBuyingPrice($orderProduct)) { | |||
return ($this->getMargin($orderProduct) / $this->getBuyingPrice($orderProduct)) * 100; | |||
}else{ | |||
return 0; | |||
} | |||
} | |||
public function getTotalMargin(OrderProductInterface $orderProduct) | |||
{ | |||
return $orderProduct->getQuantityOrder() * $this->getMargin($orderProduct); | |||
} | |||
public function getTotalWithReduction(OrderProductInterface $orderProduct) | |||
{ | |||
return $this->applyReductionCatalog( |
@@ -30,11 +30,26 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface | |||
return $total; | |||
} | |||
//Inclus les ReductionCatalog des OrderProducts | |||
public function getMarginOrderProducts(OrderShopInterface $orderShop):float | |||
{ | |||
// A tester calculer ce montant en faisant TotalOrderWithTax - TotalOrderTaxes | |||
$total = 0; | |||
foreach ($orderShop->getOrderProducts() as $orderProduct) { | |||
$total += $this->orderProductPriceUtils->getTotalMargin($orderProduct); | |||
} | |||
return $total; | |||
} | |||
public function getTotalOrderProductsWithTax(OrderShopInterface $orderShop):float | |||
{ | |||
return $this->getTotalOrderProductsWithTaxByOrderProducts($orderShop->getOrderProducts()) ; | |||
} | |||
public function getTotalOrderProductsWithTaxByOrderProducts($orderProducts):float | |||
{ | |||
$total = 0; | |||
@@ -107,6 +122,25 @@ class OrderShopPriceUtils implements OrderShopPriceUtilsInterface | |||
} | |||
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 getTotalOrderProductsWithTaxAndReductions(OrderShopInterface $orderShop) | |||
{ | |||
$total = $this->getTotalOrderProductsWithTax($orderShop) ; |
@@ -22,6 +22,8 @@ class ProductPriceUtils | |||
elseif ($product->getBehaviorPriceInherited() == 'by-reference-unit') { | |||
if ($product->getQuantityInherited() > 0) { | |||
return $product->getPriceByRefUnitInherited() * ($product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient()); | |||
}else{ | |||
return 0; | |||
} | |||
} | |||
} | |||
@@ -73,5 +75,21 @@ class ProductPriceUtils | |||
} | |||
public function getBuyingPrice(ProductPropertyInterface $product) | |||
{ | |||
if ($product->getBehaviorPriceInherited() == 'by-piece') { | |||
return $product->getBuyingPriceInherited(); | |||
} | |||
elseif ($product->getBehaviorPriceInherited() == 'by-reference-unit') { | |||
if ($product->getQuantityInherited() > 0) { | |||
return $product->getBuyingPriceByRefUnitInherited() * ($product->getQuantityInherited() / $product->getUnitInherited()->getCoefficient()); | |||
}else{ | |||
return 0; | |||
} | |||
} | |||
} | |||
} | |||
@@ -7,6 +7,7 @@ use Lc\ShopBundle\Context\MerchantUtilsInterface; | |||
use Lc\ShopBundle\Context\OrderUtilsInterface; | |||
use Lc\ShopBundle\Context\PriceUtilsInterface; | |||
use Lc\ShopBundle\Context\ProductFamilyUtilsInterface; | |||
use Lc\ShopBundle\Context\Services\StatisticsUtilsInterface; | |||
class UtilsManager | |||
{ | |||
@@ -21,6 +22,7 @@ class UtilsManager | |||
protected $documentUtils ; | |||
protected $mailUtils ; | |||
protected $ticketUtils ; | |||
protected $statisticsUtils; | |||
public function __construct( | |||
Utils $utils, | |||
@@ -103,4 +105,5 @@ class UtilsManager | |||
{ | |||
return $this->ticketUtils ; | |||
} | |||
} |