src/Entity/Idempiere/SmSalestemplate.php line 23

Open in your IDE?
  1. <?php
  2. /**
  3. * @author Created by <dmarquez@sumagroups.com>
  4. * @author Modified by: rbellorin <rbellorin@sumagroups.com>
  5. * @since 2026-01-15
  6. *
  7. * @version 2026-01-15
  8. */
  9. namespace App\Entity\Idempiere;
  10. use App\Entity\Order\SmLocalSalestemplate;
  11. use App\Repository\Idempiere\SmSalestemplateRepository;
  12. use DateTime;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. /**
  17. * @ORM\Entity(repositoryClass=SmSalestemplateRepository::class)
  18. * @ORM\Table(name="SM_SalesTemplate")
  19. */
  20. class SmSalestemplate
  21. {
  22. /**
  23. * @ORM\Id
  24. * @ORM\Column(type="integer")
  25. */
  26. private $sm_salestemplate_id;
  27. /**
  28. * @ORM\Column(type="integer")
  29. */
  30. private $ad_client_id;
  31. /**
  32. * @ORM\Column(type="integer")
  33. */
  34. private $ad_org_id;
  35. /**
  36. * @ORM\ManyToOne(targetEntity=AdOrg::class)
  37. * @ORM\JoinColumn(referencedColumnName="ad_org_id", nullable=false)
  38. */
  39. private $ad_org;
  40. /**
  41. * @ORM\Column(type="string", length=1)
  42. */
  43. private $isactive;
  44. /**
  45. * @ORM\Column(type="datetime")
  46. */
  47. private $created;
  48. /**
  49. * @ORM\Column(type="integer")
  50. */
  51. private $createdby;
  52. /**
  53. * @ORM\Column(type="datetime")
  54. */
  55. private $updated;
  56. /**
  57. * @ORM\Column(type="integer")
  58. */
  59. private $updatedby;
  60. /**
  61. * @ORM\Column(type="string", length=30)
  62. */
  63. private $documentno;
  64. /**
  65. * @ORM\Column(type="string", length=255, nullable=true)
  66. */
  67. private $description;
  68. /**
  69. * @ORM\ManyToOne(targetEntity=MPricelist::class)
  70. * @ORM\JoinColumn(referencedColumnName="m_pricelist_id", nullable=false)
  71. */
  72. private $m_pricelist;
  73. /**
  74. * @ORM\Column(type="integer")
  75. */
  76. private $m_pricelist_id;
  77. /**
  78. * @ORM\Column(type="integer", nullable=true)
  79. */
  80. private $m_warehouse_id;
  81. /**
  82. * @ORM\ManyToOne(targetEntity=MWarehouse::class)
  83. * @ORM\JoinColumn(referencedColumnName="m_warehouse_id", nullable=false)
  84. */
  85. private $m_warehouse;
  86. /**
  87. * @ORM\Column(type="string", length=1)
  88. */
  89. private $isapproved;
  90. /**
  91. * @ORM\Column(type="string", length=25)
  92. */
  93. private $daterequired;
  94. /**
  95. * @ORM\Column(type="float")
  96. */
  97. private $totallines;
  98. /**
  99. * @ORM\Column(type="string", length=2)
  100. */
  101. private $docaction;
  102. /**
  103. * @ORM\Column(type="string", length=2)
  104. */
  105. private $docstatus;
  106. /**
  107. * @ORM\Column(type="string", length=1)
  108. */
  109. private $processed;
  110. /**
  111. * @ORM\Column(type="string", length=25)
  112. */
  113. private $datedoc;
  114. /**
  115. * @ORM\ManyToOne(targetEntity=CDoctype::class)
  116. * @ORM\JoinColumn(referencedColumnName="c_doctype_id", nullable=false)
  117. */
  118. private $c_doctype;
  119. /**
  120. * @ORM\Column(type="integer")
  121. */
  122. private $c_doctype_id;
  123. /**
  124. * @ORM\Column(type="string", length=36)
  125. */
  126. private $sm_salestemplate_uu;
  127. /**
  128. * @ORM\Column(type="string", length=1)
  129. */
  130. private $isapproved2;
  131. /**
  132. * @ORM\ManyToOne(targetEntity=CBpartner::class, inversedBy="salestemplate")
  133. * @ORM\JoinColumn(referencedColumnName="c_bpartner_id", nullable=false)
  134. */
  135. private $c_bpartner;
  136. /**
  137. * @ORM\Column(type="integer", nullable=true)
  138. */
  139. private $c_bpartner_id;
  140. /**
  141. * @ORM\ManyToOne(targetEntity=CBpartnerLocation::class)
  142. * @ORM\JoinColumn(referencedColumnName="c_bpartner_location_id", nullable=false)
  143. */
  144. private $c_bpartner_location;
  145. /**
  146. * @ORM\Column(type="integer", nullable=true)
  147. */
  148. private $c_bpartner_location_id;
  149. /**
  150. * @ORM\ManyToOne(targetEntity=AdUser::class)
  151. * @ORM\JoinColumn(name="salesrep_id", referencedColumnName="ad_user_id")
  152. */
  153. private $salesrep;
  154. /**
  155. * @ORM\Column(type="integer")
  156. */
  157. private $salesrep_id;
  158. /**
  159. * @ORM\ManyToOne(targetEntity=SmMarca::class)
  160. * @ORM\JoinColumn(referencedColumnName="sm_marca_id", nullable=false)
  161. */
  162. private $sm_marca;
  163. /**
  164. * @ORM\Column(type="integer")
  165. */
  166. private $sm_marca_id;
  167. /**
  168. * @ORM\Column(type="string", length=1)
  169. */
  170. private $isquatation;
  171. /**
  172. * @ORM\ManyToOne(targetEntity=CPaymentterm::class)
  173. * @ORM\JoinColumn(referencedColumnName="c_paymentterm_id", nullable=false)
  174. */
  175. private $c_paymentterm;
  176. /**
  177. * @ORM\Column(type="integer", nullable=true)
  178. */
  179. private $c_paymentterm_id;
  180. /**
  181. * @ORM\Column(type="string", length=1)
  182. */
  183. private $sm_document_int;
  184. /**
  185. * @ORM\Column(type="string", length=1)
  186. */
  187. private $isapproved3;
  188. /**
  189. * @ORM\Column(type="string", length=1)
  190. */
  191. private $processing;
  192. /**
  193. * @ORM\Column(type="float")
  194. */
  195. private $processedon;
  196. /**
  197. * @ORM\Column(type="integer")
  198. */
  199. private $ad_user_id;
  200. /**
  201. * @ORM\OneToMany(targetEntity=SmSalestemplateline::class, mappedBy="salestemplate", orphanRemoval=true, cascade={"persist"})
  202. */
  203. private $salestemplatelines;
  204. /**
  205. * @ORM\Column(type="integer")
  206. */
  207. private $bill_location_id;
  208. /**
  209. * @ORM\ManyToOne(targetEntity=CBpartnerLocation::class)
  210. * @ORM\JoinColumn(name="bill_location_id", referencedColumnName="c_bpartner_location_id", nullable=false)
  211. */
  212. private $bill_location;
  213. /**
  214. * @ORM\OneToMany(targetEntity=COrder::class, mappedBy="salestemplate")
  215. */
  216. private $orders;
  217. /**
  218. * @ORM\Column(type="string", length=1)
  219. */
  220. private $isfromweb;
  221. public function __construct()
  222. {
  223. $this->salestemplatelines = new ArrayCollection();
  224. $this->orders = new ArrayCollection();
  225. $this->setIsFromweb('Y');
  226. }
  227. /**
  228. * Copiar datos de una plantilla temporal
  229. *
  230. * @param SmLocalSalestemplate $smLocalSalestemplate Plantilla de Ventas Temporal
  231. *
  232. * @return SmSalestemplate Plantilla de Ventas
  233. */
  234. public function copyFromLocal(SmLocalSalestemplate $smLocalSalestemplate): self
  235. {
  236. $date = new DateTime("now");
  237. $this
  238. ->setAdClientId( $smLocalSalestemplate->getAdClientId() )
  239. ->setAdUserId( $smLocalSalestemplate->getCreatedby() )
  240. ->setCreated( $date )
  241. ->setCreatedby( $smLocalSalestemplate->getCreatedby() )
  242. ->setDatedoc( $smLocalSalestemplate->getDatedoc() )
  243. ->setDaterequired( $smLocalSalestemplate->getDaterequired() )
  244. ->setDescription( $smLocalSalestemplate->getDescription() )
  245. ->setIsactive( $smLocalSalestemplate->getIsactive() )
  246. ->setSalesrepId( $smLocalSalestemplate->getSalesrepId() )
  247. ->setSmDocumentInt( $smLocalSalestemplate->getSmDocumentInt() )
  248. ->setSmMarcaId( $smLocalSalestemplate->getSmMarcaId() )
  249. ->setUpdated( $date )
  250. ->setUpdatedby( $smLocalSalestemplate->getCreatedby() )
  251. ->setIsFromweb('Y')
  252. ;
  253. return $this;
  254. }
  255. public function getId(): ?int
  256. {
  257. return $this->getSmSalestemplateId();
  258. }
  259. public function getSmSalestemplateId(): ?int
  260. {
  261. return $this->sm_salestemplate_id;
  262. }
  263. public function setSmSalestemplateId(int $sm_salestemplate_id): self
  264. {
  265. $this->sm_salestemplate_id = $sm_salestemplate_id;
  266. return $this;
  267. }
  268. public function getAdClientId(): ?int
  269. {
  270. return $this->ad_client_id;
  271. }
  272. public function setAdClientId(int $ad_client_id): self
  273. {
  274. $this->ad_client_id = $ad_client_id;
  275. return $this;
  276. }
  277. public function getAdOrgId(): ?int
  278. {
  279. return $this->ad_org_id;
  280. }
  281. public function setAdOrgId(int $ad_org_id): self
  282. {
  283. $this->ad_org_id = $ad_org_id;
  284. return $this;
  285. }
  286. public function getAdOrg(): ?AdOrg
  287. {
  288. return $this->ad_org;
  289. }
  290. public function setAdOrg(?AdOrg $ad_org): self
  291. {
  292. $this->ad_org = $ad_org;
  293. return $this;
  294. }
  295. public function isActive(): ?bool
  296. {
  297. return $this->getIsactive() === "Y";
  298. }
  299. public function getIsactive(): ?string
  300. {
  301. return $this->isactive;
  302. }
  303. public function setIsactive(string $isactive): self
  304. {
  305. $this->isactive = $isactive;
  306. return $this;
  307. }
  308. public function setActive(bool $active): self
  309. {
  310. $this->setIsactive($active ? "Y" : "N");
  311. return $this;
  312. }
  313. public function getCreated(): ?\DateTimeInterface
  314. {
  315. return $this->created;
  316. }
  317. public function setCreated(\DateTimeInterface $created): self
  318. {
  319. $this->created = $created;
  320. return $this;
  321. }
  322. public function getCreatedby(): ?int
  323. {
  324. return $this->createdby;
  325. }
  326. public function setCreatedby(int $createdby): self
  327. {
  328. $this->createdby = $createdby;
  329. return $this;
  330. }
  331. public function getUpdated(): ?\DateTimeInterface
  332. {
  333. return $this->updated;
  334. }
  335. public function setUpdated(\DateTimeInterface $updated): self
  336. {
  337. $this->updated = $updated;
  338. return $this;
  339. }
  340. public function getUpdatedby(): ?int
  341. {
  342. return $this->updatedby;
  343. }
  344. public function setUpdatedby(int $updatedby): self
  345. {
  346. $this->updatedby = $updatedby;
  347. return $this;
  348. }
  349. public function getDocumentno(): ?string
  350. {
  351. return $this->documentno;
  352. }
  353. public function setDocumentno(string $documentno): self
  354. {
  355. $this->documentno = $documentno;
  356. return $this;
  357. }
  358. public function getDescription(): ?string
  359. {
  360. return $this->description;
  361. }
  362. public function setDescription(?string $description): self
  363. {
  364. $this->description = $description;
  365. return $this;
  366. }
  367. public function getMPricelist(): ?MPricelist
  368. {
  369. return $this->m_pricelist;
  370. }
  371. public function setMPricelist(?MPricelist $m_pricelist): self
  372. {
  373. $this->m_pricelist = $m_pricelist;
  374. return $this;
  375. }
  376. public function getMPricelistId(): ?int
  377. {
  378. return $this->m_pricelist_id;
  379. }
  380. public function setMPricelistId(int $m_pricelist_id): self
  381. {
  382. $this->m_pricelist_id = $m_pricelist_id;
  383. return $this;
  384. }
  385. public function getMWarehouseId(): ?int
  386. {
  387. return $this->m_warehouse_id;
  388. }
  389. public function setMWarehouseId(int $m_warehouse_id): self
  390. {
  391. $this->m_warehouse_id = $m_warehouse_id;
  392. return $this;
  393. }
  394. public function getMWarehouse(): ?MWarehouse
  395. {
  396. return $this->m_warehouse;
  397. }
  398. public function setMWarehouse(?MWarehouse $m_warehouse): self
  399. {
  400. $this->m_warehouse = $m_warehouse;
  401. return $this;
  402. }
  403. public function getIsapproved(): ?string
  404. {
  405. return $this->isapproved;
  406. }
  407. public function setIsapproved(string $isapproved): self
  408. {
  409. $this->isapproved = $isapproved;
  410. return $this;
  411. }
  412. public function getDaterequired(): ?string
  413. {
  414. return $this->daterequired;
  415. }
  416. public function setDaterequired(string $daterequired): self
  417. {
  418. $this->daterequired = $daterequired;
  419. return $this;
  420. }
  421. public function getTotallines(): ?float
  422. {
  423. return $this->totallines;
  424. }
  425. public function setTotallines(float $totallines): self
  426. {
  427. $this->totallines = $totallines;
  428. return $this;
  429. }
  430. public function getDocaction(): ?string
  431. {
  432. return $this->docaction;
  433. }
  434. public function setDocaction(string $docaction): self
  435. {
  436. $this->docaction = $docaction;
  437. return $this;
  438. }
  439. public function getDocstatus(): ?string
  440. {
  441. return $this->docstatus;
  442. }
  443. public function setDocstatus(string $docstatus): self
  444. {
  445. $this->docstatus = $docstatus;
  446. return $this;
  447. }
  448. public function getProcessed(): ?string
  449. {
  450. return $this->processed;
  451. }
  452. public function setProcessed(string $processed): self
  453. {
  454. $this->processed = $processed;
  455. return $this;
  456. }
  457. public function getDatedoc(): ?string
  458. {
  459. return $this->datedoc;
  460. }
  461. public function setDatedoc(string $datedoc): self
  462. {
  463. $this->datedoc = $datedoc;
  464. return $this;
  465. }
  466. public function getCDoctype(): ?CDoctype
  467. {
  468. return $this->c_doctype;
  469. }
  470. public function setCDoctype(?CDoctype $c_doctype): self
  471. {
  472. $this->c_doctype = $c_doctype;
  473. return $this;
  474. }
  475. public function getCDoctypeId(): ?int
  476. {
  477. return $this->c_doctype_id;
  478. }
  479. public function setCDoctypeId(int $c_doctype_id): self
  480. {
  481. $this->c_doctype_id = $c_doctype_id;
  482. return $this;
  483. }
  484. public function getSmSalestemplateUu(): ?string
  485. {
  486. return $this->sm_salestemplate_uu;
  487. }
  488. public function setSmSalestemplateUu(string $sm_salestemplate_uu): self
  489. {
  490. $this->sm_salestemplate_uu = $sm_salestemplate_uu;
  491. return $this;
  492. }
  493. public function getIsapproved2(): ?string
  494. {
  495. return $this->isapproved2;
  496. }
  497. public function setIsapproved2(string $isapproved2): self
  498. {
  499. $this->isapproved2 = $isapproved2;
  500. return $this;
  501. }
  502. public function getBpartner(): ?string
  503. {
  504. return $this->getCBpartner() ? $this->getCBpartner()->getName() : null;
  505. }
  506. public function getCBpartner(): ?CBpartner
  507. {
  508. return $this->c_bpartner;
  509. }
  510. public function setCBpartner(?CBpartner $c_bpartner): self
  511. {
  512. $this->c_bpartner = $c_bpartner;
  513. return $this;
  514. }
  515. public function getCBpartnerId(): ?int
  516. {
  517. return $this->c_bpartner_id;
  518. }
  519. public function setCBpartnerId(?int $c_bpartner_id): self
  520. {
  521. $this->c_bpartner_id = $c_bpartner_id;
  522. return $this;
  523. }
  524. public function getCBpartnerLocation(): ?CBpartnerLocation
  525. {
  526. return $this->c_bpartner_location;
  527. }
  528. public function setCBpartnerLocation(?CBpartnerLocation $c_bpartner_location): self
  529. {
  530. $this->c_bpartner_location = $c_bpartner_location;
  531. return $this;
  532. }
  533. public function getCBpartnerLocationId(): ?int
  534. {
  535. return $this->c_bpartner_location_id;
  536. }
  537. public function setCBpartnerLocationId(?int $c_bpartner_location_id): self
  538. {
  539. $this->c_bpartner_location_id = $c_bpartner_location_id;
  540. return $this;
  541. }
  542. public function getSalesrepName(): ?string
  543. {
  544. return $this->getSalesrep() ? $this->getSalesrep()->getName() : null;
  545. }
  546. public function getSalesrep(): ?AdUser
  547. {
  548. return $this->salesrep;
  549. }
  550. public function setSalesrep(?AdUser $salesrep): self
  551. {
  552. $this->salesrep = $salesrep;
  553. return $this;
  554. }
  555. public function getSalesrepId(): ?int
  556. {
  557. return $this->salesrep_id;
  558. }
  559. public function setSalesrepId(int $salesrep_id): self
  560. {
  561. $this->salesrep_id = $salesrep_id;
  562. return $this;
  563. }
  564. public function getSmMarca(): SmMarca
  565. {
  566. return $this->sm_marca;
  567. }
  568. public function getMarca(): string
  569. {
  570. return $this->getSmMarca() ? $this->getSmMarca()->getName() : '';
  571. }
  572. public function setSmMarca(SmMarca $sm_marca): self
  573. {
  574. $this->sm_marca = $sm_marca;
  575. return $this;
  576. }
  577. public function getSmMarcaId(): ?int
  578. {
  579. return $this->sm_marca_id;
  580. }
  581. public function setSmMarcaId(int $sm_marca_id): self
  582. {
  583. $this->sm_marca_id = $sm_marca_id;
  584. return $this;
  585. }
  586. public function getIsquatation(): ?bool
  587. {
  588. return ($this->isquatation === 'Y');
  589. }
  590. public function setIsquatation(string $isquatation): self
  591. {
  592. $this->isquatation = $isquatation;
  593. return $this;
  594. }
  595. public function getCPaymentterm(): ?CPaymentterm
  596. {
  597. return $this->c_paymentterm;
  598. }
  599. public function setCPaymentterm(?CPaymentterm $c_paymentterm): self
  600. {
  601. $this->c_paymentterm = $c_paymentterm;
  602. return $this;
  603. }
  604. public function getCPaymenttermId(): ?int
  605. {
  606. return $this->c_paymentterm_id;
  607. }
  608. public function setCPaymenttermId(?int $c_paymentterm_id): self
  609. {
  610. $this->c_paymentterm_id = $c_paymentterm_id;
  611. return $this;
  612. }
  613. public function isDocumentInt(): ?bool
  614. {
  615. return $this->getSmDocumentInt() === "Y";
  616. }
  617. public function setDocumentInt(bool $isDocumentInt): self
  618. {
  619. $this->setSmDocumentInt($isDocumentInt ? "Y" : "N");
  620. return $this;
  621. }
  622. public function getSmDocumentInt(): ?string
  623. {
  624. return $this->sm_document_int;
  625. }
  626. public function setSmDocumentInt(string $sm_document_int): self
  627. {
  628. $this->sm_document_int = $sm_document_int;
  629. return $this;
  630. }
  631. public function getIsapproved3(): ?string
  632. {
  633. return $this->isapproved3;
  634. }
  635. public function setIsapproved3(string $isapproved3): self
  636. {
  637. $this->isapproved3 = $isapproved3;
  638. return $this;
  639. }
  640. public function getProcessing(): ?string
  641. {
  642. return $this->processing;
  643. }
  644. public function setProcessing(string $processing): self
  645. {
  646. $this->processing = $processing;
  647. return $this;
  648. }
  649. public function getProcessedon(): ?float
  650. {
  651. return $this->processedon;
  652. }
  653. public function setProcessedon(float $processedon): self
  654. {
  655. $this->processedon = $processedon;
  656. return $this;
  657. }
  658. public function getAdUserId(): ?int
  659. {
  660. return $this->ad_user_id;
  661. }
  662. public function setAdUserId(int $ad_user_id): self
  663. {
  664. $this->ad_user_id = $ad_user_id;
  665. return $this;
  666. }
  667. /**
  668. * @return Collection<int, SmSalestemplateline>
  669. */
  670. public function getLines(): Collection
  671. {
  672. return $this->getSalestemplatelines();
  673. }
  674. /**
  675. * @return Collection<int, SmSalestemplateline>
  676. */
  677. public function getSalestemplatelines(): Collection
  678. {
  679. return $this->salestemplatelines;
  680. }
  681. public function addLine(SmSalestemplateline $line): self
  682. {
  683. $this->addSmSalestemplateline($line);
  684. return $this;
  685. }
  686. public function addSmSalestemplateline(SmSalestemplateline $smSalestemplateline): self
  687. {
  688. if (!$this->salestemplatelines->contains($smSalestemplateline)) {
  689. $this->salestemplatelines[] = $smSalestemplateline;
  690. $smSalestemplateline->setSmSalestemplate($this);
  691. $this->setTotallines(
  692. $this->getTotallines() + $smSalestemplateline->getLinenetamt()
  693. );
  694. //
  695. $line = count($this->salestemplatelines) * 10;
  696. $smSalestemplateline->setLine($line);
  697. }
  698. return $this;
  699. }
  700. public function removeLine(SmSalestemplateline $line): self
  701. {
  702. $this->removeSmSalestemplateline($line);
  703. return $this;
  704. }
  705. public function removeSmSalestemplateline(SmSalestemplateline $smSalestemplateline): self
  706. {
  707. if ($this->salestemplatelines->removeElement($smSalestemplateline)) {
  708. // set the owning side to null (unless already changed)
  709. if ($smSalestemplateline->getSmSalestemplate() === $this) {
  710. $smSalestemplateline->setSmSalestemplate(null);
  711. $this->setTotallines(
  712. $this->getTotallines() - $smSalestemplateline->getLinenetamt()
  713. );
  714. }
  715. }
  716. return $this;
  717. }
  718. public function getBillLocationId(): ?int
  719. {
  720. return $this->bill_location_id;
  721. }
  722. public function setBillLocationId(int $bill_location_id): self
  723. {
  724. $this->bill_location_id = $bill_location_id;
  725. return $this;
  726. }
  727. public function getBillLocation(): ?CBpartnerLocation
  728. {
  729. return $this->bill_location;
  730. }
  731. public function setBillLocation(?CBpartnerLocation $bill_location): self
  732. {
  733. $this->bill_location = $bill_location;
  734. return $this;
  735. }
  736. public function getOrder(): ?COrder
  737. {
  738. if ($this->orders->isEmpty())
  739. return null;
  740. $orders = $this->orders->filter(fn(COrder $order) => in_array($order->getDocstatus(), ['CL', 'CO', 'AP']));
  741. if ($orders->isEmpty())
  742. return null;
  743. return $orders->first();
  744. }
  745. /**
  746. * Get the status of the sales
  747. */
  748. public function getOrderStatus(): string
  749. {
  750. return $this->getOrder() ? $this->getOrder()->getDocstatus() : $this->getDocstatus();
  751. }
  752. /**
  753. * Get the status of the sales process
  754. */
  755. public function getProcessStatus(): string
  756. {
  757. return $this->getOrder() ? $this->getOrder()->getProcessStatus() : $this->getDocstatus();
  758. }
  759. /**
  760. * setIsFromWeb
  761. *
  762. * @param string $value
  763. * @return self
  764. */
  765. public function setIsFromweb(string $value) : self {
  766. $this->isfromweb = $value;
  767. return $this;
  768. }
  769. /**
  770. * getIsfromweb
  771. *
  772. * @return string
  773. */
  774. public function getIsfromweb() : string {
  775. return $this->isfromweb;
  776. }
  777. }