Bläddra i källkod

Intégration app order

packProduct
Fabien Normand 3 år sedan
förälder
incheckning
262e14220d
33 ändrade filer med 222 tillägg och 100 borttagningar
  1. +10
    -1
      Container/Order/OrderShopContainer.php
  2. +10
    -1
      Container/Product/ProductFamilyContainer.php
  3. +10
    -1
      Container/Reduction/ReductionCreditContainer.php
  4. +2
    -2
      Context/MerchantContextTrait.php
  5. +2
    -2
      Context/SectionContextTrait.php
  6. +0
    -1
      Controller/AdminControllerTrait.php
  7. +55
    -0
      Definition/Field/Order/OrderShopFieldDefinition.php
  8. +1
    -1
      Factory/Address/AddressFactory.php
  9. +1
    -1
      Factory/File/DocumentFactory.php
  10. +3
    -3
      Factory/Newsletter/NewsletterFactory.php
  11. +1
    -1
      Factory/Order/OrderShopFactory.php
  12. +1
    -1
      Factory/PointSale/PointSaleFactory.php
  13. +2
    -2
      Factory/Product/ProductCategoryFactory.php
  14. +1
    -1
      Factory/Product/ProductFamilyFactory.php
  15. +1
    -1
      Factory/Reduction/ReductionCartFactory.php
  16. +1
    -1
      Factory/Reduction/ReductionCatalogFactory.php
  17. +1
    -1
      Factory/Reduction/ReductionCreditFactory.php
  18. +4
    -4
      Factory/Reminder/ReminderFactory.php
  19. +1
    -1
      Factory/Section/OpeningFactory.php
  20. +1
    -1
      Factory/Section/SectionFactory.php
  21. +1
    -1
      Factory/Setting/MerchantSettingFactory.php
  22. +1
    -1
      Factory/Setting/SectionSettingFactory.php
  23. +3
    -3
      Factory/Site/NewsFactory.php
  24. +3
    -3
      Factory/Site/PageFactory.php
  25. +3
    -3
      Factory/Ticket/TicketFactory.php
  26. +2
    -2
      Factory/User/GroupUserFactory.php
  27. +1
    -1
      Factory/User/UserMerchantFactory.php
  28. +1
    -3
      Model/Order/OrderShopModel.php
  29. +10
    -0
      Resources/views/admin/order/field/complementary.html.twig
  30. +14
    -0
      Resources/views/admin/order/field/order_payment.html.twig
  31. +2
    -0
      Resources/views/admin/order/field/order_status.html.twig
  32. +1
    -0
      Resources/views/admin/order/field/total.html.twig
  33. +72
    -56
      Solver/Order/OrderShopSolver.php

+ 10
- 1
Container/Order/OrderShopContainer.php Visa fil

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Container\Order;

use App\Resolver\OrderResolver;
use Lc\CaracoleBundle\Builder\Order\OrderShopBuilder;
use Lc\CaracoleBundle\Definition\Field\Order\OrderShopFieldDefinition;
use Lc\CaracoleBundle\Factory\Order\OrderShopFactory;
use Lc\CaracoleBundle\Repository\Order\OrderShopRepositoryQuery;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
@@ -19,6 +20,7 @@ class OrderShopContainer
protected OrderShopBuilder $builder;
protected OrderResolver $resolver;
protected OrderShopTransformer $transformer;
protected OrderShopFieldDefinition $fieldDefinition;

public function __construct(
OrderShopFactory $factory,
@@ -27,7 +29,8 @@ class OrderShopContainer
OrderShopStore $store,
OrderResolver $resolver,
OrderShopBuilder $builder,
OrderShopTransformer $transformer
OrderShopTransformer $transformer,
OrderShopFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->solver = $solver;
@@ -36,6 +39,7 @@ class OrderShopContainer
$this->resolver = $resolver;
$this->builder = $builder;
$this->transformer = $transformer;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): OrderShopFactory
@@ -73,4 +77,9 @@ class OrderShopContainer
return $this->transformer;
}

