Browse Source

Modal remboursement

feature/export_comptable
Fab 4 years ago
parent
commit
8af8a49883
12 changed files with 381 additions and 120 deletions
  1. +7
    -0
      ShopBundle/Context/OrderPayoffInterface.php
  2. +7
    -0
      ShopBundle/Context/OrderProductRefundInterface.php
  3. +7
    -0
      ShopBundle/Context/OrderRefundInterface.php
  4. +0
    -13
      ShopBundle/Model/AbstractEntity.php
  5. +23
    -0
      ShopBundle/Model/Document.php
  6. +3
    -107
      ShopBundle/Model/OrderPayment.php
  7. +147
    -0
      ShopBundle/Model/OrderPayoffTrait.php
  8. +21
    -0
      ShopBundle/Model/OrderProduct.php
  9. +87
    -0
      ShopBundle/Model/OrderProductRefund.php
  10. +52
    -0
      ShopBundle/Model/OrderRefund.php
  11. +21
    -0
      ShopBundle/Repository/OrderRefundRepository.php
  12. +6
    -0
      ShopBundle/Services/Utils.php

+ 7
- 0
ShopBundle/Context/OrderPayoffInterface.php View File

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

namespace Lc\ShopBundle\Context;

interface OrderPayoffInterface
{
}

+ 7
- 0
ShopBundle/Context/OrderProductRefundInterface.php View File

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

namespace Lc\ShopBundle\Context;

interface OrderProductRefundInterface
{
}

+ 7
- 0
ShopBundle/Context/OrderRefundInterface.php View File

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

namespace Lc\ShopBundle\Context;

interface OrderRefundInterface
{
}

+ 0
- 13
ShopBundle/Model/AbstractEntity.php View File

@@ -11,7 +11,6 @@ use Lc\ShopBundle\Context\UserInterface;
*/
abstract class AbstractEntity
{
protected $errors;

/**
* @ORM\Column(type="datetime")
@@ -40,18 +39,6 @@ abstract class AbstractEntity
protected $updatedBy;


public function addError($message, $domain = 'lcshop', $params = []){
$this->errors[] = array(
'message'=> $message,
'domain'=> $domain,
'params'=>$params
);
return $this->errors;
}
public function getErrors(){
return $this->errors;
}

public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;

+ 23
- 0
ShopBundle/Model/Document.php View File

@@ -75,6 +75,11 @@ abstract class Document extends AbstractDocumentEntity implements FilterMerchant
*/
protected $orderShops;

/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"})
*/
protected $orderRefund;

public function __construct()
{
$this->orderShops = new ArrayCollection();
@@ -243,4 +248,22 @@ abstract class Document extends AbstractDocumentEntity implements FilterMerchant

return $this;
}


public function getOrderRefund(): ?OrderRefund
{
return $this->orderRefund;
}

public function setOrderRefund(OrderRefund $orderRefund): self
{
$this->orderRefund = $orderRefund;

// set the owning side of the relation if necessary
if ($orderRefund->getDocument() !== $this) {
$orderRefund->setDocument($this);
}

return $this;
}
}

+ 3
- 107
ShopBundle/Model/OrderPayment.php View File

@@ -4,118 +4,14 @@ namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\OrderPayoffInterface;
use Lc\ShopBundle\Context\ReductionInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderPayment extends AbstractEntity
abstract class OrderPayment extends AbstractEntity implements OrderPayoffInterface
{
const TYPE_CREDIT_CARD = 'cb' ;
const TYPE_CHEQUE = 'cheque' ;
const TYPE_CREDIT = 'credit' ;
use OrderPayoffTrait;

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderPayments")
* @ORM\JoinColumn(nullable=false)
*/
protected $orderShop;

/**
* @ORM\Column(type="string", length=255)
*/
protected $type;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $reference;

/**
* @ORM\Column(type="datetime")
*/
protected $paidAt;

/**
* @ORM\Column(type="float")
*/
protected $amount;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $comment;


public function __toString()
{
return $this->amount. '€ par '.$this->type.' le '.$this->getPaidAt()->format('d-m-Y');
}

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

public function setOrderShop(?OrderShop $orderShop): self
{
$this->orderShop = $orderShop;

return $this;
}

public function setType(string $type): self
{
$this->type = $type;

return $this;
}

public function getReference(): ?string
{
return $this->reference;
}

public function setReference(?string $reference): self
{
$this->reference = $reference;

return $this;
}

public function getPaidAt(): ?\DateTimeInterface
{
return $this->paidAt;
}

public function setPaidAt(\DateTimeInterface $paidAt): self
{
$this->paidAt = $paidAt;

return $this;
}

public function getAmount(): ?float
{
return $this->amount;
}

public function setAmount(float $amount): self
{
$this->amount = $amount;

return $this;
}

public function getComment(): ?string
{
return $this->comment;
}

public function setComment(?string $comment): self
{
$this->comment = $comment;

return $this;
}
}

+ 147
- 0
ShopBundle/Model/OrderPayoffTrait.php View File

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\ReductionInterface;

