|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- <?php
-
- namespace Lc\CaracoleBundle\Model\Credit;
-
- use Doctrine\ORM\Mapping as ORM;
- use Lc\CaracoleBundle\Doctrine\Extension\PayoffTrait;
- use Lc\CaracoleBundle\Model\Order\OrderPaymentInterface;
- use Lc\CaracoleBundle\Model\Order\OrderRefundInterface;
- use Lc\CaracoleBundle\Doctrine\Extension\PayoffInterface;
- use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
- use Gedmo\Mapping\Annotation as Gedmo;
- use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
-
- /**
- * @ORM\MappedSuperclass()
- */
- abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffInterface
- {
- 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';
-
-
- /**$merchant
- * @ORM\Column(type="float", nullable=true)
- */
- protected $amount;
-
- /**
- * @ORM\Column(type="string", length=31)
- */
- protected $type;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\User\UserMerchantInterface", inversedBy="creditHistories")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $userMerchant;
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderPaymentInterface", cascade={"persist", "remove"})
- */
- protected $orderPayment;
-
- /**
- * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderRefundInterface", cascade={"persist", "remove"})
- */
- protected $orderRefund;
-
- /**
- * @Gedmo\Blameable(on="create")
- * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
- * @ORM\JoinColumn(nullable=true)
- */
- protected $createdBy;
-
- /**
- * @Gedmo\Blameable(on="update")
- * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
- * @ORM\JoinColumn(nullable=true)
- */
- protected $updatedBy;
-
- public function __toString(){
- //Todo a écrire
- return $this->getType();
- }
-
- public function getAmount(): ?float
- {
- return $this->amount;
- }
-
- public function setAmount(?float $amount): self
- {
- $this->amount = $amount;
-
- return $this;
- }
-
- public function getAmountInherited(): float
- {
- if ($this->getOrderPayment() !== null) {
- return $this->getOrderPayment()->getAmount();
- } else {
- if ($this->getOrderRefund() !== null) {
- return $this->getOrderRefund()->getAmount();
- } else {
- return $this->getAmount();
- }
- }
- }
-
- public function getMeanPaymentInherited(): string
- {
- if ($this->getOrderPayment() !== null) {
- return $this->getOrderPayment()->getMeanPayment();
- } else {
- if ($this->getOrderRefund() !== null) {
- return $this->getOrderRefund()->getMeanPayment();
- } else {
- return $this->getMeanPayment();
- }
- }
- }
-
- public function getPaidAtInherited(): ?\DateTimeInterface
- {
- if ($this->getOrderPayment() !== null) {
- return $this->getOrderPayment()->getPaidAt();
- } else {
- if ($this->getOrderRefund() !== null) {
- return $this->getOrderRefund()->getPaidAt();
- } else {
- return $this->getPaidAt();
- }
- }
- }
-
- public function getReferenceInherited(): ?string
- {
- if ($this->getOrderPayment() !== null) {
- return $this->getOrderPayment()->getReference();
- } else {
- if ($this->getOrderRefund() !== null) {
- return $this->getOrderRefund()->getReference();
- } else {
- return $this->getReference();
- }
- }
- }
-
- public function getCommentInherited(): ?string
- {
- if ($this->getOrderPayment() !== null) {
- return $this->getOrderPayment()->getComment();
- } else {
- if ($this->getOrderRefund() !== null) {
- return $this->getOrderRefund()->getComment();
- } else {
- return $this->getComment();
- }
- }
- }
-
- public function getMeanPaymentInheritedLabel(): string
- {
- return 'field.default.meanPaymentOptions.' . $this->getMeanPaymentInherited();
- }
-
- public function getType(): ?string
- {
- return $this->type;
- }
-
- public function setType(string $type): self
- {
- $this->type = $type;
-
- return $this;
- }
-
- public function getUserMerchant(): ?UserMerchantInterface
- {
- return $this->userMerchant;
- }
-
- public function setUserMerchant(?UserMerchantInterface $userMerchant): self
- {
- $this->userMerchant = $userMerchant;
-
- return $this;
- }
-
- public function getOrderPayment(): ?OrderPaymentInterface
- {
- return $this->orderPayment;
- }
-
- public function setOrderPayment(?OrderPaymentInterface $orderPayment): self
- {
- $this->orderPayment = $orderPayment;
-
- return $this;
- }
-
- public function getOrderRefund(): ?OrderRefundInterface
- {
- return $this->orderRefund;
- }
-
- public function setOrderRefund(?OrderRefundInterface $orderRefund): self
- {
- $this->orderRefund = $orderRefund;
-
- return $this;
- }
- }
|