src/Entity/DetalleOperacion.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Enum\TipoOperacionEnum;
  4. use DateTime;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Symfony\Component\HttpFoundation\File\File;
  8. use Symfony\Component\Uid\Uuid;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11. * @ORM\Entity(repositoryClass="App\Repository\DetalleOperacionRepository")
  12. * @ORM\Table(name="detalle_operacion", schema="perseo")
  13. * @ORM\InheritanceType("SINGLE_TABLE")
  14. * @ORM\DiscriminatorColumn(name="type", type="string")
  15. * @ORM\DiscriminatorMap({
  16. * "operacion":"App\Entity\DetalleOperacion",
  17. * "compra":"App\Entity\DetalleCompra",
  18. * "venta":"App\Entity\DetalleVenta"
  19. * })
  20. * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  21. * @Vich\Uploadable
  22. */
  23. class DetalleOperacion
  24. {
  25. /**
  26. * @ORM\Id
  27. * @ORM\Column(type="uuid", unique=true)
  28. * @ORM\GeneratedValue(strategy="CUSTOM")
  29. * @ORM\CustomIdGenerator(class="doctrine.uuid_generator")
  30. */
  31. protected $id;
  32. /**
  33. * @ORM\Column(type="float", nullable=true, name="precio_coste", options={"default":"0.0","unsigned":true})
  34. */
  35. protected $precioCoste;
  36. /**
  37. * @ORM\Column(type="float", nullable=true, precision=2, name="precio_promocion", options={"default":"0.00","unsigned":true})
  38. */
  39. protected $precioPromocion;
  40. /**
  41. * @ORM\Column(type="string", nullable=true, name="reloj_foto")
  42. */
  43. protected $relojFoto;
  44. /**
  45. * @Vich\UploadableField(mapping="reloj", fileNameProperty="relojFoto")
  46. * @var File
  47. */
  48. protected $relojFotoFile;
  49. /**
  50. * @ORM\Column(type="string", nullable=true, name="reloj_modelo1")
  51. */
  52. protected $relojModelo1;
  53. /**
  54. * @ORM\Column(type="string", nullable=true)
  55. */
  56. private $relojModelo2;
  57. /**
  58. * @ORM\Column(type="string", nullable=true, name="reloj_ref1")
  59. */
  60. protected $relojRef1;
  61. /**
  62. * @ORM\Column(type="string", nullable=true)
  63. */
  64. private $relojRef2;
  65. /**
  66. * @ORM\Column(type="string", nullable=true, name="reloj_serie")
  67. */
  68. protected $relojSerie;
  69. /**
  70. * @ORM\Column(
  71. * type="datetime",
  72. * nullable=true,
  73. * name="reloj_fecha",
  74. * options={"comment":"Fecha comprado por primera vez"}
  75. * )
  76. */
  77. protected $relojFecha;
  78. /**
  79. * @ORM\Column(type="boolean", nullable=false, name="reloj_caja", options={"default":0})
  80. */
  81. protected $relojCaja;
  82. /**
  83. * @ORM\Column(type="boolean", nullable=false, name="reloj_papeles", options={"default":0})
  84. */
  85. protected $relojPapeles;
  86. /**
  87. * @ORM\Column(
  88. * type="string",
  89. * length=4,
  90. * nullable=true,
  91. * name="reloj_regimen",
  92. * options={"comment":"Valores a tomar REBU รณ IVA, por defecto REBU"}
  93. * )
  94. */
  95. protected $relojRegimen;
  96. /**
  97. * @ORM\Column(type="text", nullable=true)
  98. */
  99. private $comentario;
  100. /**
  101. * @ORM\Column(type="datetime", nullable=true, name="deleted_at")
  102. */
  103. protected $deletedAt;
  104. /**
  105. * @ORM\Column(type="datetime", nullable=false, name="updated_at", options={"default":"2022-01-01 00:00:00"})
  106. * @Gedmo\Timestampable(on="update")
  107. */
  108. protected $updatedAt;
  109. /**
  110. * @ORM\Column(type="datetime", nullable=false, name="created_at", options={"default":"2022-01-01 00:00:00"})
  111. * @Gedmo\Timestampable(on="create")
  112. */
  113. protected $createdAt;
  114. /**
  115. * @ORM\OneToOne(targetEntity=\App\Entity\ActividadAbstract::class, mappedBy="detalleOperacion")
  116. */
  117. private $actividad;
  118. /**
  119. * @ORM\ManyToOne(targetEntity="App\Entity\EstadoAspecto", inversedBy="detalleCompras")
  120. * @ORM\JoinColumn(name="reloj_aspecto_id", referencedColumnName="id")
  121. */
  122. protected $relojAspecto;
  123. /**
  124. * @ORM\ManyToOne(targetEntity="App\Entity\Marca", inversedBy="detalleCompras")
  125. * @ORM\JoinColumn(name="reloj_marca_id", referencedColumnName="id")
  126. */
  127. protected $relojMarca;
  128. protected $relojFechaStr;
  129. public function __construct()
  130. {
  131. $this->relojCaja = false;
  132. $this->relojPapeles = false;
  133. }
  134. public function getId(): ?Uuid
  135. {
  136. return $this->id;
  137. }
  138. public function getPrecioCoste(): ?float
  139. {
  140. return $this->precioCoste;
  141. }
  142. public function setPrecioCoste(?float $precioCoste): self
  143. {
  144. $this->precioCoste = $precioCoste;
  145. return $this;
  146. }
  147. public function getRelojFoto(): ?string
  148. {
  149. return $this->relojFoto;
  150. }
  151. public function setRelojFoto(?string $relojFoto): self
  152. {
  153. $this->relojFoto = $relojFoto;
  154. return $this;
  155. }
  156. public function getRelojFotoFile(): ?File
  157. {
  158. return $this->relojFotoFile;
  159. }
  160. public function setRelojFotoFile(?File $relojFotoFile): self
  161. {
  162. $this->relojFotoFile = $relojFotoFile;
  163. if ($relojFotoFile) {
  164. // if 'updatedAt' is not defined in your entity, use another property
  165. $this->setUpdatedAt(new DateTime('now'));
  166. }
  167. return $this;
  168. }
  169. public function getRelojModelo1(): ?string
  170. {
  171. return $this->relojModelo1;
  172. }
  173. public function setRelojModelo1(?string $relojModelo1): self
  174. {
  175. $this->relojModelo1 = $relojModelo1;
  176. return $this;
  177. }
  178. public function getRelojRef1(): ?string
  179. {
  180. return $this->relojRef1;
  181. }
  182. public function setRelojRef1(?string $relojRef1): self
  183. {
  184. $this->relojRef1 = $relojRef1;
  185. return $this;
  186. }
  187. public function getRelojSerie(): ?string
  188. {
  189. return $this->relojSerie;
  190. }
  191. public function setRelojSerie(?string $relojSerie): self
  192. {
  193. $this->relojSerie = $relojSerie;
  194. return $this;
  195. }
  196. public function getRelojFecha(): ?\DateTimeInterface
  197. {
  198. return $this->relojFecha;
  199. }
  200. public function setRelojFecha(?\DateTimeInterface $relojFecha): self
  201. {
  202. $this->relojFecha = $relojFecha;
  203. return $this;
  204. }
  205. public function isRelojCaja(): ?bool
  206. {
  207. return $this->relojCaja;
  208. }
  209. public function setRelojCaja(bool $relojCaja): self
  210. {
  211. $this->relojCaja = $relojCaja;
  212. return $this;
  213. }
  214. public function isRelojPapeles(): ?bool
  215. {
  216. return $this->relojPapeles;
  217. }
  218. public function setRelojPapeles(bool $relojPapeles): self
  219. {
  220. $this->relojPapeles = $relojPapeles;
  221. return $this;
  222. }
  223. public function getDeletedAt(): ?\DateTimeInterface
  224. {
  225. return $this->deletedAt;
  226. }
  227. public function setDeletedAt(?\DateTimeInterface $deletedAt): self
  228. {
  229. $this->deletedAt = $deletedAt;
  230. return $this;
  231. }
  232. public function getUpdatedAt(): ?\DateTimeInterface
  233. {
  234. return $this->updatedAt;
  235. }
  236. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  237. {
  238. $this->updatedAt = $updatedAt;
  239. return $this;
  240. }
  241. public function getCreatedAt(): ?\DateTimeInterface
  242. {
  243. return $this->createdAt;
  244. }
  245. public function setCreatedAt(\DateTimeInterface $createdAt): self
  246. {
  247. $this->createdAt = $createdAt;
  248. return $this;
  249. }
  250. public function getRelojMarca(): ?Marca
  251. {
  252. return $this->relojMarca;
  253. }
  254. public function setRelojMarca(?Marca $relojMarca): self
  255. {
  256. $this->relojMarca = $relojMarca;
  257. return $this;
  258. }
  259. public function getRelojAspecto(): ?EstadoAspecto
  260. {
  261. return $this->relojAspecto;
  262. }
  263. public function setRelojAspecto(?EstadoAspecto $relojAspecto): self
  264. {
  265. $this->relojAspecto = $relojAspecto;
  266. return $this;
  267. }
  268. public function getRelojModelo2(): ?string
  269. {
  270. return $this->relojModelo2;
  271. }
  272. public function setRelojModelo2(?string $relojModelo2): self
  273. {
  274. $this->relojModelo2 = $relojModelo2;
  275. return $this;
  276. }
  277. public function getRelojRef2(): ?string
  278. {
  279. return $this->relojRef2;
  280. }
  281. public function setRelojRef2(?string $relojRef2): self
  282. {
  283. $this->relojRef2 = $relojRef2;
  284. return $this;
  285. }
  286. public function getRelojRegimen(): ?string
  287. {
  288. return $this->relojRegimen;
  289. }
  290. public function setRelojRegimen(?string $relojRegimen): self
  291. {
  292. $this->relojRegimen = $relojRegimen;
  293. return $this;
  294. }
  295. public function getComentario(): ?string
  296. {
  297. return $this->comentario;
  298. }
  299. public function setComentario(?string $comentario): self
  300. {
  301. $this->comentario = $comentario;
  302. return $this;
  303. }
  304. public function getPrecioPromocion(): ?float
  305. {
  306. return $this->precioPromocion;
  307. }
  308. public function setPrecioPromocion(?float $precioPromocion): static
  309. {
  310. $this->precioPromocion = $precioPromocion;
  311. return $this;
  312. }
  313. public function getActividad(): ?ActividadAbstract
  314. {
  315. return $this->actividad;
  316. }
  317. public function setActividad(?ActividadAbstract $actividad): static
  318. {
  319. // unset the owning side of the relation if necessary
  320. if ($actividad === null && $this->actividad !== null) {
  321. $this->actividad->setDetalleOperacion(null);
  322. }
  323. // set the owning side of the relation if necessary
  324. if ($actividad !== null && $actividad->getDetalleOperacion() !== $this) {
  325. $actividad->setDetalleOperacion($this);
  326. }
  327. $this->actividad = $actividad;
  328. return $this;
  329. }
  330. public function getType(): ?string
  331. {
  332. $type = null;
  333. if($this instanceof DetalleCompra) $type = TipoOperacionEnum::OPERACION_COMPRA;
  334. if($this instanceof DetalleVenta) $type = TipoOperacionEnum::OPERACION_VENTA;
  335. return $type;
  336. }
  337. public function getOperacion(): ?Operacion
  338. {
  339. $operacion = null;
  340. if($this instanceof DetalleCompra) $operacion = $this->getCompra()->getOperacion();
  341. if($this instanceof DetalleVenta) $operacion = $this->getVenta()->getOperacion();
  342. return $operacion;
  343. }
  344. public function getRelojFechaStr(): ?string
  345. {
  346. return $this->relojFecha?->format("d/m/Y");
  347. }
  348. }