/**
* @ORM\MappedSuperclass()
*/
trait OrderPayoffTrait
{

/**
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\OrderShopInterface", inversedBy="orderPayments")
* @ORM\JoinColumn(nullable=false)
*/
protected $orderShop;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $meanPayment;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $reference;

/**
* @ORM\Column(type="datetime", nullable=true)
*/
protected $paidAt;

/**
* @ORM\Column(type="float")
*/
protected $amount;

/**
* @ORM\Column(type="text", nullable=true)
*/
protected $comment;

/**
* @ORM\Column(type="boolean")
*/
protected $editable;

public function __toString()
{
return $this->amount. '€ par '.$this->type.' le '.$this->getPaidAt()->format('d-m-Y');
}

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

public function setOrderShop(?OrderShop $orderShop): self
{
$this->orderShop = $orderShop;

return $this;
}

public function setMeanPayment(?string $meanPayment): self
{
$this->meanPayment = $meanPayment;

return $this;
}

public function getMeanPayment(?string $meanPayment): self
{
$this->meanPayment = $meanPayment;

return $this;
}


public function getReference(): ?string
{
return $this->reference;
}

public function setReference(?string $reference): self
{
$this->reference = $reference;

return $this;
}

public function getPaidAt(): ?\DateTimeInterface
{
return $this->paidAt;
}

public function setPaidAt(?\DateTimeInterface $paidAt): self
{
$this->paidAt = $paidAt;

return $this;
}

public function getAmount(): ?float
{
return $this->amount;
}

public function setAmount(float $amount): self
{
$this->amount = $amount;

return $this;
}

public function getComment(): ?string
{
return $this->comment;
}

public function setComment(?string $comment): self
{
$this->comment = $comment;

return $this;
}

public function setEditable(bool $editable): self
{
$this->editable = $editable;

return $this;
}

public function getEditable(): ?bool
{
return $this->editable;
}

public function isEditable(): ?bool
{
return $this->editable;
}
}

+ 21
- 0
ShopBundle/Model/OrderProduct.php View File

@@ -44,6 +44,11 @@ abstract class OrderProduct implements PriceInterface
*/
protected $orderProductReductionCatalog;

/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderProductRefundInterface", mappedBy="orderProduct", cascade={"persist", "remove"})
*/
protected $orderProductRefund;

public function __toString()
{
if($this->getTitle()) {
@@ -177,5 +182,21 @@ abstract class OrderProduct implements PriceInterface

return $this;
}
public function getOrderProductRefund(): ?OrderProductRefund
{
return $this->orderProductRefund;
}

public function setOrderProductRefund(OrderProductRefund $orderProductRefund): self
{
$this->orderProductRefund = $orderProductRefund;

// set the owning side of the relation if necessary
if ($orderProductRefund->getOrderProduct() !== $this) {
$orderProductRefund->setOrderProduct($this);
}

return $this;
}

}

+ 87
- 0
ShopBundle/Model/OrderProductRefund.php View File

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;


/**
* @ORM\MappedSuperclass()
*/
abstract class OrderProductRefund
{
/**
* @ORM\Column(type="integer")
*/
protected $quantityRefund;

/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
protected $title;

/**
* @ORM\Column(type="float")
*/
protected $price;

/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderProductInterface", inversedBy="orderProductRefund", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
protected $orderProduct;

public function getQuantityRefund(): ?int
{
return $this->quantityRefund;
}

public function setQuantityOrder(int $quantityRefund): self
{
$this->quantityRefund = $quantityRefund;

return $this;
}

public function getPrice(): ?float
{
return $this->getPrice() ;
}

public function setPrice(?float $price): self
{
$this->price = $price;

return $this;
}

public function getTitleInherited(): ?string
{
return $this->title;
}

public function getTitle(): ?string
{
return $this->title;
}

public function setTitle(string $title): self
{
$this->title = $title;

return $this;
}

public function getOrderProduct(): ?OrderProduct
{
return $this->orderProduct;
}

public function setOrderProduct(OrderProduct $orderProduct): self
{
$this->orderProduct = $orderProduct;

return $this;
}
}


+ 52
- 0
ShopBundle/Model/OrderRefund.php View File

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

namespace Lc\ShopBundle\Model;

use Doctrine\ORM\Mapping as ORM;
use Lc\ShopBundle\Context\OrderPaymentInterface;
use Lc\ShopBundle\Context\OrderPayoffInterface;
use Lc\ShopBundle\Context\ReductionInterface;

/**
* @ORM\MappedSuperclass()
*/
abstract class OrderRefund extends AbstractEntity implements OrderPayoffInterface
{
use OrderPayoffTrait;

/**
* @ORM\Column(type="float", nullable=true)
*/
protected $deliveryRefundAmount;

/**
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\DocumentInterface", inversedBy="orderRefund", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
protected $document;

public function getDeliveryRefundAmount(): ?float
{
return $this->deliveryRefundAmount;
}

public function setDeliveryRefundAmount(?float $deliveryRefundAmount): self
{
$this->deliveryRefundAmount = $deliveryRefundAmount;

return $this;
}

public function getDocument(): ?Document
{
return $this->document;
}

public function setDocument(Document $document): self
{
$this->document = $document;

return $this;
}
}


+ 21
- 0
ShopBundle/Repository/OrderRefundRepository.php View File

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

namespace Lc\ShopBundle\Repository;

use Lc\ShopBundle\Context\DefaultRepositoryInterface;
use Lc\ShopBundle\Context\OrderRefundInterface;

/**
* @method OrderRefundInterface|null find($id, $lockMode = null, $lockVersion = null)
* @method OrderRefundInterface|null findOneBy(array $criteria, array $orderBy = null)
* @method OrderRefundInterface[] findAll()
* @method OrderRefundInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/
class OrderRefundRepository extends BaseRepository implements DefaultRepositoryInterface
{
public function getInterfaceClass()
{
return OrderRefundInterface::class;
}

}

+ 6
- 0
ShopBundle/Services/Utils.php View File

@@ -24,6 +24,12 @@ class Utils
protected $session;
protected $translator;

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' ;

public function __construct(EntityManagerInterface $em, ParameterBagInterface $parameterBag, SessionInterface $session, TranslatorInterface $translator)
{
$this->em = $em ;

Loading…
Cancel
Save