@@ -0,0 +1,7 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface OrderPayoffInterface | |||
{ | |||
} |
@@ -0,0 +1,7 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface OrderProductRefundInterface | |||
{ | |||
} |
@@ -0,0 +1,7 @@ | |||
<?php | |||
namespace Lc\ShopBundle\Context; | |||
interface OrderRefundInterface | |||
{ | |||
} |
@@ -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; |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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; | |||
} | |||
} | |||
@@ -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; | |||
} | |||
} | |||
@@ -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; | |||
} | |||
} |
@@ -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 ; |