@@ -47,23 +47,20 @@ class ReductionCreditBuilder | |||
$user = $orderShop->getUser(); | |||
$orderProductsGiftVouchers = $this->orderProductStore->getGiftVouchersByOrder($orderShop); | |||
$sectionMarket = $this->sectionStore | |||
->setMerchant($orderShop->getSection()->getMerchant()) | |||
->getOneMarket(); | |||
foreach ($orderProductsGiftVouchers as $orderProductsGiftVoucher) { | |||
$i = 1; | |||
// création de la reductionCredit | |||
while ($i <= $orderProductsGiftVoucher->getQuantityOrder()) { | |||
$reductionGift = $this->reductionCreditFactory->create($sectionMarket, ReductionCreditModel::TYPE_GIFT); | |||
$reductionGift = $this->reductionCreditFactory->create($orderShop->getSection()->getMerchant(), ReductionCreditModel::TYPE_GIFT); | |||
$reductionGift->setTitle($orderProductsGiftVoucher->getTitle()); | |||
$reductionGift->setOwner($user); | |||
$reductionGift->setCreatedBy($user); | |||
$reductionGift->setUpdatedBy($user); | |||
$reductionGift->setValue($this->priceSolver->getPriceWithTax($orderProductsGiftVoucher->getProduct())); | |||
$reductionGift->setBehaviorTaxRate(TaxRateModel::BEHAVIOR_TAX_RATE_INCLUDED); | |||
$this->entityManager->persist($reductionGift); | |||
$this->entityManager->create($reductionGift); | |||
$i++; | |||
} |
@@ -16,7 +16,7 @@ abstract class ReductionCartAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
return $this->getReductionCartContainer()->getFactory()->create($this->getSectionCurrent()); | |||
return $this->getReductionCartContainer()->getFactory()->create($this->getMerchantCurrent()); | |||
} | |||
} |
@@ -14,6 +14,6 @@ abstract class ReductionCatalogAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
return $this->getReductionCatalogContainer()->getFactory()->create($this->getSectionCurrent()); | |||
return $this->getReductionCatalogContainer()->getFactory()->create($this->getMerchantCurrent()); | |||
} | |||
} |
@@ -15,6 +15,6 @@ abstract class ReductionCreditAdminController extends AbstractAdminController | |||
public function createEntity(string $entityFqcn) | |||
{ | |||
return $this->getReductionCreditContainer()->getFactory()->create($this->getSectionCurrent()); | |||
return $this->getReductionCreditContainer()->getFactory()->create($this->getMerchantCurrent()); | |||
} | |||
} |
@@ -3,20 +3,18 @@ | |||
namespace Lc\CaracoleBundle\Factory\Reduction; | |||
use App\Entity\Reduction\ReductionCart; | |||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCartInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
class ReductionCartFactory extends AbstractFactory | |||
{ | |||
public function create(SectionInterface $section): ReductionCartInterface | |||
public function create(MerchantInterface $merchant): ReductionCartInterface | |||
{ | |||
$reductionCart = new ReductionCart(); | |||
$reductionCart->setSection($section); | |||
$reductionCart->setMerchant($merchant); | |||
$reductionCart->setStatus(1); | |||
return $reductionCart; |
@@ -3,20 +3,18 @@ | |||
namespace Lc\CaracoleBundle\Factory\Reduction; | |||
use App\Entity\Reduction\ReductionCatalog; | |||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCatalogInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
class ReductionCatalogFactory extends AbstractFactory | |||
{ | |||
public function create(SectionInterface $section): ReductionCatalogInterface | |||
public function create(MerchantInterface $merchant): ReductionCatalogInterface | |||
{ | |||
$reductionCatalog = new ReductionCatalog(); | |||
$reductionCatalog->setSection($section); | |||
$reductionCatalog->setMerchant($merchant); | |||
$reductionCatalog->setStatus(1); | |||
return $reductionCatalog; |
@@ -3,21 +3,19 @@ | |||
namespace Lc\CaracoleBundle\Factory\Reduction; | |||
use App\Entity\Reduction\ReductionCredit; | |||
use Lc\CaracoleBundle\Context\MerchantContextTrait; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditInterface; | |||
use Lc\CaracoleBundle\Model\Reduction\ReductionCreditModel; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Factory\AbstractFactory; | |||
class ReductionCreditFactory extends AbstractFactory | |||
{ | |||
public function create(SectionInterface $section, string $type = ReductionCreditModel::TYPE_CREDIT): ReductionCreditInterface | |||
public function create(MerchantInterface $merchant, string $type = ReductionCreditModel::TYPE_CREDIT): ReductionCreditInterface | |||
{ | |||
$reductionCredit = new ReductionCredit(); | |||
$reductionCredit->setSection($section); | |||
$reductionCredit->setMerchant($merchant); | |||
$reductionCredit->setType($type); | |||
$reductionCredit->setStatus(1); | |||
@@ -40,7 +40,6 @@ class ProductCategoriesFilter extends AssociationFilter | |||
} | |||
$section = ' ['.$category->getSection()->getTitle().']' ;; | |||
return $category . $section. $isOffline; | |||
} | |||
) | |||
); |
@@ -6,7 +6,6 @@ use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\OrderAmountMinTrait; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionCartPropertyInterface; | |||
@@ -17,19 +16,18 @@ use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\PointSale\PointSaleInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | |||
use Lc\SovBundle\Doctrine\Extension\StatusTrait; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class ReductionCartModel extends AbstractLightEntity implements ReductionPropertyInterface, ReductionInterface, | |||
ReductionCartPropertyInterface, | |||
FilterSectionInterface, | |||
OrderAmountMinInterface, StatusInterface | |||
FilterMerchantInterface, | |||
OrderAmountMinInterface, | |||
StatusInterface | |||
{ | |||
use StatusTrait; | |||
use OrderAmountMinTrait; | |||
@@ -48,10 +46,10 @@ abstract class ReductionCartModel extends AbstractLightEntity implements Reducti | |||
protected $title; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $section; | |||
protected $merchant; | |||
/** | |||
* @ORM\Column(type="array", nullable=true) | |||
@@ -112,19 +110,18 @@ abstract class ReductionCartModel extends AbstractLightEntity implements Reducti | |||
return $this; | |||
} | |||
public function getSection(): SectionInterface | |||
public function getMerchant(): MerchantInterface | |||
{ | |||
return $this->section; | |||
return $this->merchant; | |||
} | |||
public function setSection(SectionInterface $section): self | |||
public function setMerchant(MerchantInterface $merchant): self | |||
{ | |||
$this->section = $section; | |||
$this->merchant = $merchant; | |||
return $this; | |||
} | |||
public function getCodes(): ?array | |||
{ | |||
return $this->codes; |
@@ -5,15 +5,13 @@ namespace Lc\CaracoleBundle\Model\Reduction; | |||
use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyTrait; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionPropertyInterface; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductCategoryInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyModel; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | |||
use Lc\SovBundle\Doctrine\Extension\StatusTrait; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||
@@ -23,7 +21,8 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||
*/ | |||
abstract class ReductionCatalogModel extends AbstractLightEntity implements ReductionCatalogInterface, | |||
ReductionPropertyInterface, | |||
FilterSectionInterface, StatusInterface | |||
FilterMerchantInterface, | |||
StatusInterface | |||
{ | |||
use StatusTrait; | |||
use ReductionTrait; | |||
@@ -37,10 +36,10 @@ abstract class ReductionCatalogModel extends AbstractLightEntity implements Redu | |||
protected $title; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $section; | |||
protected $merchant; | |||
/** | |||
* @ORM\ManyToMany(targetEntity="Lc\CaracoleBundle\Model\Product\ProductFamilyInterface") | |||
@@ -76,14 +75,14 @@ abstract class ReductionCatalogModel extends AbstractLightEntity implements Redu | |||
return $this; | |||
} | |||
public function getSection(): SectionInterface | |||
public function getMerchant(): MerchantInterface | |||
{ | |||
return $this->section; | |||
return $this->merchant; | |||
} | |||
public function setSection(SectionInterface $section): self | |||
public function setMerchant(MerchantInterface $merchant): self | |||
{ | |||
$this->section = $section; | |||
$this->merchant = $merchant; | |||
return $this; | |||
} |
@@ -6,12 +6,10 @@ use Doctrine\Common\Collections\ArrayCollection; | |||
use Doctrine\Common\Collections\Collection; | |||
use Doctrine\ORM\Mapping as ORM; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterMerchantInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\FilterSectionInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionInterface; | |||
use Lc\CaracoleBundle\Doctrine\Extension\ReductionTrait; | |||
use Lc\CaracoleBundle\Model\Config\UnitModel; | |||
use Lc\CaracoleBundle\Model\Merchant\MerchantInterface; | |||
use Lc\CaracoleBundle\Model\Section\SectionInterface; | |||
use Lc\SovBundle\Doctrine\Extension\StatusInterface; | |||
use Lc\SovBundle\Doctrine\Extension\StatusTrait; | |||
use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity; | |||
@@ -20,7 +18,8 @@ use Lc\SovBundle\Model\User\UserInterface; | |||
/** | |||
* @ORM\MappedSuperclass() | |||
*/ | |||
abstract class ReductionCreditModel extends AbstractLightEntity implements ReductionInterface, FilterSectionInterface, | |||
abstract class ReductionCreditModel extends AbstractLightEntity implements ReductionInterface, | |||
FilterMerchantInterface, | |||
StatusInterface | |||
{ | |||
const TYPE_CREDIT = 'credit'; | |||
@@ -40,10 +39,10 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc | |||
protected $users; | |||
/** | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Section\SectionInterface") | |||
* @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface") | |||
* @ORM\JoinColumn(nullable=false) | |||
*/ | |||
protected $section; | |||
protected $merchant; | |||
/** | |||
* @ORM\Column(type="string", length=255) | |||
@@ -99,14 +98,14 @@ abstract class ReductionCreditModel extends AbstractLightEntity implements Reduc | |||
return $this; | |||
} | |||
public function getSection(): SectionInterface | |||
public function getMerchant(): MerchantInterface | |||
{ | |||
return $this->section; | |||
return $this->merchant; | |||
} | |||
public function setSection(SectionInterface $section): self | |||
public function setMerchant(MerchantInterface $merchant): self | |||
{ | |||
$this->section = $section; | |||
$this->merchant = $merchant; | |||
return $this; | |||
} |
@@ -4,6 +4,7 @@ namespace Lc\CaracoleBundle\Repository\Order; | |||
use App\Builder\Distribution\DistributionBuilder; | |||
use App\Entity\Distribution\Distribution; | |||
use App\Entity\User\User; | |||
use Doctrine\ORM\EntityManagerInterface; | |||
use Lc\CaracoleBundle\Builder\File\DocumentBuilder; | |||
use Lc\CaracoleBundle\Model\Distribution\DistributionInterface; | |||
@@ -241,6 +242,7 @@ class OrderShopStore extends AbstractStore | |||
//TODO vérifier que ne pas utiliser createDefaultQuery est pertinent | |||
$query = $this->createQuery($query); | |||
if ($user) { | |||
$query->filterByUser($user); | |||
} | |||
@@ -474,12 +476,13 @@ class OrderShopStore extends AbstractStore | |||
public function getReductionCreditsAvailableByUser(UserInterface $user): array | |||
{ | |||
$reductionCredits = $this->reductionCreditStore->getByTypeAndUser(ReductionCreditModel::TYPE_CREDIT, $user); | |||
$reductionCredits = $this->reductionCreditStore | |||
->setMerchant($this->merchant) | |||
->getByTypeAndUser(ReductionCreditModel::TYPE_CREDIT, $user); | |||
$reductionCreditsArray = []; | |||
foreach ($reductionCredits as $reductionCredit) { | |||
if (!$this->countValidWithReductionCredit($reductionCredit, $user) | |||
&& ($reductionCredit->getSection()->getMerchant() == $this->merchant)) { | |||
if (!$this->countValidWithReductionCredit($reductionCredit, $user)) { | |||
$reductionCreditsArray[] = $reductionCredit; | |||
} | |||
} | |||
@@ -487,13 +490,15 @@ class OrderShopStore extends AbstractStore | |||
return $reductionCreditsArray; | |||
} | |||
public function getReductionGiftsAvailableByUser($user): array | |||
public function getReductionGiftsAvailableByUser(UserInterface $user): array | |||
{ | |||
$reductionGifts = $this->reductionCreditStore->getByTypeAndUser(ReductionCreditModel::TYPE_GIFT, $user); | |||
$reductionGifts = $this->reductionCreditStore | |||
->setMerchant($this->merchant) | |||
->getByTypeAndUser(ReductionCreditModel::TYPE_GIFT, $user); | |||
$reductionGiftsArray = []; | |||
foreach ($reductionGifts as $reductionGift) { | |||
if (!$this->countValidWithReductionCredit($reductionGift)) { | |||
if (!$this->countValidWithReductionCredit($reductionGift, $user)) { | |||
$reductionGiftsArray[] = $reductionGift; | |||
} | |||
} | |||
@@ -541,7 +546,9 @@ class OrderShopStore extends AbstractStore | |||
// findAllAvailableForUser / getReductionCartsAvailableByUser | |||
public function getReductionCartAvailableByUser(UserInterface $user, $query = null) | |||
{ | |||
$reductionCarts = $this->reductionCartStore->getOnline(); | |||
$reductionCarts = $this->reductionCartStore | |||
->setMerchant($this->merchant) | |||
->getOnline(); | |||
$reductionCartsArray = []; | |||
foreach ($reductionCarts as $reductionCart) { | |||
@@ -549,7 +556,7 @@ class OrderShopStore extends AbstractStore | |||
&& $this->reductionCartSolver->matchWithGroupUser($reductionCart, $user) | |||
&& $this->getReductionCartRemainingQuantityByUser($reductionCart, $user) | |||
&& ($reductionCart->getUsers()->count() > 0 || $reductionCart->getGroupUsers()->count() > 0) | |||
&& (!$this->merchant || $reductionCart->getSection()->getMerchant() == $this->merchant)) { | |||
&& (!$this->merchant || $reductionCart->getMerchant() == $this->merchant)) { | |||
$reductionCartsArray[] = $reductionCart; | |||
} |
@@ -4,12 +4,11 @@ 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 SectionRepositoryQueryTrait; | |||
use MerchantRepositoryQueryTrait; | |||
public function __construct(ReductionCartRepository $repository, PaginatorInterface $paginator) | |||
{ |
@@ -2,7 +2,7 @@ | |||
namespace Lc\CaracoleBundle\Repository\Reduction; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
use Lc\CaracoleBundle\Solver\Reduction\ReductionCartSolver; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
@@ -10,7 +10,7 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ReductionCartStore extends AbstractStore | |||
{ | |||
use SectionStoreTrait; | |||
use MerchantStoreTrait; | |||
protected ReductionCartRepositoryQuery $query; | |||
protected ReductionCartSolver $reductionCartSolver; | |||
@@ -34,10 +34,9 @@ class ReductionCartStore extends AbstractStore | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
if($this->section) { | |||
$query->filterBySection($this->section); | |||
} | |||
$this->addFilterByMerchantRequired($query); | |||
$query->filterIsOnlineAndOffline(); | |||
return $query; | |||
} | |||
@@ -5,7 +5,6 @@ namespace Lc\CaracoleBundle\Repository\Reduction; | |||
use Knp\Component\Pager\PaginatorInterface; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Repository\MerchantRepositoryQueryTrait; | |||
use Lc\CaracoleBundle\Repository\SectionRepositoryQueryTrait; | |||
use Lc\SovBundle\Model\User\UserInterface; | |||
use Lc\SovBundle\Repository\AbstractRepositoryQuery; | |||
@@ -17,7 +16,7 @@ class ReductionCatalogRepositoryQuery extends AbstractRepositoryQuery | |||
protected bool $isJoinUsers = false; | |||
protected bool $isJoinGroupUsers = false; | |||
use SectionRepositoryQueryTrait; | |||
use MerchantRepositoryQueryTrait; | |||
public function __construct(ReductionCatalogRepository $repository, PaginatorInterface $paginator) | |||
{ |
@@ -3,13 +3,13 @@ | |||
namespace Lc\CaracoleBundle\Repository\Reduction; | |||
use Lc\CaracoleBundle\Model\Product\ProductFamilyInterface; | |||
use Lc\CaracoleBundle\Repository\SectionStoreTrait; | |||
use Lc\CaracoleBundle\Repository\MerchantStoreTrait; | |||
use Lc\CaracoleBundle\Repository\AbstractStore; | |||
use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ReductionCatalogStore extends AbstractStore | |||
{ | |||
use SectionStoreTrait; | |||
use MerchantStoreTrait; | |||
protected ReductionCatalogRepositoryQuery $query; | |||
@@ -26,7 +26,7 @@ class ReductionCatalogStore extends AbstractStore | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$this->addFilterBySectionOptionnal($query); | |||
$this->addFilterByMerchantRequired($query); | |||
$query->filterIsOnlineAndOffline(); | |||
return $query; | |||
} |
@@ -5,14 +5,14 @@ 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 SectionRepositoryQueryTrait; | |||
use MerchantRepositoryQueryTrait; | |||
// @TODO : à utiliser | |||
protected $isJoinUsers = false; | |||
public function __construct(ReductionCreditRepository $repository, PaginatorInterface $paginator) |
@@ -10,7 +10,6 @@ use Lc\SovBundle\Repository\RepositoryQueryInterface; | |||
class ReductionCreditStore extends AbstractStore | |||
{ | |||
use SectionStoreTrait; | |||
use MerchantStoreTrait; | |||
protected ReductionCreditRepositoryQuery $query; | |||
@@ -29,9 +28,7 @@ class ReductionCreditStore extends AbstractStore | |||
public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface | |||
{ | |||
$this->addFilterBySectionOptionnal($query); | |||
$this->addFilterByMerchantViaSectionOptionnal($query); | |||
$this->addFilterByMerchantRequired($query); | |||
$query->filterIsOnlineAndOffline(); | |||
return $query; |
@@ -5,6 +5,8 @@ namespace Lc\CaracoleBundle\Transformer\Order; | |||
use App\Entity\Order\OrderShop; | |||
use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; | |||
use Lc\CaracoleBundle\Model\Order\OrderShopInterface; | |||
use Lc\CaracoleBundle\Repository\Order\OrderShopStore; | |||
use Lc\CaracoleBundle\Repository\Reduction\ReductionCreditStore; | |||
use Lc\CaracoleBundle\Resolver\OrderShopResolver; | |||
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver; | |||
use Lc\CaracoleBundle\Solver\Price\PriceSolver; | |||
@@ -20,9 +22,13 @@ class OrderShopTransformer | |||
protected TranslatorAdmin $translatorAdmin; | |||
protected UrlGeneratorInterface $urlGenerator; | |||
public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver, OrderShopResolver $orderShopResolver, TranslatorAdmin $translatorAdmin, UrlGeneratorInterface $urlGenerator) | |||
{ | |||
public function __construct( | |||
PriceSolver $priceSolver, | |||
OrderShopSolver $orderShopSolver, | |||
OrderShopResolver $orderShopResolver, | |||
TranslatorAdmin $translatorAdmin, | |||
UrlGeneratorInterface $urlGenerator | |||
) { | |||
$this->priceSolver = $priceSolver; | |||
$this->orderShopSolver = $orderShopSolver; | |||
$this->orderShopResolver = $orderShopResolver; | |||
@@ -34,15 +40,12 @@ class OrderShopTransformer | |||
public function getDatas(OrderShopInterface $orderShop, UserInterface $user = null): array | |||
{ | |||
$data = []; | |||
$data['order'] = $orderShop; | |||
$data['count'] = $this->orderShopSolver->countQuantities($orderShop); | |||
$data['total_with_tax'] = $this->priceSolver->getTotalWithTax($orderShop); | |||
$data['order_products_by_category'] = $this->orderShopSolver->getOrderProductsByParentCategory($orderShop); | |||
$data['total_remaining_to_be_paid'] = $this->orderShopResolver->getTotalRemainingToBePaid($orderShop); | |||
if ($orderShop) { | |||
$data['count'] = $this->orderShopSolver->countQuantities($orderShop); | |||
$data['total_with_tax'] = $this->priceSolver->getTotalWithTax($orderShop); | |||
$data['order_products_by_category'] = $this->orderShopSolver->getOrderProductsByParentCategory($orderShop); | |||
$data['total_remaining_to_be_paid'] = $this->orderShopResolver->getTotalRemainingToBePaid($orderShop); | |||
} | |||
return $data; | |||
} | |||
@@ -103,7 +106,6 @@ class OrderShopTransformer | |||
{ | |||
$data = array(); | |||
foreach ($order->getOrderPayments() as $orderPayment) { | |||
$data[$orderPayment->getId()] = array( | |||
'id' => $orderPayment->getId(), | |||
'reference' => $orderPayment->getReference(), | |||
@@ -111,7 +113,9 @@ class OrderShopTransformer | |||
'comment' => $orderPayment->getComment(), | |||
'meanPayment' => $orderPayment->getMeanPayment(), | |||
'meanPaymentText' => $this->translatorAdmin->transChoice( | |||
'OrderPayment', 'meanPayment',$orderPayment->getMeanPayment() | |||
'OrderPayment', | |||
'meanPayment', | |||
$orderPayment->getMeanPayment() | |||
), | |||
'paidAtText' => $orderPayment->getPaidAt()->format('d/m/Y'), | |||
'paidAt' => $orderPayment->getPaidAt()->format('Y-m-d'), | |||
@@ -186,7 +190,7 @@ class OrderShopTransformer | |||
'type' => $orderDocument->getType(), | |||
'isSent' => $orderDocument->getIsSent(), | |||
'orderReference' => $order->getReference(), | |||
'link' => $this->urlGenerator->generate('document_download', ['id'=> $orderDocument->getId()]) | |||
'link' => $this->urlGenerator->generate('document_download', ['id' => $orderDocument->getId()]) | |||
); | |||
} | |||
return $data; |