Kaynağa Gözat

Intégration app order

packProduct
Fab 3 yıl önce
ebeveyn
işleme
9e60dc3fa2
11 değiştirilmiş dosya ile 250 ekleme ve 51 silme
  1. +8
    -8
      Form/Order/OrderProductType.php
  2. +38
    -0
      Form/Reduction/BehaviorTaxRateType.php
  3. +24
    -0
      Form/Reduction/ValueType.php
  4. +2
    -9
      Model/Credit/CreditHistoryModel.php
  5. +8
    -0
      Model/Order/OrderPaymentModel.php
  6. +2
    -0
      Model/Order/OrderShopModel.php
  7. +21
    -0
      Solver/Order/OrderPaymentSolver.php
  8. +26
    -25
      Solver/Price/OrderShopPriceSolver.php
  9. +3
    -3
      Solver/Product/ProductFamilySolver.php
  10. +2
    -2
      Solver/Product/ProductSolver.php
  11. +116
    -4
      Transformer/Order/OrderShopTransformer.php

+ 8
- 8
Form/Order/OrderProductType.php Dosyayı Görüntüle

@@ -24,8 +24,6 @@ class OrderProductType extends AbstractType

public function buildForm(FormBuilderInterface $builder, array $options)
{
$data = $options['data'];

$builder
->add('quantityOrder', NumberType::class)
->add('product', HiddenType::class);
@@ -35,10 +33,12 @@ class OrderProductType extends AbstractType

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

+ 38
- 0
Form/Reduction/BehaviorTaxRateType.php Dosyayı Görüntüle

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

namespace Lc\CaracoleBundle\Form\Reduction;

use Lc\CaracoleBundle\Model\Config\TaxRateModel;
use Lc\SovBundle\Translation\TranslatorAdmin;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\OptionsResolver\OptionsResolver;

class BehaviorTaxRateType extends AbstractType
{
protected TranslatorAdmin $translatorAdmin;
public function __construct(TranslatorAdmin $translatorAdmin)
{
$this->translatorAdmin = $translatorAdmin;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$builder = $event->getForm()->getParent();

$builder->add('behaviorTaxRate', ChoiceType::class, [
'required' => false,
'empty_data' => TaxRateModel::BEHAVIOR_TAX_RATE_INCLUDED,
'choices' => $this->translatorAdmin->transChoices(
TaxRateModel::getBehaviorTaxRateChoices(),
'TaxRate',
'behaviorTaxRate'
)
]);
});
}
}

+ 24
- 0
Form/Reduction/ValueType.php Dosyayı Görüntüle

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

namespace Lc\CaracoleBundle\Form\Reduction;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents;

class ValueType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
$builder = $event->getForm()->getParent();

$builder->add('value', NumberType::class, [
'required' => false
]);
});
}

}

+ 2
- 9
Model/Credit/CreditHistoryModel.php Dosyayı Görüntüle

