Browse Source

Refactoring frontend

packProduct
Guillaume 3 years ago
parent
commit
f74508de94
21 changed files with 378 additions and 180 deletions
  1. +9
    -0
      Container/Credit/CreditHistoryContainer.php
  2. +37
    -5
      Definition/MerchantSettingDefinition.php
  3. +180
    -0
      Form/Ticket/TicketFormType.php
  4. +0
    -4
      Model/Address/AddressInterface.php
  5. +0
    -68
      Model/Credit/CreditHistoryInterface.php
  6. +0
    -70
      Model/Credit/CreditHistoryModel.php
  7. +2
    -1
      Model/Order/OrderProductModel.php
  8. +1
    -1
      Model/Ticket/TicketModel.php
  9. +16
    -12
      Notification/MailMailjetNotification.php
  10. +6
    -0
      Repository/Address/AddressRepositoryQuery.php
  11. +9
    -0
      Repository/Address/AddressStore.php
  12. +3
    -1
      Repository/Order/OrderProductStore.php
  13. +17
    -11
      Repository/Order/OrderShopStore.php
  14. +4
    -1
      Repository/Product/ProductFamilyStore.php
  15. +2
    -1
      Repository/Reduction/ReductionCartRepositoryQuery.php
  16. +3
    -1
      Repository/Reduction/ReductionCartStore.php
  17. +3
    -1
      Repository/Reduction/ReductionCatalogStore.php
  18. +2
    -1
      Repository/Reduction/ReductionCreditRepositoryQuery.php
  19. +3
    -1
      Repository/Reduction/ReductionCreditStore.php
  20. +3
    -1
      Resources/translations/admin.fr.yaml
  21. +78
    -0
      Solver/Credit/CreditHistorySolver.php

+ 9
- 0
Container/Credit/CreditHistoryContainer.php View File

@@ -6,6 +6,7 @@ use Lc\CaracoleBundle\Builder\Credit\CreditHistoryBuilder;
use Lc\CaracoleBundle\Factory\Credit\CreditHistoryFactory;
use Lc\CaracoleBundle\Repository\Credit\CreditHistoryRepositoryQuery;
use Lc\CaracoleBundle\Repository\Credit\CreditHistoryStore;
use Lc\CaracoleBundle\Solver\Credit\CreditHistorySolver;

class CreditHistoryContainer
{
@@ -13,15 +14,18 @@ class CreditHistoryContainer
protected CreditHistoryRepositoryQuery $repositoryQuery;
protected CreditHistoryStore $store;
protected CreditHistoryBuilder $builder;
protected CreditHistorySolver $solver;

public function __construct(
CreditHistoryFactory $factory,
CreditHistoryRepositoryQuery $repositoryQuery,
CreditHistorySolver $solver,
CreditHistoryStore $store,
CreditHistoryBuilder $builder
) {
$this->factory = $factory;
$this->repositoryQuery = $repositoryQuery;
$this->solver = $solver;
$this->store = $store;
$this->builder = $builder;
}
@@ -36,6 +40,11 @@ class CreditHistoryContainer
return $this->repositoryQuery;
}

public function getSolver(): CreditHistorySolver
{
return $this->solver;
}

