src/Entity/Idempiere/MPricelist.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Idempiere;
  3. use App\Repository\Idempiere\MPricelistRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity(repositoryClass=MPricelistRepository::class)
  9. * @ORM\Table(name="m_pricelist")
  10. */
  11. class MPricelist
  12. {
  13. /**
  14. * @ORM\Id
  15. * @ORM\Column(type="integer")
  16. */
  17. private $m_pricelist_id;
  18. /**
  19. * @ORM\Column(type="string", length=36)
  20. */
  21. private $m_pricelist_uu;
  22. /**
  23. * @ORM\Column(type="string", length=255)
  24. */
  25. private $name;
  26. /**
  27. * @ORM\Column(type="string", length=1)
  28. */
  29. private $issopricelist;
  30. /**
  31. * @ORM\Column(type="string", length=1)
  32. */
  33. private $isactive;
  34. /**
  35. * @ORM\Column(type="string", length=1)
  36. */
  37. private $isdefault;
  38. /**
  39. * @ORM\Column(type="integer")
  40. */
  41. private $c_currency_id;
  42. /**
  43. * @ORM\Column(type="integer")
  44. */
  45. private $priceprecision;
  46. /**
  47. * @ORM\Column(type="integer")
  48. */
  49. private $ad_org_id;
  50. /**
  51. * @ORM\OneToMany(targetEntity=MPricelistVersion::class, mappedBy="m_pricelist")
  52. */
  53. private $m_pricelist_versions;
  54. /**
  55. * @ORM\Column(type="string", length=1)
  56. */
  57. private $isfavourite;
  58. /**
  59. * @ORM\Column(type="string", length=1)
  60. */
  61. private $isonline;
  62. /**
  63. * @ORM\Column(type="string", length=1)
  64. */
  65. private $isinitialcost;
  66. public function __construct()
  67. {
  68. $this->m_pricelist_versions = new ArrayCollection();
  69. }
  70. public function getId(): ?int
  71. {
  72. return $this->getMPricelistId();
  73. }
  74. public function getMPricelistId(): ?int
  75. {
  76. return $this->m_pricelist_id;
  77. }
  78. public function setMPricelistId(int $m_pricelist_id): self
  79. {
  80. $this->m_pricelist_id = $m_pricelist_id;
  81. return $this;
  82. }
  83. public function getMPricelistUu(): ?string
  84. {
  85. return $this->m_pricelist_uu;
  86. }
  87. public function setMPricelistUu(string $m_pricelist_uu): self
  88. {
  89. $this->m_pricelist_uu = $m_pricelist_uu;
  90. return $this;
  91. }
  92. public function getName(): ?string
  93. {
  94. return $this->name;
  95. }
  96. public function setName(string $name): self
  97. {
  98. $this->name = $name;
  99. return $this;
  100. }
  101. public function getIssopricelist(): ?string
  102. {
  103. return $this->issopricelist;
  104. }
  105. public function setIssopricelist(string $issopricelist): self
  106. {
  107. $this->issopricelist = $issopricelist;
  108. return $this;
  109. }
  110. public function getIsactive(): ?string
  111. {
  112. return $this->isactive;
  113. }
  114. public function setIsactive(string $isactive): self
  115. {
  116. $this->isactive = $isactive;
  117. return $this;
  118. }
  119. public function getIsdefault(): ?string
  120. {
  121. return $this->isdefault;
  122. }
  123. public function setIsdefault(string $isdefault): self
  124. {
  125. $this->isdefault = $isdefault;
  126. return $this;
  127. }
  128. public function getCCurrencyId(): ?int
  129. {
  130. return $this->c_currency_id;
  131. }
  132. public function setCCurrencyId(int $c_currency_id): self
  133. {
  134. $this->c_currency_id = $c_currency_id;
  135. return $this;
  136. }
  137. public function getPriceprecision(): ?int
  138. {
  139. return $this->priceprecision;
  140. }
  141. public function setPriceprecision(int $priceprecision): self
  142. {
  143. $this->priceprecision = $priceprecision;
  144. return $this;
  145. }
  146. public function getAdOrgId(): ?int
  147. {
  148. return $this->ad_org_id;
  149. }
  150. public function setAdOrgId(int $ad_org_id): self
  151. {
  152. $this->ad_org_id = $ad_org_id;
  153. return $this;
  154. }
  155. /**
  156. * @return Collection|MPricelistVersion[]
  157. */
  158. public function getMPricelistVersions(): Collection
  159. {
  160. return $this->m_pricelist_versions;
  161. }
  162. public function getIsfavourite(): ?string
  163. {
  164. return $this->isfavourite;
  165. }
  166. public function setIsfavourite(string $isfavourite): self
  167. {
  168. $this->isfavourite = $isfavourite;
  169. return $this;
  170. }
  171. public function getIsonline(): ?string
  172. {
  173. return $this->isonline;
  174. }
  175. public function setIsonline(string $isonline): self
  176. {
  177. $this->isonline = $isonline;
  178. return $this;
  179. }
  180. public function getIsinitialcost(): ?string
  181. {
  182. return $this->isinitialcost;
  183. }
  184. public function setIsinitialcost(string $isinitialcost): self
  185. {
  186. $this->isinitialcost = $isinitialcost;
  187. return $this;
  188. }
  189. public function getMPricelistVersionsLast(): int
  190. {
  191. // // return $this->m_pricelist_versions;
  192. // $lasta = end($this->m_pricelist_versions);
  193. // dd($lasta);
  194. // return end($this->m_pricelist_versions->toArray());
  195. $arrayDeColeccion = $this->m_pricelist_versions->toArray();
  196. // Ahora ordena el array por ID de forma descendente
  197. usort($arrayDeColeccion, function ($a, $b) {
  198. return $b->getId() <=> $a->getId();
  199. });
  200. // El primer elemento es el último
  201. $ultimoElemento = reset($arrayDeColeccion);
  202. // Si se encontró un elemento, obtén su ID
  203. if ($ultimoElemento) {
  204. $ultimoId = $ultimoElemento->getId();
  205. }
  206. return $ultimoId;
  207. }
  208. }