public function getFieldDefinition(): OrderShopFieldDefinition
{
return $this->fieldDefinition;
}

}

+ 10
- 1
Container/Product/ProductFamilyContainer.php Visa fil

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Container\Product;

use App\Definition\Field\Product\ProductFamilyFieldDefinition;
use Lc\CaracoleBundle\Builder\Product\ProductFamilyBuilder;
use Lc\CaracoleBundle\Factory\Product\ProductFamilyFactory;
use Lc\CaracoleBundle\Repository\Product\ProductFamilyRepositoryQuery;
@@ -17,6 +18,7 @@ class ProductFamilyContainer
protected ProductFamilyStore $store;
protected ProductFamilyBuilder $builder;
protected ProductFamilyResolver $resolver;
protected ProductFamilyFieldDefinition $fieldDefinition;

public function __construct(
ProductFamilyFactory $factory,
@@ -24,7 +26,8 @@ class ProductFamilyContainer
ProductFamilyRepositoryQuery $repositoryQuery,
ProductFamilyStore $store,
ProductFamilyBuilder $builder,
ProductFamilyResolver $resolver
ProductFamilyResolver $resolver,
ProductFamilyFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->solver = $solver;
@@ -32,6 +35,7 @@ class ProductFamilyContainer
$this->store = $store;
$this->builder = $builder;
$this->resolver = $resolver;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ProductFamilyFactory
@@ -64,4 +68,9 @@ class ProductFamilyContainer
return $this->builder;
}


public function getFieldDefinition(): ProductFamilyFieldDefinition
{
return $this->fieldDefinition;
}
}

+ 10
- 1
Container/Reduction/ReductionCreditContainer.php Visa fil

@@ -2,6 +2,7 @@

namespace Lc\CaracoleBundle\Container\Reduction;

use App\Definition\Field\Reduction\ReductionCreditFieldDefinition;
use Lc\CaracoleBundle\Factory\Reduction\ReductionCreditFactory;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditRepositoryQuery;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
@@ -11,15 +12,18 @@ class ReductionCreditContainer
protected ReductionCreditFactory $factory;
protected ReductionCreditRepositoryQuery $repositoryQuery;
protected ReductionCreditStore $store;
protected ReductionCreditFieldDefinition $fieldDefinition;

public function __construct(
ReductionCreditFactory $factory,
ReductionCreditRepositoryQuery $repositoryQuery,
ReductionCreditStore $store
ReductionCreditStore $store,
ReductionCreditFieldDefinition $fieldDefinition
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->store = $store;
$this->fieldDefinition = $fieldDefinition;
}

public function getFactory(): ReductionCreditFactory
@@ -37,4 +41,9 @@ class ReductionCreditContainer
return $this->store;
}

public function getFieldDefinition(): ReductionCreditFieldDefinition
{
return $this->fieldDefinition;
}

}

Factory/MerchantFactoryTrait.php → Context/MerchantContextTrait.php Visa fil

@@ -1,10 +1,10 @@
<?php

namespace Lc\CaracoleBundle\Factory;
namespace Lc\CaracoleBundle\Context;

use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;

trait MerchantFactoryTrait
trait MerchantContextTrait
{
protected MerchantInterface $merchant;


Factory/SectionFactoryTrait.php → Context/SectionContextTrait.php Visa fil

@@ -1,10 +1,10 @@
<?php

namespace Lc\CaracoleBundle\Factory;
namespace Lc\CaracoleBundle\Context;

use Lc\CaracoleBundle\Model\Section\SectionInterface;

trait SectionFactoryTrait
trait SectionContextTrait
{
protected SectionInterface $section;


+ 0
- 1
Controller/AdminControllerTrait.php Visa fil

@@ -293,7 +293,6 @@ trait AdminControllerTrait
}
}


