src/Entity/Legacy/Estimate.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Legacy;
  3. use ApiPlatform\Core\Annotation\ApiFilter;
  4. use ApiPlatform\Core\Annotation\ApiResource;
  5. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
  6. use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Roothirsch\CoreBundle\UserAware\UserAwareInterface;
  10. use Roothirsch\CoreBundle\UserAware\UserAwareTrait;
  11. use Roothirsch\ShopBundle\API\Filter\EstimateNotEmptyFilter;
  12. /**
  13. * @ORM\Entity
  14. * @ORM\Table(name="legacy_estimate")
  15. * @ApiResource(
  16. * itemOperations={
  17. * "order"={"method"="PUT", "path"="/estimates/{id}/order", "requirements"={"id"=".+"}},
  18. * "get",
  19. * "put",
  20. * "delete"
  21. * },
  22. * collectionOperations={
  23. * "duplicate"={"method"="POST", "path"="/estimates/{id}/duplicate", "requirements"={"id"=".+"}},
  24. * "get",
  25. * "post"
  26. * }
  27. * )
  28. * @ApiFilter(OrderFilter::class, properties={"updated", "created", "reference", "comisson", "netTotal"}, arguments={"orderParameterName"="order"})
  29. * @ApiFilter(SearchFilter::class, properties={"status": "exact"})
  30. * @ApiFilter(EstimateNotEmptyFilter::class)
  31. */
  32. class Estimate implements UserAwareInterface
  33. {
  34. use UserAwareTrait;
  35. /**
  36. * @ORM\Id
  37. * @ORM\GeneratedValue
  38. * @ORM\Column(type="integer")
  39. */
  40. private $id;
  41. /**
  42. * @ORM\Column(type="string", nullable=true)
  43. */
  44. private $status = 'draft';
  45. /**
  46. * @ORM\Column(type="string", nullable=true)
  47. */
  48. private $customer;
  49. /**
  50. * @ORM\Column(type="string", nullable=true)
  51. */
  52. private $reference;
  53. /**
  54. * @ORM\Column(type="string", nullable=true)
  55. */
  56. private $address;
  57. /**
  58. * @ORM\Column(type="string", nullable=true)
  59. */
  60. private $contactPerson;
  61. /**
  62. * @ORM\Column(type="string", nullable=true)
  63. */
  64. private $comission;
  65. /**
  66. * @ORM\Column(type="boolean")
  67. */
  68. private $applyDiscount = true;
  69. /**
  70. * @ORM\Column(type="boolean")
  71. */
  72. private $applyMwst = false;
  73. /**
  74. * @ORM\Column(type="float")
  75. */
  76. private $customerDiscount = 0;
  77. /**
  78. * @ORM\Column(type="json_array")
  79. */
  80. private $items = [];
  81. /**
  82. * @ORM\Column(type="float")
  83. */
  84. private $netTotal = 0;
  85. /**
  86. * @ORM\Column(type="string")
  87. */
  88. private $currency = 'chf';
  89. /**
  90. * @ORM\Column(type="string", nullable=true)
  91. */
  92. private $description;
  93. /**
  94. * @var \DateTime
  95. *
  96. * @Gedmo\Timestampable(on="create")
  97. * @ORM\Column(type="integer")
  98. */
  99. private $created;
  100. /**
  101. * @var \DateTime
  102. *
  103. * @Gedmo\Timestampable(on="update")
  104. * @ORM\Column(type="integer")
  105. */
  106. private $updated;
  107. /**
  108. * @var \DateTime
  109. *
  110. * @ORM\Column(type="datetime", nullable=true)
  111. */
  112. private $orderedAt;
  113. /**
  114. * @ORM\Column(type="string", nullable=true)
  115. */
  116. private $orderNumber;
  117. /**
  118. * @var \DateTime
  119. * @ORM\Column(type="date", nullable=true)
  120. */
  121. private $deliveryDate;
  122. /**
  123. * @var string
  124. * @ORM\Column(type="string", nullable=true)
  125. */
  126. private $deliveryType = 'abholung';
  127. /**
  128. * @ORM\ManyToOne(targetEntity="App\Entity\Company", cascade={"persist"}, fetch="EAGER")
  129. * @ORM\JoinColumn(onDelete="SET NULL")
  130. */
  131. private $distributor;
  132. /**
  133. * @ORM\Column(type="boolean")
  134. */
  135. private $hideAddressInSelector = false;
  136. /**
  137. * @var array
  138. * @ORM\Column(type="json_array")
  139. */
  140. private $files = [];
  141. /**
  142. * @return mixed
  143. */
  144. public function getId()
  145. {
  146. return $this->id;
  147. }
  148. /**
  149. * @param mixed $id
  150. */
  151. public function setId($id)
  152. {
  153. $this->id = $id;
  154. }
  155. /**
  156. * @return mixed
  157. */
  158. public function getStatus()
  159. {
  160. return $this->status;
  161. }
  162. /**
  163. * @param mixed $status
  164. */
  165. public function setStatus($status)
  166. {
  167. $this->status = $status;
  168. }
  169. /**
  170. * @return mixed
  171. */
  172. public function getCustomer()
  173. {
  174. return $this->customer;
  175. }
  176. /**
  177. * @param mixed $customer
  178. */
  179. public function setCustomer($customer)
  180. {
  181. $this->customer = $customer;
  182. }
  183. /**
  184. * @return mixed
  185. */
  186. public function getAddress()
  187. {
  188. return $this->address;
  189. }
  190. /**
  191. * @param mixed $address
  192. */
  193. public function setAddress($address)
  194. {
  195. $this->address = $address;
  196. }
  197. /**
  198. * @return mixed
  199. */
  200. public function getContactPerson()
  201. {
  202. return $this->contactPerson;
  203. }
  204. /**
  205. * @param mixed $contactPerson
  206. */
  207. public function setContactPerson($contactPerson)
  208. {
  209. $this->contactPerson = $contactPerson;
  210. }
  211. /**
  212. * @return mixed
  213. */
  214. public function getComission()
  215. {
  216. return $this->comission;
  217. }
  218. /**
  219. * @param mixed $comission
  220. */
  221. public function setComission($comission)
  222. {
  223. $this->comission = $comission;
  224. }
  225. /**
  226. * @return mixed
  227. */
  228. public function getApplyDiscount()
  229. {
  230. return $this->applyDiscount;
  231. }
  232. /**
  233. * @param mixed $applyDiscount
  234. */
  235. public function setApplyDiscount($applyDiscount)
  236. {
  237. $this->applyDiscount = $applyDiscount;
  238. }
  239. /**
  240. * @return mixed
  241. */
  242. public function getCustomerDiscount()
  243. {
  244. return $this->customerDiscount;
  245. }
  246. /**
  247. * @param mixed $customerDiscount
  248. */
  249. public function setCustomerDiscount($customerDiscount)
  250. {
  251. $this->customerDiscount = $customerDiscount;
  252. }
  253. /**
  254. * @return mixed
  255. */
  256. public function getItems()
  257. {
  258. return $this->items;
  259. }
  260. /**
  261. * @param mixed $items
  262. */
  263. public function setItems($items)
  264. {
  265. $this->items = $items;
  266. }
  267. /**
  268. * @return mixed
  269. */
  270. public function getReference()
  271. {
  272. return $this->reference;
  273. }
  274. /**
  275. * @param mixed $reference
  276. */
  277. public function setReference($reference)
  278. {
  279. $this->reference = $reference;
  280. }
  281. /**
  282. * @return \DateTime
  283. */
  284. public function getCreated()
  285. {
  286. return $this->created;
  287. }
  288. /**
  289. * @param \DateTime $created
  290. */
  291. public function setCreated($created)
  292. {
  293. $this->created = $created;
  294. }
  295. /**
  296. * @return \DateTime
  297. */
  298. public function getUpdated()
  299. {
  300. return $this->updated;
  301. }
  302. /**
  303. * @param \DateTime $updated
  304. */
  305. public function setUpdated($updated)
  306. {
  307. $this->updated = $updated;
  308. }
  309. /**
  310. * @return mixed
  311. */
  312. public function getNetTotal()
  313. {
  314. return $this->netTotal;
  315. }
  316. /**
  317. * @param mixed $netTotal
  318. */
  319. public function setNetTotal($netTotal)
  320. {
  321. $this->netTotal = $netTotal;
  322. }
  323. /**
  324. * @return mixed
  325. */
  326. public function getCurrency()
  327. {
  328. return $this->currency;
  329. }
  330. /**
  331. * @param mixed $currency
  332. */
  333. public function setCurrency($currency)
  334. {
  335. $this->currency = $currency;
  336. }
  337. /**
  338. * @return mixed
  339. */
  340. public function getDescription()
  341. {
  342. return $this->description;
  343. }
  344. /**
  345. * @param mixed $description
  346. */
  347. public function setDescription($description)
  348. {
  349. $this->description = $description;
  350. }
  351. /**
  352. * @return mixed
  353. */
  354. public function getApplyMwst()
  355. {
  356. return $this->applyMwst;
  357. }
  358. /**
  359. * @param mixed $applyMwst
  360. */
  361. public function setApplyMwst($applyMwst)
  362. {
  363. $this->applyMwst = $applyMwst;
  364. }
  365. /**
  366. * @return \DateTime
  367. */
  368. public function getDeliveryDate()
  369. {
  370. return $this->deliveryDate;
  371. }
  372. /**
  373. * @param \DateTime $deliveryDate
  374. */
  375. public function setDeliveryDate($deliveryDate)
  376. {
  377. $this->deliveryDate = $deliveryDate;
  378. }
  379. /**
  380. * @return mixed
  381. */
  382. public function getOrderNumber()
  383. {
  384. return $this->orderNumber;
  385. }
  386. /**
  387. * @param mixed $orderNumber
  388. */
  389. public function setOrderNumber($orderNumber)
  390. {
  391. $this->orderNumber = $orderNumber;
  392. }
  393. /**
  394. * @return mixed
  395. */
  396. public function getDistributor()
  397. {
  398. return $this->distributor;
  399. }
  400. /**
  401. * @param mixed $distributor
  402. */
  403. public function setDistributor($distributor)
  404. {
  405. $this->distributor = $distributor;
  406. }
  407. /**
  408. * @return string
  409. */
  410. public function getDeliveryType()
  411. {
  412. return $this->deliveryType;
  413. }
  414. /**
  415. * @param string $deliveryType
  416. */
  417. public function setDeliveryType($deliveryType)
  418. {
  419. $this->deliveryType = $deliveryType;
  420. }
  421. /**
  422. * @return \DateTime
  423. */
  424. public function getOrderedAt()
  425. {
  426. return $this->orderedAt;
  427. }
  428. /**
  429. * @param \DateTime $orderedAt
  430. */
  431. public function setOrderedAt($orderedAt)
  432. {
  433. $this->orderedAt = $orderedAt;
  434. }
  435. /**
  436. * @return mixed
  437. */
  438. public function getHideAddressInSelector()
  439. {
  440. return $this->hideAddressInSelector;
  441. }
  442. /**
  443. * @param mixed $hideAddressInSelector
  444. */
  445. public function setHideAddressInSelector($hideAddressInSelector)
  446. {
  447. $this->hideAddressInSelector = $hideAddressInSelector;
  448. }
  449. /**
  450. * @return array
  451. */
  452. public function getFiles()
  453. {
  454. return $this->files ?? [];
  455. }
  456. /**
  457. * @param array $files
  458. *
  459. * @return Estimate
  460. */
  461. public function setFiles($files)
  462. {
  463. $this->files = $files;
  464. return $this;
  465. }
  466. public function isEmpty() {
  467. foreach($this->items as $item) {
  468. if (isset($item['state']) && $item['state'] == 'added') {
  469. return false;
  470. }
  471. }
  472. return true;
  473. }
  474. }