@@ -19,17 +19,9 @@ abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffI
{
use PayoffTrait;


const TYPE_CREDIT = 'credit';
const TYPE_DEBIT = 'debit';

const MEAN_PAYMENT_CREDIT_CARD = 'cb';
const MEAN_PAYMENT_CHEQUE = 'cheque';
const MEAN_PAYMENT_CREDIT = 'credit';
const MEAN_PAYMENT_TRANSFER = 'transfer';
const MEAN_PAYMENT_CASH = 'cash';
const MEAN_PAYMENT_GIFT = 'transfer-gift';

/**
* @ORM\Column(type="float", nullable=true)
*/
@@ -56,7 +48,8 @@ abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffI
*/
protected $orderRefund;

public function __toString(){
public function __toString()
{
//Todo a écrire
return $this->getType();
}

+ 8
- 0
Model/Order/OrderPaymentModel.php Dosyayı Görüntüle

@@ -13,4 +13,12 @@ use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
abstract class OrderPaymentModel extends AbstractLightEntity implements OrderPayoffInterface
{
use OrderPayoffTrait;

const MEAN_PAYMENT_CREDIT_CARD = 'cb';
const MEAN_PAYMENT_CHEQUE = 'cheque';
const MEAN_PAYMENT_CREDIT = 'credit';
const MEAN_PAYMENT_TRANSFER = 'transfer';
const MEAN_PAYMENT_CASH = 'cash';
const MEAN_PAYMENT_GIFT = 'transfer-gift';

}

+ 2
- 0
Model/Order/OrderShopModel.php Dosyayı Görüntüle

@@ -22,6 +22,8 @@ abstract class OrderShopModel extends AbstractLightEntity implements FilterSecti
const DELIVERY_TYPE_HOME = 'home';
const DELIVERY_TYPE_POINTSALE = 'point-sale';



/**
* @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface", inversedBy="orderShops", fetch="EAGER")
*/

+ 21
- 0
Solver/Order/OrderPaymentSolver.php Dosyayı Görüntüle

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

namespace Lc\CaracoleBundle\Solver\Order;

use Lc\CaracoleBundle\Model\Order\OrderPaymentModel;

class OrderPaymentSolver
{

public function getMeanPaymentChoices()
{
return [
OrderPaymentModel::MEAN_PAYMENT_CREDIT_CARD,
OrderPaymentModel::MEAN_PAYMENT_CHEQUE,
OrderPaymentModel::MEAN_PAYMENT_CREDIT,
OrderPaymentModel::MEAN_PAYMENT_TRANSFER,
OrderPaymentModel::MEAN_PAYMENT_CASH,
OrderPaymentModel::MEAN_PAYMENT_GIFT,
];
}
}

+ 26
- 25
Solver/Price/OrderShopPriceSolver.php Dosyayı Görüntüle

@@ -10,6 +10,7 @@ use Lc\CaracoleBundle\Solver\Product\ProductSolver;

class OrderShopPriceSolver
{
//TODO vérifier si les round sont cohérents
use PriceSolverTrait;

protected OrderProductPriceSolver $orderProductPriceResolver;
@@ -35,7 +36,7 @@ class OrderShopPriceSolver
foreach ($orderShop->getOrderProducts() as $orderProduct) {
$total += $this->orderProductPriceResolver->getTotalWithReduction($orderProduct);
}
return $total;
return $this->round($total);
}

//Inclus les ReductionCatalog des OrderProducts
@@ -45,7 +46,7 @@ class OrderShopPriceSolver
foreach ($orderShop->getOrderProducts() as $orderProduct) {
$total += $this->orderProductPriceResolver->getTotalMargin($orderProduct);
}
return $total;
return $this->round($total);
}

public function getMarginOrderProductsWithReductions(OrderShopInterface $orderShop, $cache = false): float
@@ -72,7 +73,7 @@ class OrderShopPriceSolver

$total -= $totalReductionAmount;

return $total;
return $this->round($total);
}
}

@@ -137,7 +138,7 @@ class OrderShopPriceSolver
$total += $this->orderProductPriceResolver->getTotalBuyingPriceWithTax($orderProduct);
}

return $total;
return $this->round($total);
}

public function getTotalOrderProductsWithTaxByOrderProducts($orderProducts): float
@@ -147,7 +148,7 @@ class OrderShopPriceSolver
$total += $this->orderProductPriceResolver->getTotalWithTaxAndReduction($orderProduct);
}

return $total;
return $this->round($total);
}

public function getTotalOrderProductsTaxes(OrderShopInterface $orderShop): float
@@ -160,7 +161,7 @@ class OrderShopPriceSolver
);
}

return $total;
return $this->round($total);
}

public function getOrderProductsTaxesAsArray(OrderShopInterface $orderShop): array
@@ -177,12 +178,12 @@ class OrderShopPriceSolver
];
}

