<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface OrderPayoffInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface OrderProductRefundInterface | |||||
{ | |||||
} |
<?php | |||||
namespace Lc\ShopBundle\Context; | |||||
interface OrderRefundInterface | |||||
{ | |||||
} |
*/ | */ | ||||
abstract class AbstractEntity | abstract class AbstractEntity | ||||
{ | { | ||||
protected $errors; | |||||
/** | /** | ||||
* @ORM\Column(type="datetime") | * @ORM\Column(type="datetime") | ||||
protected $updatedBy; | 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 | public function getCreatedAt(): ?\DateTimeInterface | ||||
{ | { | ||||
return $this->createdAt; | return $this->createdAt; |
*/ | */ | ||||
protected $orderShops; | protected $orderShops; | ||||
/** | |||||
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderRefundInterface", mappedBy="document", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $orderRefund; | |||||
public function __construct() | public function __construct() | ||||
{ | { | ||||
$this->orderShops = new ArrayCollection(); | $this->orderShops = new ArrayCollection(); | ||||
return $this; | 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; | |||||
} | |||||
} | } |
use Doctrine\ORM\Mapping as ORM; | use Doctrine\ORM\Mapping as ORM; | ||||
use Lc\ShopBundle\Context\OrderPaymentInterface; | use Lc\ShopBundle\Context\OrderPaymentInterface; | ||||
use Lc\ShopBundle\Context\OrderPayoffInterface; | |||||
use Lc\ShopBundle\Context\ReductionInterface; | use Lc\ShopBundle\Context\ReductionInterface; | ||||
/** | /** | ||||
* @ORM\MappedSuperclass() | * @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; | |||||
} | |||||
} | } |
<?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; | |||||
} | |||||
} |
*/ | */ | ||||
protected $orderProductReductionCatalog; | protected $orderProductReductionCatalog; | ||||
/** | |||||
* @ORM\OneToOne(targetEntity="Lc\ShopBundle\Context\OrderProductRefundInterface", mappedBy="orderProduct", cascade={"persist", "remove"}) | |||||
*/ | |||||
protected $orderProductRefund; | |||||
public function __toString() | public function __toString() | ||||
{ | { | ||||
if($this->getTitle()) { | if($this->getTitle()) { | ||||
return $this; | 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; | |||||
} | |||||
} | } |
<?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; | |||||
} | |||||
} | |||||
<?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; | |||||
} | |||||
} | |||||
<?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; | |||||
} | |||||
} |
protected $session; | protected $session; | ||||
protected $translator; | 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) | public function __construct(EntityManagerInterface $em, ParameterBagInterface $parameterBag, SessionInterface $session, TranslatorInterface $translator) | ||||
{ | { | ||||
$this->em = $em ; | $this->em = $em ; |