public function getStore(): CreditHistoryStore
{
return $this->store;

+ 37
- 5
Definition/MerchantSettingDefinition.php View File

@@ -7,23 +7,55 @@ use Lc\SovBundle\Definition\AbstractSettingDefinition;
class MerchantSettingDefinition extends AbstractSettingDefinition implements MerchantSettingDefinitionInterface
{
const CATEGORY_GENERAL = 'general';
const CATEGORY_EMAIL = 'email';

const SETTING_URL = 'url';
const SETTING_EMAIL_SUBJECT_PREFIX = 'emailSubjectPrefix';
const SETTING_EMAIL_FROM = 'emailFrom';
const SETTING_EMAIL_FROM_NAME = 'emailFromName';
const SETTING_EMAIL_CONTACT = 'emailContact';

public function __construct()
{
$this
->addSettingText(
->addSettingText(
[
'name' => self::SETTING_URL,
'category' => self::CATEGORY_GENERAL,
]
);

$this->addSettingText(
[
'category' => self::CATEGORY_EMAIL,
'name' => self::SETTING_EMAIL_SUBJECT_PREFIX,
]
);
$this->addSettingText(
[
'category' => self::CATEGORY_EMAIL,
'name' => self::SETTING_EMAIL_FROM,
]
);
$this->addSettingText(
[
'category' => self::CATEGORY_EMAIL,
'name' => self::SETTING_EMAIL_FROM_NAME,
]
);
$this->addSettingText(
[
'name' => self::SETTING_URL,
'category' => self::CATEGORY_GENERAL,
'category' => self::CATEGORY_EMAIL,
'name' => self::SETTING_EMAIL_CONTACT,
]
);
);
}

public function getCategories()
{
return [
self::CATEGORY_GENERAL,
self::CATEGORY_GENERAL,
self::CATEGORY_EMAIL,
];
}


+ 180
- 0
Form/Ticket/TicketFormType.php View File

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

namespace Lc\CaracoleBundle\Form\Ticket;

use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Repository\Order\OrderShopStore;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\SovBundle\Component\FormComponent;
use Lc\SovBundle\Doctrine\EntityManager;
use Lc\SovBundle\Model\Ticket\TicketInterface;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Solver\Ticket\TicketSolver;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Validator\Constraints\File;

class TicketFormType extends AbstractType
{
protected Security $security;
protected EntityManager $entityManager;
protected TranslatorAdmin $translatorAdmin;
protected TicketSolver $ticketSolver;
protected FormComponent $formComponent;
protected OrderShopStore $orderShopStore;
protected PriceSolver $priceSolver;

public function __construct(
Security $security,
EntityManager $entityManager,
TranslatorAdmin $translatorAdmin,
TicketSolver $ticketSolver,
FormComponent $formComponent,
OrderShopStore $orderShopStore,
PriceSolver $priceSolver
) {
$this->security = $security;
$this->entityManager = $entityManager;
$this->translatorAdmin = $translatorAdmin;
$this->ticketSolver = $ticketSolver;
$this->formComponent = $formComponent;
$this->orderShopStore = $orderShopStore;
$this->priceSolver = $priceSolver;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$isConnected = $this->security->getUser();
$entityName = $this->entityManager->getEntityName(TicketInterface::class);

if (!$isConnected) {
$builder->add(
'visitorFirstname',
TextType::class,
[
'label' => 'Prénom'
]
)
->add(
'visitorLastname',
TextType::class,
[
'label' => 'Nom'
]
)
->add(
'visitorEmail',
EmailType::class,
[
'label' => 'Email'
]
);
}

$builder->add(
'type',
ChoiceType::class,
[
'label' => 'Type',
'choices' => $this->translatorAdmin->transChoices(
$this->ticketSolver->getTypeChoices(),
'Ticket',
'type'
),
]
);

if ($isConnected) {
$builder->add(
'orderShop',
EntityType::class,
[
'class' => $this->entityManager->getEntityName(OrderShopInterface::class),
'multiple' => false,
'expanded' => false,
'choices' => $this->orderShopStore->getBy(
[
'user' => $this->security->getUser(),
'isValid' => true
]
),
'label' => 'field.default.order',
'placeholder' => '-- Choisissez une commande --',
'required' => false,
'choice_label' => function ($orderShop, $key, $value) {
return 'Commande du ' . $orderShop->getValidationDate()->format(
'd/m/Y'
) . ' (' . number_format(
$this->priceSolver->getTotalWithTax($orderShop),
2
) . ' €)';
},
'translation_domain' => 'admin',
]
);
} else {
$this->formComponent->addCaptchaType($builder);
}

$builder->add(
'subject',
TextType::class
);

$builder->add(
'message',
TextareaType::class,
[
'mapped' => false,
'label' => 'Message'
]
);

$builder->add(
'image',
FileType::class,
[
'label' => 'Photo',
'mapped' => false,
'required' => false,
'constraints' => [
new File(
[
'maxSize' => '2048k',
'mimeTypes' => [
'image/png',
'image/jpeg',
'image/jpg',
'image/gif',
],
'mimeTypesMessage' => "Mauvais format d'image (formats acceptés : jpeg, png, gif)",
]
)
],
]
);
}

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
[
'data_class' => $this->entityManager->getEntityName(TicketInterface::class),
]
);
}
}

+ 0
- 4
Model/Address/AddressInterface.php View File

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

namespace Lc\CaracoleBundle\Model\Address;


use Lc\CaracoleBundle\Model\Merchant\MerchantInterface;
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface;
use Lc\SovBundle\Model\User\UserInterface;