$orderProductsTaxes[$idTaxRate]['totalOrderProducts'] += $this->orderProductPriceResolver->getTotalWithReduction(
$orderProductsTaxes[$idTaxRate]['totalOrderProducts'] += $this->round($this->orderProductPriceResolver->getTotalWithReduction(
$orderProduct
) / $this->getReductionsCoef($orderShop);
$orderProductsTaxes[$idTaxRate]['totalTaxes'] += $this->orderProductPriceResolver->getTotalTaxes(
) / $this->getReductionsCoef($orderShop));
$orderProductsTaxes[$idTaxRate]['totalTaxes'] += $this->round($this->orderProductPriceResolver->getTotalTaxes(
$orderProduct
) / $this->getReductionsCoef($orderShop);
) / $this->getReductionsCoef($orderShop));
}

return $orderProductsTaxes;
@@ -195,7 +196,7 @@ class OrderShopPriceSolver

private function getTaxRateAverage(OrderShopInterface $orderShop): float
{
return $this->getTotalOrderProductsWithTax($orderShop) / $this->getTotalOrderProducts($orderShop);
return $this->round($this->getTotalOrderProductsWithTax($orderShop) / $this->getTotalOrderProducts($orderShop));
}

public function getTotalOrderProductsWithReductions(OrderShopInterface $orderShop, $cache = false)
@@ -206,7 +207,7 @@ class OrderShopPriceSolver
$total = $this->getTotalOrderProducts($orderShop);
$total -= $this->getTotalReductionCartsAmount($orderShop);
$total -= $this->getTotalReductionCreditsAmount($orderShop);
return $total;
return $this->round($total);
}
}

@@ -214,7 +215,7 @@ class OrderShopPriceSolver
{
$total = $this->getTotalOrderProducts($orderShop);
$total -= $this->getTotalReductionCartsAmount($orderShop);
return $total;
return $this->round($total);
}

public function getTotalReductionCartsAmount(OrderShopInterface $orderShop)
@@ -226,7 +227,7 @@ class OrderShopPriceSolver
$orderReductionCart
);
}
return $totalReductionAmount;
return $this->round($totalReductionAmount);
}

public function getTotalReductionCreditsAmount(OrderShopInterface $orderShop)
@@ -238,7 +239,7 @@ class OrderShopPriceSolver
$orderReductionCredit
);
}
return $totalReductionAmount;
return $this->round($totalReductionAmount);
}

public function getTotalOrderProductsWithTaxAndReductions(OrderShopInterface $orderShop, $cache = false)
@@ -249,7 +250,7 @@ class OrderShopPriceSolver
$total = $this->getTotalOrderProductsWithTax($orderShop);
$total -= $this->getTotalReductionCartsAmountWithTax($orderShop);
$total -= $this->getTotalReductionCreditsAmountWithTax($orderShop);
return $total;
return $this->round($total);
}
}

@@ -257,7 +258,7 @@ class OrderShopPriceSolver
{
$total = $this->getTotalOrderProductsWithTax($orderShop);
$total -= $this->getTotalReductionCartsAmountWithTax($orderShop);
return $total;
return $this->round($total);
}

public function getTotalReductionCartsAmountWithTax(OrderShopInterface $orderShop)
@@ -266,7 +267,7 @@ class OrderShopPriceSolver
foreach ($orderShop->getOrderReductionCarts() as $orderReductionCart) {
$totalReductionAmount += $this->getOrderProductsReductionCartAmountWithTax($orderShop, $orderReductionCart);
}
return $totalReductionAmount;
return $this->round($totalReductionAmount);
}

public function getTotalReductionCreditsAmountWithTax(OrderShopInterface $orderShop)
@@ -278,7 +279,7 @@ class OrderShopPriceSolver
$orderReductionCredit
);
}
return $totalReductionAmount;
return $this->round($totalReductionAmount);
}

public function getOrderProductsReductionCartAmountWithoutTax(OrderShopInterface $order, $orderReductionCart)
@@ -302,7 +303,7 @@ class OrderShopPriceSolver
}
}
}
return $amount;
return $this->round($amount);
}

public function getOrderProductsReductionCartAmountWithTax(OrderShopInterface $order, $orderReductionCart)
@@ -324,7 +325,7 @@ class OrderShopPriceSolver
}
}

return $amount;
return $this->round($amount);
}

