選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

65 行
1.6KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Repository\File;
  3. use App\Entity\Address\Address;
  4. use Lc\CaracoleBundle\Repository\MerchantStoreTrait;
  5. use Lc\CaracoleBundle\Repository\SectionStoreTrait;
  6. use Lc\SovBundle\Repository\AbstractStore;
  7. use Lc\SovBundle\Repository\RepositoryQueryInterface;
  8. class DocumentStore extends AbstractStore
  9. {
  10. use SectionStoreTrait;
  11. protected DocumentRepositoryQuery $query;
  12. public function __construct(DocumentRepositoryQuery $query)
  13. {
  14. $this->query = $query;
  15. }
  16. public function orderByDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  17. {
  18. $query->orderBy('id');
  19. return $query;
  20. }
  21. public function filtersDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  22. {
  23. $query->filterIsOnlineAndOffline();
  24. $query->filterBySection($this->section);
  25. return $query;
  26. }
  27. public function relationsDefault(RepositoryQueryInterface $query): RepositoryQueryInterface
  28. {
  29. return $query;
  30. }
  31. public function getOneLatestByType(string $documentType, $query = null)
  32. {
  33. // @TODO : à écrire
  34. }
  35. // findLastInvoice
  36. public function getOneLastInvoice($query = null)
  37. {
  38. $query = $this->createDefaultQuery($query);
  39. $query
  40. ->orderBy('createdAt', 'DESC');
  41. return $query->findOne();
  42. }
  43. public function getByBuyerAddress(Address $buyerAddress, $query = null)
  44. {
  45. $query = $this->createDefaultQuery($query);
  46. $query->filterByBuyerAddress($buyerAddress);
  47. return $query->find();
  48. }
  49. }