/**
* @ORM\MappedSuperclass()
*/
interface AddressInterface
{
public function getUser(): ?UserInterface;

+ 0
- 68
Model/Credit/CreditHistoryInterface.php View File

@@ -20,73 +20,5 @@ use Lc\SovBundle\Model\User\UserInterface;
*/
interface CreditHistoryInterface
{
public function getCreatedBy(): ?UserInterface;

public function setCreatedBy(?UserInterface $createdBy);

public function getUpdatedBy(): ?UserInterface;

public function setUpdatedBy(?UserInterface $updatedBy);

public function __toString();

public function getAmount(): ?float;

public function setAmount(?float $amount);

public function getAmountInherited(): float;

public function getMeanPaymentInherited(): string;

public function getPaidAtInherited(): ?\DateTimeInterface;

public function getReferenceInherited(): ?string;

public function getCommentInherited(): ?string;

public function getMeanPaymentInheritedLabel(): string;

public function getType(): ?string;

public function setType(string $type): CreditHistoryModel;

public function getUserMerchant(): ?UserMerchantInterface;

public function setUserMerchant(?UserMerchantInterface $userMerchant): CreditHistoryModel;

public function getOrderPayment(): ?OrderPaymentInterface;

public function setOrderPayment(?OrderPaymentInterface $orderPayment): CreditHistoryModel;

public function getOrderRefund(): ?OrderRefundInterface;

public function setOrderRefund(?OrderRefundInterface $orderRefund): CreditHistoryModel;

public function getDevAlias(): ?string;

public function setDevAlias(?string $devAlias);

public function setMeanPayment(?string $meanPayment): CreditHistoryModel;

public function getMeanPayment(): ?string;

public function getReference(): ?string;

public function setReference(?string $reference): CreditHistoryModel;

public function getPaidAt(): ?\DateTimeInterface;

public function setPaidAt(?\DateTimeInterface $paidAt): CreditHistoryModel;

public function getComment(): ?string;

public function setComment(?string $comment): CreditHistoryModel;

public function getCreatedAt(): ?\DateTimeInterface;

public function setCreatedAt(\DateTimeInterface $createdAt);

public function getUpdatedAt(): ?\DateTimeInterface;

public function setUpdatedAt(\DateTimeInterface $updatedAt);
}

+ 0
- 70
Model/Credit/CreditHistoryModel.php View File

@@ -73,76 +73,6 @@ abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffI
return $this;
}

public function getAmountInherited(): float
{
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getAmount();
} else {
if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getAmount();
} else {
return $this->getAmount();
}
}
}

public function getMeanPaymentInherited(): string
{
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getMeanPayment();
} else {
if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getMeanPayment();
} else {
return $this->getMeanPayment();
}
}
}

public function getPaidAtInherited(): ?\DateTimeInterface
{
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getPaidAt();
} else {
if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getPaidAt();
} else {
return $this->getPaidAt();
}
}
}

public function getReferenceInherited(): ?string
{
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getReference();
} else {
if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getReference();
} else {
return $this->getReference();
}
}
}

public function getCommentInherited(): ?string
{
if ($this->getOrderPayment() !== null) {
return $this->getOrderPayment()->getComment();
} else {
if ($this->getOrderRefund() !== null) {
return $this->getOrderRefund()->getComment();
} else {
return $this->getComment();
}
}
}

public function getMeanPaymentInheritedLabel(): string
{
return 'field.default.meanPaymentOptions.' . $this->getMeanPaymentInherited();
}

