1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Repository; |
4
|
|
|
|
5
|
|
|
use ControleOnline\Entity\Order; |
6
|
|
|
use ControleOnline\Entity\People; |
|
|
|
|
7
|
|
|
use ControleOnline\Service\PeopleService; |
|
|
|
|
8
|
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
|
|
|
|
9
|
|
|
use Doctrine\Persistence\ManagerRegistry; |
|
|
|
|
10
|
|
|
use Doctrine\DBAL\DBALException; |
|
|
|
|
11
|
|
|
use Doctrine\ORM\Query\ResultSetMapping; |
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @method Order|null find($id, $lockMode = null, $lockVersion = null) |
15
|
|
|
* @method Order|null findOneBy(array $criteria, array $orderBy = null) |
16
|
|
|
* @method Order[] findAll() |
17
|
|
|
* @method Order[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
18
|
|
|
*/ |
19
|
|
|
class OrderRepository extends ServiceEntityRepository |
20
|
|
|
{ |
21
|
|
|
public function __construct( |
22
|
|
|
private PeopleService $peopleService, |
23
|
|
|
|
24
|
|
|
ManagerRegistry $registry |
25
|
|
|
) { |
26
|
|
|
parent::__construct($registry, Order::class); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
public function getPurchasingSuggestion(?People $company): array |
31
|
|
|
{ |
32
|
|
|
$qb = $this->createQueryBuilder('p') |
33
|
|
|
->select([ |
34
|
|
|
'pe.id AS company_id', |
35
|
|
|
'pe.name AS company_name', |
36
|
|
|
'pe.alias AS company_alias', |
37
|
|
|
'p.id AS product_id', |
38
|
|
|
'p.sku AS sku', |
39
|
|
|
'p.product AS product_name', |
40
|
|
|
'p.description AS description', |
41
|
|
|
'p.type AS type', |
42
|
|
|
'SUM(pi.available + pi.ordered + pi.transit - pi.sales) AS stock', |
43
|
|
|
'SUM(pi.minimum) AS minimum', |
44
|
|
|
'GREATEST(0, SUM(pi.available + pi.ordered + pi.transit - pi.minimum - pi.sales) * -1) AS needed' |
45
|
|
|
]) |
46
|
|
|
->join('p.company', 'pe') |
47
|
|
|
->join('ControleOnline\Entity\ProductInventory', 'pi', 'WITH', 'pi.product = p.id') |
48
|
|
|
->andWhere('p.type NOT IN (:excludedTypes)') |
49
|
|
|
->andWhere('pe IN (:companies)') |
50
|
|
|
->groupBy('p.id, p.product, p.description, p.sku, pe.id, pe.name, pe.alias') |
51
|
|
|
->having('needed > 0') |
52
|
|
|
->setParameter('excludedTypes', ['custom', 'component']) |
53
|
|
|
->setParameter( |
54
|
|
|
'companies', |
55
|
|
|
$this->peopleService->getMyCompanies() |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
if ($company) |
59
|
|
|
$qb->andWhere('pe = :company')->setParameter('company', $company); |
60
|
|
|
|
61
|
|
|
return $qb->getQuery()->getResult(); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths