No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

CreditHistoryModel.php 5.3KB

hace 3 años
hace 3 años
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Credit;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Lc\CaracoleBundle\Doctrine\Extension\PayoffTrait;
  5. use Lc\CaracoleBundle\Model\Order\OrderPaymentInterface;
  6. use Lc\CaracoleBundle\Model\Order\OrderRefundInterface;
  7. use Lc\CaracoleBundle\Doctrine\Extension\PayoffInterface;
  8. use Lc\CaracoleBundle\Model\User\UserMerchantInterface;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  11. /**
  12. * @ORM\MappedSuperclass()
  13. */
  14. abstract class CreditHistoryModel extends AbstractLightEntity implements PayoffInterface
  15. {
  16. use PayoffTrait;
  17. const TYPE_CREDIT = 'credit';
  18. const TYPE_DEBIT = 'debit';
  19. const MEAN_PAYMENT_CREDIT_CARD = 'cb';
  20. const MEAN_PAYMENT_CHEQUE = 'cheque';
  21. const MEAN_PAYMENT_CREDIT = 'credit';
  22. const MEAN_PAYMENT_TRANSFER = 'transfer';
  23. const MEAN_PAYMENT_CASH = 'cash';
  24. /**
  25. * @ORM\Column(type="float", nullable=true)
  26. */
  27. protected $amount;
  28. /**
  29. * @ORM\Column(type="string", length=31)
  30. */
  31. protected $type;
  32. /**
  33. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\User\UserMerchantInterface", inversedBy="creditHistories")
  34. * @ORM\JoinColumn(nullable=false)
  35. */
  36. protected $userMerchant;
  37. /**
  38. * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderPaymentInterface", cascade={"persist", "remove"})
  39. */
  40. protected $orderPayment;
  41. /**
  42. * @ORM\OneToOne(targetEntity="Lc\CaracoleBundle\Model\Order\OrderRefundInterface", cascade={"persist", "remove"})
  43. */
  44. protected $orderRefund;
  45. /**
  46. * @Gedmo\Blameable(on="create")
  47. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
  48. * @ORM\JoinColumn(nullable=true)
  49. */
  50. protected $createdBy;
  51. /**
  52. * @Gedmo\Blameable(on="update")
  53. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\User\UserInterface")
  54. * @ORM\JoinColumn(nullable=true)
  55. */
  56. protected $updatedBy;
  57. public function __toString(){
  58. //Todo a écrire
  59. return $this->getType();
  60. }
  61. public function getAmount(): ?float
  62. {
  63. return $this->amount;
  64. }
  65. public function setAmount(?float $amount): self
  66. {
  67. $this->amount = $amount;
  68. return $this;
  69. }
  70. public function getAmountInherited(): float
  71. {
  72. if ($this->getOrderPayment() !== null) {
  73. return $this->getOrderPayment()->getAmount();
  74. } else {
  75. if ($this->getOrderRefund() !== null) {
  76. return $this->getOrderRefund()->getAmount();
  77. } else {
  78. return $this->getAmount();
  79. }
  80. }
  81. }
  82. public function getMeanPaymentInherited(): string
  83. {
  84. if ($this->getOrderPayment() !== null) {
  85. return $this->getOrderPayment()->getMeanPayment();
  86. } else {
  87. if ($this->getOrderRefund() !== null) {
  88. return $this->getOrderRefund()->getMeanPayment();
  89. } else {
  90. return $this->getMeanPayment();
  91. }
  92. }
  93. }
  94. public function getPaidAtInherited(): ?\DateTimeInterface
  95. {
  96. if ($this->getOrderPayment() !== null) {
  97. return $this->getOrderPayment()->getPaidAt();
  98. } else {
  99. if ($this->getOrderRefund() !== null) {
  100. return $this->getOrderRefund()->getPaidAt();
  101. } else {
  102. return $this->getPaidAt();
  103. }
  104. }
  105. }
  106. public function getReferenceInherited(): ?string
  107. {
  108. if ($this->getOrderPayment() !== null) {
  109. return $this->getOrderPayment()->getReference();
  110. } else {
  111. if ($this->getOrderRefund() !== null) {
  112. return $this->getOrderRefund()->getReference();
  113. } else {
  114. return $this->getReference();
  115. }
  116. }
  117. }
  118. public function getCommentInherited(): ?string
  119. {
  120. if ($this->getOrderPayment() !== null) {
  121. return $this->getOrderPayment()->getComment();
  122. } else {
  123. if ($this->getOrderRefund() !== null) {
  124. return $this->getOrderRefund()->getComment();
  125. } else {
  126. return $this->getComment();
  127. }
  128. }
  129. }
  130. public function getMeanPaymentInheritedLabel(): string
  131. {
  132. return 'field.default.meanPaymentOptions.' . $this->getMeanPaymentInherited();
  133. }
  134. public function getType(): ?string
  135. {
  136. return $this->type;
  137. }
  138. public function setType(string $type): self
  139. {
  140. $this->type = $type;
  141. return $this;
  142. }
  143. public function getUserMerchant(): ?UserMerchantInterface
  144. {
  145. return $this->userMerchant;
  146. }
  147. public function setUserMerchant(?UserMerchantInterface $userMerchant): self
  148. {
  149. $this->userMerchant = $userMerchant;
  150. return $this;
  151. }
  152. public function getOrderPayment(): ?OrderPaymentInterface
  153. {
  154. return $this->orderPayment;
  155. }
  156. public function setOrderPayment(?OrderPaymentInterface $orderPayment): self
  157. {
  158. $this->orderPayment = $orderPayment;
  159. return $this;
  160. }
  161. public function getOrderRefund(): ?OrderRefundInterface
  162. {
  163. return $this->orderRefund;
  164. }
  165. public function setOrderRefund(?OrderRefundInterface $orderRefund): self
  166. {
  167. $this->orderRefund = $orderRefund;
  168. return $this;
  169. }
  170. }