public function getType(): ?string
{
return $this->type;

+ 2
- 1
Model/Order/OrderProductModel.php View File

@@ -6,11 +6,12 @@ use Lc\CaracoleBundle\Doctrine\Extension\PriceTrait;
use Doctrine\ORM\Mapping as ORM;
use Lc\CaracoleBundle\Doctrine\Extension\PriceInterface;
use Lc\CaracoleBundle\Model\Product\ProductInterface;
use Lc\SovBundle\Doctrine\EntityInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderProductModel implements PriceInterface
abstract class OrderProductModel implements PriceInterface, EntityInterface
{
use PriceTrait;


+ 1
- 1
Model/Ticket/TicketModel.php View File

@@ -40,7 +40,7 @@ abstract class TicketModel extends SovTicketModel implements FilterSectionInterf
return $this;
}

public function getOrderShop(): OrderShopInterface
public function getOrderShop(): ?OrderShopInterface
{
return $this->orderShop;
}

+ 16
- 12
Notification/MailMailjetNotification.php View File

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

use Lc\CaracoleBundle\Definition\MerchantSettingDefinition;
use Lc\CaracoleBundle\Resolver\MerchantResolver;
use Lc\SovBundle\Solver\Setting\SettingSolver;
use Mailjet\MailjetSwiftMailer\SwiftMailer\MailjetTransport;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Twig\Environment;
@@ -26,35 +27,38 @@ class MailMailjetNotification
const ATTACHMENT_CONTENT_TYPE = 'attachment-content-type';
//const DISPOSITION_NOTIFICATION_TO = 'disposition-notification-to' ;

protected $transport;
protected $templating;
protected $parameterBag;
protected $merchantResolver;
protected MailjetTransport $transport;
protected Environment $templating;
protected ParameterBagInterface $parameterBag;
protected MerchantResolver $merchantResolver;
protected SettingSolver $settingSolver;

public function __construct(
MailjetTransport $mailjetTransport,
Environment $templating,
ParameterBagInterface $parameterBag,
MerchantResolver $merchantResolver
MerchantResolver $merchantResolver,
SettingSolver $settingSolver
) {
$this->transport = $mailjetTransport;
$this->templating = $templating;
$this->parameterBag = $parameterBag;
$this->merchantResolver = $merchantResolver;
$this->settingSolver = $settingSolver;
}

public function send($params = [])
{
$merchantCurrent = $this->merchantResolver->getCurrent();

$merchantConfigEmailFrom = $merchantCurrent->getSettingValue(MerchantSettingDefinition::EMAIL_FROM);
$merchantConfigEmailFrom = $this->settingSolver->getSettingValue($merchantCurrent, MerchantSettingDefinition::SETTING_EMAIL_FROM);
$emailFrom = (isset($params[self::FROM_EMAIL]) && $params[self::FROM_EMAIL] && strlen($params[self::FROM_EMAIL])) ? $params[self::FROM_EMAIL] : $merchantConfigEmailFrom;

$merchantConfigEmailFromName = $merchantCurrent->getSettingValue(MerchantSettingDefinition::EMAIL_FROM_NAME);
$emailFromName = isset($params[self::FROM_NAME]) ? $params[self::FROM_NAME] : $merchantConfigEmailFromName;
$merchantConfigEmailFromName = $this->settingSolver->getSettingValue($merchantCurrent, MerchantSettingDefinition::SETTING_EMAIL_FROM_NAME);
$emailFromName = isset($params[self::FROM_NAME]) ?? $merchantConfigEmailFromName;

$merchantConfigEmailSubjectPrefix = $merchantCurrent->getSettingValue(MerchantSettingDefinition::EMAIL_SUBJECT_PREFIX);
$emailSubjectPrefix = isset($params[self::SUBJECT_PREFIX]) ? $params[self::SUBJECT_PREFIX] : $merchantConfigEmailSubjectPrefix;
$merchantConfigEmailSubjectPrefix = $this->settingSolver->getSettingValue($merchantCurrent, MerchantSettingDefinition::SETTING_EMAIL_SUBJECT_PREFIX);
$emailSubjectPrefix = isset($params[self::SUBJECT_PREFIX]) ?? $merchantConfigEmailSubjectPrefix;
if ($emailSubjectPrefix && strlen($emailSubjectPrefix)) {
$emailSubjectPrefix .= ' ';
}
@@ -64,11 +68,11 @@ class MailMailjetNotification

if ($this->parameterBag->get('mailjet.dev.redirect.active')==1) {
$message->addTo($this->parameterBag->get('mailjet.dev.redirect.email'),
isset($params[self::TO_NAME]) ? $params[self::TO_NAME] : null);
isset($params[self::TO_NAME]) ?? null);
} else {
$message->addTo(
$params[self::TO_EMAIL],
isset($params[self::TO_NAME]) ? $params[self::TO_NAME] : null);
isset($params[self::TO_NAME]) ?? null);
}

$contentData = [] ;

+ 6
- 0
Repository/Address/AddressRepositoryQuery.php View File

@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Repository\Address;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class AddressRepositoryQuery extends AbstractRepositoryQuery
@@ -14,4 +15,9 @@ class AddressRepositoryQuery extends AbstractRepositoryQuery
{
parent::__construct($repository, 'r', $paginator);
}

public function filterByUser(UserInterface $user)
{
return $this->andWhereEqual('user', $user);
}
}

+ 9
- 0
Repository/Address/AddressStore.php View File

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