public function buildIndexActions(Actions $actions): void
{
parent::buildIndexActions($actions);

+ 55
- 0
Definition/Field/Order/OrderShopFieldDefinition.php Visa fil

@@ -0,0 +1,55 @@
<?php

namespace Lc\CaracoleBundle\Definition\Field\Order;

use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
use EasyCorp\Bundle\EasyAdminBundle\Field\Field;
use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField;
use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Field\AssociationField;
use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;

class OrderShopFieldDefinition extends AbstractFieldDefinition
{
use MerchantContextTrait;

public function configurePanels(): array
{
return [];
}

public function configureFields(): array
{
return [
'id' => IntegerField::new('id', 'ID'),
'userLastname' => TextareaField::new('user.lastname', 'field.default.lastname'),
//->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'),
'userFirstname' => TextareaField::new('user.firstname', 'field.default.firstname'),
//->setTemplatePath('@LcShop/backend/default/field/textorempty.html.twig'),
'userEmail' => TextareaField::new('user.email', 'field.default.email'),
//->setTemplatePath('@LcShop/backend/default/field/user.html.twig'),
'total' => NumberField::new('total')
->setTemplatePath('@LcCaracole/admin/order/field/total.html.twig'),
'orderStatus' => AssociationField::new('orderStatus')
->setTemplatePath('@LcCaracole/admin/order/field/order_status.html.twig'),
'createdAt' => DateTimeField::new('createdAt', 'field.OrderShop.createdAt'),
'updatedAt' => DateTimeField::new('updatedAt', 'field.OrderShop.updatedAt'),
'orderShopCreatedAt' => DateTimeField::new('orderShopCreatedAt', 'field.OrderShop.createdAt'),
'cycleNumber' => IntegerField::new('cycleNumber'),
'cycleDeliveryId' => IntegerField::new('cycleDeliveryId'),
'cycleId' => IntegerField::new('cycleId'),
'deliveryType' => Field::new('deliveryType'),
//->setTemplatePath('@LcShop/backend/default/field/options_translatable.html.twig'),
'reference' => TextField::new('reference'),
'complementaryOrderShops' => AssociationField::new('complementaryOrderShops')->setFormTypeOption('mapped', false)
->setTemplatePath('@LcCaracole/admin/order/field/complementary.html.twig'),
'orderPayments' => AssociationField::new('orderPayments')
->setTemplatePath('@LcCaracole/admin/order/field/order_payment.html.twig')

];
}

}

+ 1
- 1
Factory/Address/AddressFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Address;

use App\Entity\Address\Address;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\Factory\AbstractFactory;

+ 1
- 1
Factory/File/DocumentFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\File;

use App\Entity\File\Document;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Address\AddressInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;

+ 3
- 3
Factory/Newsletter/NewsletterFactory.php Visa fil

@@ -2,14 +2,14 @@

namespace Lc\CaracoleBundle\Factory\Newsletter;

use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\SovBundle\Model\Newsletter\NewsletterInterface;
use Lc\SovBundle\Factory\Newsletter\NewsletterFactory as SovNewsletterFactory;

class NewsletterFactory extends SovNewsletterFactory
{
use SectionFactoryTrait;
use SectionContextTrait;

public function create(): NewsletterInterface
{

+ 1
- 1
Factory/Order/OrderShopFactory.php Visa fil

@@ -4,7 +4,7 @@ namespace Lc\CaracoleBundle\Factory\Order;

use App\Entity\Order\OrderShop;
use Lc\CaracoleBundle\Event\Order\OrderShopChangeStatusEvent;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Model\Order\OrderStatusModel;

+ 1
- 1
Factory/PointSale/PointSaleFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\PointSale;

use App\Entity\PointSale\PointSale;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\SovBundle\Factory\AbstractFactory;

+ 2
- 2
Factory/Product/ProductCategoryFactory.php Visa fil

@@ -3,8 +3,8 @@
namespace Lc\CaracoleBundle\Factory\Product;

use App\Entity\Product\ProductCategory;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

+ 1
- 1
Factory/Product/ProductFamilyFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Product;

use App\Entity\Product\ProductFamily;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

+ 1
- 1
Factory/Reduction/ReductionCartFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Reduction;

use App\Entity\Reduction\ReductionCart;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

+ 1
- 1
Factory/Reduction/ReductionCatalogFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Reduction;

use App\Entity\Reduction\ReductionCatalog;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

+ 1
- 1
Factory/Reduction/ReductionCreditFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Reduction;

use App\Entity\Reduction\ReductionCredit;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;

+ 4
- 4
Factory/Reminder/ReminderFactory.php Visa fil

@@ -3,8 +3,8 @@
namespace Lc\CaracoleBundle\Factory\Reminder;

use App\Entity\Merchant\Merchant;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Factory\Reminder\ReminderFactory as SovReminderFactory;
@@ -12,8 +12,8 @@ use Lc\SovBundle\Model\Reminder\ReminderInterface;

class ReminderFactory extends SovReminderFactory
{
use MerchantFactoryTrait;
use SectionFactoryTrait;
use MerchantContextTrait;
use SectionContextTrait;

public function create(
string $crudAction = null,

+ 1
- 1
Factory/Section/OpeningFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Section;

use App\Entity\Section\Opening;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\User\GroupUserInterface;

+ 1
- 1
Factory/Section/SectionFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Section;

use App\Entity\Section\Section;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Factory\AbstractFactory;

+ 1
- 1
Factory/Setting/MerchantSettingFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Setting;

use App\Entity\Setting\MerchantSetting;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\File\FileInterface;

+ 1
- 1
Factory/Setting/SectionSettingFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\Setting;

use App\Entity\Setting\SectionSetting;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Factory\AbstractFactory;
use Lc\SovBundle\Model\File\FileInterface;

+ 3
- 3
Factory/Site/NewsFactory.php Visa fil

@@ -2,15 +2,15 @@

namespace Lc\CaracoleBundle\Factory\Site;

use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\Factory\Site\NewsFactory as SovNewsFactory;
use Lc\SovBundle\Model\Site\NewsInterface;

class NewsFactory extends SovNewsFactory
{
use SectionFactoryTrait;
use SectionContextTrait;

public function create(): NewsInterface
{

+ 3
- 3
Factory/Site/PageFactory.php Visa fil

@@ -2,15 +2,15 @@

namespace Lc\CaracoleBundle\Factory\Site;

use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Section\SectionInterface;
use Lc\SovBundle\Factory\Site\PageFactory as SovPageFactory;
use Lc\SovBundle\Model\Site\PageInterface;

class PageFactory extends SovPageFactory
{
use SectionFactoryTrait;
use SectionContextTrait;

public function create(): PageInterface
{

+ 3
- 3
Factory/Ticket/TicketFactory.php Visa fil

@@ -2,15 +2,15 @@

namespace Lc\CaracoleBundle\Factory\Ticket;

use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Factory\SectionFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Context\SectionContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\Factory\Ticket\TicketFactory as SovTicketFactory;
use Lc\SovBundle\Model\Ticket\TicketInterface;

class TicketFactory extends SovTicketFactory
{
use MerchantFactoryTrait;
use MerchantContextTrait;

public function create(): TicketInterface
{

+ 2
- 2
Factory/User/GroupUserFactory.php Visa fil

@@ -2,14 +2,14 @@

namespace Lc\CaracoleBundle\Factory\User;

use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\SovBundle\Model\User\GroupUserInterface;
use Lc\SovBundle\Factory\User\GroupUserFactory as SovGroupUserFactory;

class GroupUserFactory extends SovGroupUserFactory
{
use MerchantFactoryTrait;
use MerchantContextTrait;

public function create(): GroupUserInterface
{

+ 1
- 1
Factory/User/UserMerchantFactory.php Visa fil

@@ -3,7 +3,7 @@
namespace Lc\CaracoleBundle\Factory\User;

use App\Entity\User\UserMerchant;
use Lc\CaracoleBundle\Factory\MerchantFactoryTrait;
use Lc\CaracoleBundle\Context\MerchantContextTrait;
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
use Lc\SovBundle\Factory\AbstractFactory;

+ 1
- 3
Model/Order/OrderShopModel.php Visa fil

@@ -741,9 +741,7 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
{
$arrayComplementaryOrderShops = new ArrayCollection();
foreach ($this->complementaryOrderShops as $complementaryOrderShop) {
if ($complementaryOrderShop->isValid()) {
$arrayComplementaryOrderShops[] = $complementaryOrderShop;
}
$arrayComplementaryOrderShops[] = $complementaryOrderShop;
}
return $arrayComplementaryOrderShops;
}

+ 10
- 0
Resources/views/admin/order/field/complementary.html.twig Visa fil

@@ -0,0 +1,10 @@
{% set value = field.value %}
{% if value|length > 0 %}
<span class="badge badge-success">
{{ value|length }} compléments
</span>
{% else %}
<span class="badge badge-danger">
non
</span>
{% endif %}

+ 14
- 0
Resources/views/admin/order/field/order_payment.html.twig Visa fil

@@ -0,0 +1,14 @@
{% set value = field.value %}
{% set item = entity.instance %}
{% for val in value %}
<span class="badge badge-success">
{% set trad = 'field.default.meanPaymentChoices.'~val.meanPayment %}
{{ trad|trans({}, 'lcshop') }}
</span>
{% endfor %}

{% set is_paid = order_shop_container.resolver.isPaid(item) %}
{% if not is_paid %}
<br />
<span class="badge badge-danger">Non soldée</span>
{% endif %}

+ 2
- 0
Resources/views/admin/order/field/order_status.html.twig Visa fil

@@ -0,0 +1,2 @@
{% set value = field.value %}
<span class="badge badge-{{ value.color is defined ? value.color : entity.instance.orderStatus.color }}">{{ value }}</span>

+ 1
- 0
Resources/views/admin/order/field/total.html.twig Visa fil

@@ -0,0 +1 @@
{{ price_solver.getTotalWithTax(entity.instance, true)|format_price|raw }}<br />

+ 72
- 56
Solver/Order/OrderShopSolver.php Visa fil

@@ -3,6 +3,8 @@
namespace Lc\CaracoleBundle\Solver\Order;

use App\Entity\Order\OrderShop;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\EntityManagerInterface;
use Lc\CaracoleBundle\Model\File\DocumentInterface;
use Lc\CaracoleBundle\Model\File\DocumentModel;
@@ -23,9 +25,10 @@ class OrderShopSolver
protected ProductSolver $productSolver;

public function __construct(
EntityManagerInterface $entityManager,
ProductSolver $productSolver
) {
EntityManagerInterface $entityManager,
ProductSolver $productSolver
)
{
$this->entityManager = $entityManager;
$this->productSolver = $productSolver;
}
@@ -65,9 +68,10 @@ class OrderShopSolver

// getOrderProductsByProductFamily
public function getOrderProductsByProductFamily(
OrderShopInterface $orderShop,
ProductFamilyInterface $productFamily
): array {
OrderShopInterface $orderShop,
ProductFamilyInterface $productFamily
): array
{
$arrayOrderProducts = [];

foreach ($orderShop->getOrderProducts() as $orderProduct) {
@@ -80,21 +84,21 @@ class OrderShopSolver
}

public function getQuantityOrderByProduct(
OrderShopInterface $orderShop,
ProductInterface $product,
$byWeight = false
): int {
OrderShopInterface $orderShop,
ProductInterface $product,
$byWeight = false
): int
{
$quantity = 0;
$productFamily = $product->getProductFamily();
$behaviorCountStock = $productFamily->getBehaviorCountStock();

foreach ($orderShop->getOrderProducts() as $orderProduct) {
if ($orderProduct->getProduct()->getId() == $product->getId()
|| (($behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY || $behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE)
&& $orderProduct->getProduct()->getProductFamily()->getId() == $productFamily->getId())) {
|| (($behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY || $behaviorCountStock == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_MEASURE)
&& $orderProduct->getProduct()->getProductFamily()->getId() == $productFamily->getId())) {
if ($byWeight) {
$quantity += $orderProduct->getQuantityOrder() * ($orderProduct->getQuantityProduct(
) / $orderProduct->getProduct()->getUnitInherited()->getCoefficient());
$quantity += $orderProduct->getQuantityOrder() * ($orderProduct->getQuantityProduct() / $orderProduct->getProduct()->getUnitInherited()->getCoefficient());
} else {
$quantity += $orderProduct->getQuantityOrder();
}
@@ -106,13 +110,13 @@ class OrderShopSolver

// isProductAvailable
public function isProductAvailable(
ProductInterface $product,
$quantityOrder = 0,
$checkCart = false,
$orderShop = null
) {
if ($product->getStatus() != 1 || $product->getProductFamily()->getStatus(
) != 1 || !$this->productSolver->isProductSaleStatusOn($product)) {
ProductInterface $product,
$quantityOrder = 0,
$checkCart = false,
$orderShop = null
)
{
if ($product->getStatus() != 1 || $product->getProductFamily()->getStatus() != 1 || !$this->productSolver->isProductSaleStatusOn($product)) {
return false;
}

@@ -128,9 +132,8 @@ class OrderShopSolver
$quantityAsked = $this->getQuantityOrderByProduct($orderShop, $product, true);
} else {
$quantityAsked = ($this->productSolver->getQuantityInherited(
$product
) / $this->productSolver->getUnitInherited($product)->getCoefficient(
)) * $quantityOrder;
$product
) / $this->productSolver->getUnitInherited($product)->getCoefficient()) * $quantityOrder;
}

if ($checkCart) {
@@ -139,7 +142,7 @@ class OrderShopSolver
}

if (($productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT_FAMILY
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT)) {
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_BY_PRODUCT)) {
if (!$quantityOrder) {
$quantityAsked = $this->getQuantityOrderByProduct($orderShop, $product);
}
@@ -150,7 +153,7 @@ class OrderShopSolver
}

if ($this->productSolver->getAvailableQuantityInherited($product) >= $quantityAsked
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_UNLIMITED) {
|| $productFamily->getBehaviorCountStock() == ProductFamilyModel::BEHAVIOR_COUNT_STOCK_UNLIMITED) {
return true;
} else {
return false;
@@ -171,10 +174,10 @@ class OrderShopSolver
public function isOrderProductAvailableAddCart(OrderProductInterface $orderProduct, OrderShopInterface $orderShop)
{
return $this->isProductAvailable(
$orderProduct->getProduct(),
$orderProduct->getQuantityOrder(),
true,
$orderShop
$orderProduct->getProduct(),
$orderProduct->getQuantityOrder(),
true,
$orderShop
);
}

@@ -187,7 +190,7 @@ class OrderShopSolver
}

if ($mergeComplementaryOrderShop) {
foreach ($orderShop->getComplementaryOrderShops() as $complementaryOrderShop) {
foreach ($this->getValidComplementaryOrderShops($orderShop) as $complementaryOrderShop) {
foreach ($complementaryOrderShop->getOrderPayments() as $orderPayment) {
$totalAmount = $orderPayment->getAmount() + $totalAmount;
}
@@ -197,6 +200,17 @@ class OrderShopSolver
return $totalAmount;
}

public function getValidComplementaryOrderShops(OrderShopInterface $orderShop): Collection
{
$arrayComplementaryOrderShops = new ArrayCollection();
foreach ($orderShop->getComplementaryOrderShops() as $complementaryOrderShop) {
if ($this->isValid($complementaryOrderShop)) {
$arrayComplementaryOrderShops[] = $complementaryOrderShop;
}
}
return $arrayComplementaryOrderShops;
}

public function getOrderStatusHistory(OrderShopInterface $orderShop, OrderStatusInterface $status)
{
$orderStatusHistories = $orderShop->getOrderStatusHistories();
@@ -239,23 +253,23 @@ class OrderShopSolver
}

public function mergeComplentaryOrderShops(
OrderShopInterface $orderShop,
bool $combineProducts = true
): OrderShopInterface {
OrderShopInterface $orderShop,
bool $combineProducts = true
): OrderShopInterface
{
$this->entityManager->refresh($orderShop);

if ($orderShop->getComplementaryOrderShops()) {
foreach ($orderShop->getComplementaryOrderShops() as $complementaryOrderShop) {
if ($this->getValidComplementaryOrderShops($orderShop)) {
foreach ($this->getValidComplementaryOrderShops($orderShop) as $complementaryOrderShop) {
foreach ($complementaryOrderShop->getOrderProducts() as $orderProductAdd) {
$updated = false;
foreach ($orderShop->getOrderProducts() as $orderProduct) {
if ($combineProducts && $orderProduct->getProduct()->getId() == $orderProductAdd->getProduct(
)->getId()
&& (string)$orderProduct->getPrice() == (string)$orderProductAdd->getPrice()
if ($combineProducts && $orderProduct->getProduct()->getId() == $orderProductAdd->getProduct()->getId()
&& (string)$orderProduct->getPrice() == (string)$orderProductAdd->getPrice()
) {
$orderProduct->setUpdatedOnMergeComplementaryOrderShop(true);
$orderProduct->setQuantityOrder(
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder()
$orderProduct->getQuantityOrder() + $orderProductAdd->getQuantityOrder()
);

$updated = true;
@@ -275,9 +289,10 @@ class OrderShopSolver
}

public function isReductionCreditAddedToOrder(
OrderShopInterface $orderShop,
ReductionCreditInterface $reductionCredit
) {
OrderShopInterface $orderShop,
ReductionCreditInterface $reductionCredit
)
{
foreach ($orderShop->getOrderReductionCredits() as $orderReductionCredit) {
if ($orderReductionCredit->getReductionCredit() == $reductionCredit) {
return true;
@@ -289,9 +304,10 @@ class OrderShopSolver


public function hasOrderProductAlreadyInCart(
OrderShopInterface $orderShop,
OrderProductInterface $orderProductTest
): ?OrderProductInterface {
OrderShopInterface $orderShop,
OrderProductInterface $orderProductTest
): ?OrderProductInterface
{
foreach ($orderShop->getOrderProducts() as $orderProduct) {
if ($orderProduct->getProduct() == $orderProductTest->getProduct()) {
return $orderProduct;
@@ -304,9 +320,9 @@ class OrderShopSolver
public function isValid(OrderShopInterface $orderShop): bool
{
if ($orderShop->getOrderStatus() && in_array(
$orderShop->getOrderStatus()->getAlias(),
OrderStatusModel::$statusAliasAsValid
) > 0) {
$orderShop->getOrderStatus()->getAlias(),
OrderStatusModel::$statusAliasAsValid
) > 0) {
return true;
}

@@ -316,9 +332,9 @@ class OrderShopSolver
public function isCart(OrderShopInterface $orderShop): bool
{
if ($orderShop->getOrderStatus() && in_array(
$orderShop->getOrderStatus()->getAlias(),
OrderStatusModel::$statusAliasAsCart
) > 0) {
$orderShop->getOrderStatus()->getAlias(),
OrderStatusModel::$statusAliasAsCart
) > 0) {
return true;
}

@@ -341,10 +357,10 @@ class OrderShopSolver
}

return $this->productSolver->getAvailableQuantityInherited($product) - $this->getQuantityOrderByProduct(
$orderShop,
$product,
$byWeight
);
$orderShop,
$product,
$byWeight
);
}

public function hasMakeAChoiceAboutComplementaryOrder(OrderShop $orderShop): bool

Laddar…
Avbryt
Spara