public function getOrderProductsReductionCreditAmountWithoutTax(
@@ -340,7 +341,7 @@ class OrderShopPriceSolver
}
}

return $amount;
return $this->round($amount);
}

public function getOrderProductsReductionCreditAmountWithTax(
@@ -354,7 +355,7 @@ class OrderShopPriceSolver
$amountWithTax = $orderReductionCredit->getValue();
}

return $amountWithTax;
return $this->round($amountWithTax);
}

public function getTotalReductions(OrderShopInterface $orderShop)
@@ -369,7 +370,7 @@ class OrderShopPriceSolver
$total += $this->getOrderProductsReductionCreditAmountWithoutTax($orderShop, $orderReductionCredit);
}

return $total;
return $this->round($total);
}

public function getTotalReductionsWithTax(OrderShopInterface $orderShop)
@@ -384,7 +385,7 @@ class OrderShopPriceSolver
$total += $this->getOrderProductsReductionCreditAmountWithTax($orderShop, $orderReductionCredit);
}

return $total;
return $this->round($total);
}
}


+ 3
- 3
Solver/Product/ProductFamilySolver.php Dosyayı Görüntüle

@@ -148,13 +148,13 @@ class ProductFamilySolver
$products = $this->getProductsOnline($productFamily);

foreach ($products as $product) {
$titleProduct = $product->getTitleInherited();
$titleProduct = $this->productSolver->getTitleInherited($product);
if (!isset($arrayCountProducts[$titleProduct])) {
$arrayCountProducts[$titleProduct] = [];
}

if (!in_array($product->getQuantityLabelInherited(), $arrayCountProducts[$titleProduct])) {
$arrayCountProducts[$titleProduct][] = $product->getQuantityLabelInherited();
if (!in_array($this->productSolver->getQuantityLabelInherited($product), $arrayCountProducts[$titleProduct])) {
$arrayCountProducts[$titleProduct][] = $this->productSolver->getQuantityLabelInherited($product);
}

if (count($arrayCountProducts[$titleProduct]) > 1) {

+ 2
- 2
Solver/Product/ProductSolver.php Dosyayı Görüntüle

@@ -137,8 +137,8 @@ class ProductSolver

public function getQuantityLabelInherited(ProductInterface $product)
{
$quantity = $product->getQuantityInherited();
$unit = $product->getUnitInherited();
$quantity = $this->getQuantityInherited($product);
$unit = $this->getUnitInherited($product);
return $quantity . $unit->getWordingShort();
}


+ 116
- 4
Transformer/Order/OrderShopTransformer.php Dosyayı Görüntüle

@@ -2,24 +2,27 @@

namespace Lc\CaracoleBundle\Transformer\Order;

use App\Entity\Order\OrderShop;
use Lc\CaracoleBundle\Model\Order\OrderShopInterface;
use Lc\CaracoleBundle\Resolver\OrderShopResolver;
use Lc\CaracoleBundle\Resolver\ReductionResolver;
use Lc\CaracoleBundle\Solver\Order\OrderShopSolver;
use Lc\CaracoleBundle\Solver\Price\PriceSolver;
use Lc\SovBundle\Model\User\UserInterface;
use Lc\SovBundle\Translation\TranslatorAdmin;

class OrderShopTransformer
{
protected PriceSolver $priceSolver;
protected OrderShopSolver $orderShopSolver;
protected OrderShopResolver $orderShopResolver;
public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver, OrderShopResolver $orderShopResolver)
protected TranslatorAdmin $translatorAdmin;

public function __construct(PriceSolver $priceSolver, OrderShopSolver $orderShopSolver, OrderShopResolver $orderShopResolver, TranslatorAdmin $translatorAdmin)
{
$this->priceSolver = $priceSolver;
$this->orderShopSolver = $orderShopSolver;
$this->orderShopResolver = $orderShopResolver;
$this->translatorAdmin = $translatorAdmin;
}

// getOrderDatas
@@ -38,7 +41,7 @@ class OrderShopTransformer
return $data;
}

public function getAsJsonObject(OrderShopInterface $orderShop): array
public function getAsArray(OrderShopInterface $orderShop): array
{
$data['id'] = $orderShop->getId();
$data['user'] = $orderShop->getUser()->getSummary();
@@ -73,4 +76,113 @@ class OrderShopTransformer

return $data;
}

public function getOrderReductionCartsInfosAsArray(OrderShop $order): array
{
$data = array();
foreach ($order->getOrderReductionCarts() as $orderReductionCart) {
$data[] = array(
'title' => $orderReductionCart->__toString(),
'id' => $orderReductionCart->getId(),
'orderReference' => $order->getReference(),
'amount' => $this->priceSolver->getOrderProductsReductionCartAmountWithTax(
$order,
$orderReductionCart
)
);
}
return $data;
}

public function getOrderPaymentsInfosAsArray(OrderShop $order): array
{
$data = array();
foreach ($order->getOrderPayments() as $orderPayment) {
$data[$orderPayment->getId()] = array(
'id' => $orderPayment->getId(),
'reference' => $orderPayment->getReference(),
'orderReference' => $order->getReference(),
'comment' => $orderPayment->getComment(),
'meanPayment' => $orderPayment->getMeanPayment(),
'meanPaymentText' => $this->translatorAdmin->trans(
'field.default.meanPaymentOptions.' . $orderPayment->getMeanPayment()
),
'paidAtText' => $orderPayment->getPaidAt()->format('d/m/Y'),
'paidAt' => $orderPayment->getPaidAt()->format('Y-m-d'),
'amount' => $orderPayment->getAmount(),
'editable' => $orderPayment->getEditable()
);
}
return $data;
}

public function getOrderStatusHistoriesInfosAsArray(OrderShop $order): array
{
$data = array();
foreach ($order->getOrderStatusHistories() as $orderStatusHistory) {
$data[$orderStatusHistory->getId()] = array(
'id' => $orderStatusHistory->getId(),
'createdAt' => $orderStatusHistory->getCreatedAt()->format('d-m-Y H:i'),
'createdBy' => $orderStatusHistory->getCreatedBy() ? $orderStatusHistory->getCreatedBy(
)->__toString() : 'aucun',
'orderStatus' => $orderStatusHistory->getOrderStatus()->getAlias(),
'origin' => $orderStatusHistory->getOrigin(),
'info' => $orderStatusHistory->__toString(),
);
}
return $data;
}

public function getOrderReductionCreditsInfosAsArray(OrderShop $order): array
{
$data = array();

foreach ($order->getOrderReductionCredits() as $orderReductionCredit) {
$data[] = array(
'title' => $orderReductionCredit->__toString(),
'id' => $orderReductionCredit->getId(),
'orderReference' => $order->getReference(),
'amount' => $this->priceSolver->getOrderProductsReductionCreditAmountWithTax(
$order,
$orderReductionCredit
)
);
}
return $data;
}

public function getOrderTicketsInfosAsArray(OrderShop $order): array
{
$data = array();
foreach ($order->getTickets() as $ticket) {
$data[$ticket->getId()] = array(
'id' => $ticket->getId(),
'date' => $ticket->getCreatedAt()->format('d/m/Y'),
'status' => $this->translatorAdmin->trans(
'field.Ticket.statusOptions.' . $ticket->getStatus()
),
'subject' => $ticket->getSubject(),
'orderReference' => $order->getReference(),
'link' => '',
);
}
return $data;
}

public function getOrderDocumentsInfosAsArray(OrderShop $order): array
{
$data = array();
foreach ($order->getDocuments() as $orderDocument) {
$data[$orderDocument->getId()] = array(
'id' => $orderDocument->getId(),
'date' => $orderDocument->getCreatedAt()->format('d/m/Y'),
'reference' => $orderDocument->getReference(),
'type' => $orderDocument->getType(),
'isSent' => $orderDocument->getIsSent(),
'orderReference' => $order->getReference(),
);
}
return $data;
}

}

Yükleniyor…
İptal
Kaydet