use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractStore;
use Lc\SovBundle\Repository\RepositoryQueryInterface;

@@ -32,4 +33,12 @@ class AddressStore extends AbstractStore
{
return $query;
}

public function getByUser(UserInterface $user)
{
$query = $this->createDefaultQuery();
$query->filterByUser($user);
return $query->find();
}

}

+ 3
- 1
Repository/Order/OrderProductStore.php View File

@@ -27,7 +27,9 @@ class OrderProductStore extends AbstractStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
if($this->section) {
$query->filterBySection($this->section);
}
return $query;
}


+ 17
- 11
Repository/Order/OrderShopStore.php View File

@@ -10,6 +10,7 @@ use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Repository\Merchant\MerchantStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCartStore;
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore;
use Lc\CaracoleBundle\Repository\Section\SectionStore;
use Lc\CaracoleBundle\Resolver\OpeningResolver;
@@ -42,6 +43,7 @@ class OrderShopStore extends AbstractStore
protected ParameterBagInterface $parameterBag;
protected UrlGeneratorInterface $router;
protected OrderShopSolver $orderShopSolver;
protected ReductionCartStore $reductionCartStore;

public function __construct(
OrderShopRepositoryQuery $query,
@@ -56,7 +58,8 @@ class OrderShopStore extends AbstractStore
FlashBagInterface $flashBag,
ParameterBagInterface $parameterBag,
UrlGeneratorInterface $router,
OrderShopSolver $orderShopSolver
OrderShopSolver $orderShopSolver,
ReductionCartStore $reductionCartStore
) {
$this->query = $query;
$this->entityManager = $entityManager;
@@ -71,6 +74,7 @@ class OrderShopStore extends AbstractStore
$this->parameterBag = $parameterBag;
$this->router = $router;
$this->orderShopSolver = $orderShopSolver;
$this->reductionCartStore = $reductionCartStore;
}

public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
@@ -130,10 +134,13 @@ class OrderShopStore extends AbstractStore
public function countByCurrentCycle(array $params, $query = null)
{
return $this->countBy(
[
'cycleNumber' => $this->orderShopSolver->getCycleNumberCurrentOrder($this->section),
'excludeComplementaryOrderShops' => isset($params['excludeComplementaryOrderShops']) ?? true,
],
array_merge(
[
'cycleNumber' => $this->orderShopSolver->getCycleNumberCurrentOrder($this->section),
'excludeComplementaryOrderShops' => isset($params['excludeComplementaryOrderShops']) ?? true,
],
$params
),
$query
);

@@ -188,7 +195,7 @@ class OrderShopStore extends AbstractStore
);
}

public function countValidByUser(UserInterface $user, $query = null): int
public function countValidByUser(UserInterface $user = null, $query = null): int
{
return $this->countBy(
[
@@ -498,14 +505,13 @@ class OrderShopStore extends AbstractStore
// findAllAvailableForUser / getReductionCartsAvailableByUser
public function getReductionCartAvailableByUser(UserInterface $user, $query = null)
{
$query = $this->createQuery($query);
$reductionCarts = $query->find();
$reductionCarts = $this->reductionCartStore->getOnline();

$reductionCartsArray = [];
foreach ($reductionCarts as $reductionCart) {
if ($this->reductionCartSolver->matchWithUser($user)
&& $this->reductionCartSolver->matchWithGroupUser($user)
&& $this->getRemainingQuantityByUser($reductionCart, $user)
if ($this->reductionCartSolver->matchWithUser($reductionCart, $user)
&& $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user)
&& $this->getReductionCartRemainingQuantityByUser($reductionCart, $user)
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0)) {
$reductionCartsArray[] = $reductionCart;
}

+ 4
- 1
Repository/Product/ProductFamilyStore.php View File

@@ -32,7 +32,10 @@ class ProductFamilyStore extends AbstractStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
if($this->section) {
$query->filterBySection($this->section);
}

return $query;
}


+ 2
- 1
Repository/Reduction/ReductionCartRepositoryQuery.php View File

@@ -4,11 +4,12 @@ namespace Lc\CaracoleBundle\Repository\Reduction;

use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ReductionCartRepositoryQuery extends AbstractRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;

public function __construct(ReductionCartRepository $repository, PaginatorInterface $paginator)
{

+ 3
- 1
Repository/Reduction/ReductionCartStore.php View File

@@ -38,7 +38,9 @@ class ReductionCartStore extends AbstractStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
if($this->section) {
$query->filterBySection($this->section);
}
$query->filterIsOnlineAndOffline();
return $query;
}

+ 3
- 1
Repository/Reduction/ReductionCatalogStore.php View File

@@ -26,7 +26,9 @@ class ReductionCatalogStore extends AbstractStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
if($this->section) {
$query->filterBySection($this->section);
}
$query->filterIsOnlineAndOffline();
return $query;
}

+ 2
- 1
Repository/Reduction/ReductionCreditRepositoryQuery.php View File

@@ -5,12 +5,13 @@ namespace Lc\CaracoleBundle\Repository\Reduction;
use Knp\Component\Pager\PaginatorInterface;
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel;
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait;
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Repository\AbstractRepositoryQuery;

class ReductionCreditRepositoryQuery extends AbstractRepositoryQuery
{
use MerchantRepositoryQueryTrait;
use SectionRepositoryQueryTrait;

public function __construct(ReductionCreditRepository $repository, PaginatorInterface $paginator)
{

+ 3
- 1
Repository/Reduction/ReductionCreditStore.php View File

@@ -31,7 +31,9 @@ class ReductionCreditStore extends AbstractStore

public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
{
$query->filterBySection($this->section);
if($this->section) {
$query->filterBySection($this->section);
}
$query->filterIsOnlineAndOffline();
return $query;
}

+ 3
- 1
Resources/translations/admin.fr.yaml View File

@@ -59,6 +59,7 @@ entity:
behaviorTaxRateChoices:
tax-excluded: TVA exclue
tax-included: Tva incluse

PointSale:
label: Point de vente
label_plurial: Points de vente
@@ -73,12 +74,13 @@ entity:
individual: Particulier
civility: Civilité
zip: Code postal
city: Ville
city: Commune
address: Adresse
phone: Téléphone
company: Entreprise
siret: SIRET
tva: Numero de TVA

Merchant:
label: Marchand
label_plurial: Marchands

+ 78
- 0
Solver/Credit/CreditHistorySolver.php View File

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

namespace Lc\CaracoleBundle\Solver\Credit;

use Lc\CaracoleBundle\Model\Credit\CreditHistoryInterface;

class CreditHistorySolver
{
public function getMeanPaymentInheritedLabel(CreditHistoryInterface $creditHistory): string
{
return 'entity.CreditHistory.fields.meanPaymentOptions.' . $this->getMeanPaymentInherited($creditHistory);
}

public function getAmountInherited(CreditHistoryInterface $creditHistory): float
{
if ($creditHistory->getOrderPayment() !== null) {
return $creditHistory->getOrderPayment()->getAmount();
} else {
if ($creditHistory->getOrderRefund() !== null) {
return $creditHistory->getOrderRefund()->getAmount();
} else {
return $creditHistory->getAmount();
}
}
}

public function getMeanPaymentInherited(CreditHistoryInterface $creditHistory): string
{
if ($creditHistory->getOrderPayment() !== null) {
return $creditHistory->getOrderPayment()->getMeanPayment();
} else {
if ($creditHistory->getOrderRefund() !== null) {
return $creditHistory->getOrderRefund()->getMeanPayment();
} else {
return $creditHistory->getMeanPayment();
}
}
}

public function getPaidAtInherited(CreditHistoryInterface $creditHistory): ?\DateTimeInterface
{
if ($creditHistory->getOrderPayment() !== null) {
return $creditHistory->getOrderPayment()->getPaidAt();
} else {
if ($creditHistory->getOrderRefund() !== null) {
return $creditHistory->getOrderRefund()->getPaidAt();
} else {
return $creditHistory->getPaidAt();
}
}
}

public function getReferenceInherited(CreditHistoryInterface $creditHistory): ?string
{
if ($creditHistory->getOrderPayment() !== null) {
return $creditHistory->getOrderPayment()->getReference();
} else {
if ($creditHistory->getOrderRefund() !== null) {
return $creditHistory->getOrderRefund()->getReference();
} else {
return $creditHistory->getReference();
}
}
}

public function getCommentInherited(CreditHistoryInterface $creditHistory): ?string
{
if ($creditHistory->getOrderPayment() !== null) {
return $creditHistory->getOrderPayment()->getComment();
} else {
if ($creditHistory->getOrderRefund() !== null) {
return $creditHistory->getOrderRefund()->getComment();
} else {
return $creditHistory->getComment();
}
}
}
}

Loading…
Cancel
Save