1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ControleOnline\Entity; |
4
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
|
6
|
|
|
use Doctrine\Common\Collections\ArrayCollection; |
|
|
|
|
7
|
|
|
use ApiPlatform\Core\Annotation\ApiSubresource; |
|
|
|
|
8
|
|
|
use Symfony\Component\Serializer\Annotation\Groups; |
|
|
|
|
9
|
|
|
use ApiPlatform\Metadata\ApiFilter; |
|
|
|
|
10
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; |
|
|
|
|
11
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\OrderFilter; |
|
|
|
|
12
|
|
|
use ControleOnline\Entity\OrderInvoice; |
13
|
|
|
use stdClass; |
14
|
|
|
use ApiPlatform\Doctrine\Orm\Filter\DateFilter; |
|
|
|
|
15
|
|
|
use ApiPlatform\Metadata\GetCollection; |
|
|
|
|
16
|
|
|
use ApiPlatform\Metadata\Put; |
|
|
|
|
17
|
|
|
use ApiPlatform\Metadata\Post; |
|
|
|
|
18
|
|
|
use ApiPlatform\Metadata\Get; |
|
|
|
|
19
|
|
|
use ApiPlatform\Metadata\ApiResource; |
|
|
|
|
20
|
|
|
use ApiPlatform\Metadata\ApiProperty; |
|
|
|
|
21
|
|
|
use ControleOnline\Controller\CreateNFeAction; |
|
|
|
|
22
|
|
|
use ControleOnline\Controller\DiscoveryCart; |
23
|
|
|
use ControleOnline\Entity\OrderProduct; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Order |
27
|
|
|
* |
28
|
|
|
* @ORM\EntityListeners({ControleOnline\Listener\LogListener::class}) |
29
|
|
|
* @ORM\Table(name="orders", uniqueConstraints={@ORM\UniqueConstraint(name="discount_id", columns={"discount_coupon_id"})}, indexes={@ORM\Index(name="adress_destination_id", columns={"address_destination_id"}), @ORM\Index(name="notified", columns={"notified"}), @ORM\Index(name="delivery_contact_id", columns={"delivery_contact_id"}), @ORM\Index(name="delivery_people_id", columns={"delivery_people_id"}), @ORM\Index(name="status_id", columns={"status_id"}), @ORM\Index(name="order_date", columns={"order_date"}), @ORM\Index(name="provider_id", columns={"provider_id"}), @ORM\Index(name="quote_id", columns={"quote_id", "provider_id"}), @ORM\Index(name="adress_origin_id", columns={"address_origin_id"}), @ORM\Index(name="retrieve_contact_id", columns={"retrieve_contact_id"}), @ORM\Index(name="main_order_id", columns={"main_order_id"}), @ORM\Index(name="retrieve_people_id", columns={"retrieve_people_id"}), @ORM\Index(name="payer_people_id", columns={"payer_people_id"}), @ORM\Index(name="client_id", columns={"client_id"}), @ORM\Index(name="alter_date", columns={"alter_date"}), @ORM\Index(name="IDX_E52FFDEEDB805178", columns={"quote_id"})}) |
30
|
|
|
* @ORM\Entity(repositoryClass="ControleOnline\Repository\OrderRepository") |
31
|
|
|
*/ |
32
|
|
|
|
33
|
|
|
#[ApiResource( |
34
|
|
|
operations: [ |
35
|
|
|
new Get( |
36
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
37
|
|
|
), |
38
|
|
|
new GetCollection( |
39
|
|
|
security: 'is_granted(\'IS_AUTHENTICATED_ANONYMOUSLY\')', |
40
|
|
|
uriTemplate: '/cart', |
41
|
|
|
controller: DiscoveryCart::class |
42
|
|
|
|
43
|
|
|
), |
44
|
|
|
new GetCollection( |
45
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')', |
46
|
|
|
normalizationContext: ['groups' => ['order:read']], |
47
|
|
|
), |
48
|
|
|
new Post( |
49
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or is_granted(\'ROLE_CLIENT\')', |
50
|
|
|
validationContext: ['groups' => ['order:write']], |
51
|
|
|
denormalizationContext: ['groups' => ['order:write']] |
52
|
|
|
), |
53
|
|
|
new Put( |
54
|
|
|
security: 'is_granted(\'ROLE_ADMIN\') or (is_granted(\'ROLE_CLIENT\'))', |
55
|
|
|
validationContext: ['groups' => ['order:write']], |
56
|
|
|
denormalizationContext: ['groups' => ['order:write']] |
57
|
|
|
), |
58
|
|
|
new Post( |
59
|
|
|
security: 'is_granted(\'ROLE_CLIENT\')', |
60
|
|
|
uriTemplate: '/orders/{id}/nfe', |
61
|
|
|
#requirements: ['format' => '^(pdf|xml)+$'], |
62
|
|
|
controller: CreateNFeAction::class |
63
|
|
|
), |
64
|
|
|
], |
65
|
|
|
formats: ['jsonld', 'json', 'html', 'jsonhal', 'csv' => ['text/csv']], |
66
|
|
|
normalizationContext: ['groups' => ['order_details:read']], |
67
|
|
|
denormalizationContext: ['groups' => ['order:write']] |
68
|
|
|
)] |
69
|
|
|
#[ApiFilter(filterClass: OrderFilter::class, properties: ['alterDate' => 'DESC'])] |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
class Order |
73
|
|
|
{ |
74
|
|
|
/** |
75
|
|
|
* @var integer |
76
|
|
|
* |
77
|
|
|
* @ORM\Column(name="id", type="integer", nullable=false) |
78
|
|
|
* @ORM\Id |
79
|
|
|
* @ORM\GeneratedValue(strategy="IDENTITY") |
80
|
|
|
* @Groups({"order_product_queue:read","order:read","order_details:read","company_expense:read","coupon:read","logistic:read","order_invoice:read"}) |
81
|
|
|
*/ |
82
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['id' => 'exact'])] |
83
|
|
|
|
84
|
|
|
private $id; |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @var \ControleOnline\Entity\People |
|
|
|
|
88
|
|
|
* |
89
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
90
|
|
|
* @ORM\JoinColumns({ |
91
|
|
|
* @ORM\JoinColumn(name="client_id", referencedColumnName="id") |
92
|
|
|
* }) |
93
|
|
|
* @Groups({"order_product_queue:read","order_product_queue:read","order:read","order_details:read","order:write", "invoice:read"}) |
94
|
|
|
*/ |
95
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['client' => 'exact'])] |
96
|
|
|
|
97
|
|
|
private $client; |
98
|
|
|
|
99
|
|
|
/** |
100
|
|
|
* @var \DateTimeInterface |
101
|
|
|
* @ORM\Column(name="order_date", type="datetime", nullable=false, columnDefinition="DATETIME") |
102
|
|
|
* @Groups({"order_product_queue:read","order:read","order_details:read","order:write"}) |
103
|
|
|
*/ |
104
|
|
|
#[ApiFilter(DateFilter::class, properties: ['orderDate'])] |
105
|
|
|
|
106
|
|
|
private $orderDate; |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @ORM\OneToMany(targetEntity="ControleOnline\Entity\OrderProduct", mappedBy="order", cascade={"persist"}) |
110
|
|
|
* @Groups({"order_details:read","order:write"}) |
111
|
|
|
*/ |
112
|
|
|
private $orderProducts; |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @var \Doctrine\Common\Collections\Collection |
|
|
|
|
116
|
|
|
* |
117
|
|
|
* @ORM\OneToMany(targetEntity="ControleOnline\Entity\OrderInvoice", mappedBy="order") |
118
|
|
|
*/ |
119
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['invoice' => 'exact'])] |
120
|
|
|
private $invoice; |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @var \Doctrine\Common\Collections\Collection |
124
|
|
|
* |
125
|
|
|
* @ORM\OneToMany(targetEntity="ControleOnline\Entity\Task", mappedBy="order") |
126
|
|
|
*/ |
127
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['task' => 'exact'])] |
128
|
|
|
|
129
|
|
|
private $task; |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @var \Doctrine\Common\Collections\Collection |
133
|
|
|
* |
134
|
|
|
* @ORM\OneToMany(targetEntity="ControleOnline\Entity\OrderInvoiceTax", mappedBy="order") |
135
|
|
|
*/ |
136
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['invoiceTax' => 'exact'])] |
137
|
|
|
|
138
|
|
|
private $invoiceTax; |
139
|
|
|
|
140
|
|
|
/** |
141
|
|
|
* @ORM\Column(name="alter_date", type="datetime", nullable=false) |
142
|
|
|
* @Groups({"display:read","order_product_queue:read","order:read","order_details:read","order:write"}) |
143
|
|
|
*/ |
144
|
|
|
|
145
|
|
|
#[ApiFilter(DateFilter::class, properties: ['alterDate'])] |
146
|
|
|
|
147
|
|
|
private $alterDate; |
148
|
|
|
|
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @var \ControleOnline\Entity\Status |
152
|
|
|
* |
153
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Status") |
154
|
|
|
* @ORM\JoinColumns({ |
155
|
|
|
* @ORM\JoinColumn(name="status_id", referencedColumnName="id") |
156
|
|
|
* }) |
157
|
|
|
* @Groups({"order_product_queue:read","display:read","order_product_queue:read","order:read","order_details:read","order:write"}) |
158
|
|
|
*/ |
159
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['status' => 'exact'])] |
160
|
|
|
|
161
|
|
|
private $status; |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @var string |
165
|
|
|
* |
166
|
|
|
* @ORM\Column(name="order_type", type="string", nullable=true) |
167
|
|
|
* @Groups({"order_product_queue:read","display:read","order_product_queue:read","order:read","order_details:read","order:write"}) |
168
|
|
|
*/ |
169
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['orderType' => 'exact'])] |
170
|
|
|
|
171
|
|
|
private $orderType = 'Online'; |
172
|
|
|
|
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @var string |
176
|
|
|
* |
177
|
|
|
* @ORM\Column(name="app", type="string", nullable=true) |
178
|
|
|
* @Groups({"order_product_queue:read","display:read","order_product_queue:read","order:read","order_details:read","order:write"}) |
179
|
|
|
*/ |
180
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['app' => 'exact'])] |
181
|
|
|
|
182
|
|
|
private $app = 'Manual'; |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @var string |
186
|
|
|
* |
187
|
|
|
* @ORM\Column(name="other_informations", type="json", nullable=true) |
188
|
|
|
* @Groups({"order_product_queue:read","order:read","order_details:read","order:write"}) |
189
|
|
|
*/ |
190
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['otherInformations' => 'exact'])] |
191
|
|
|
|
192
|
|
|
private $otherInformations; |
193
|
|
|
|
194
|
|
|
/** |
195
|
|
|
* @var \ControleOnline\Entity\Order |
196
|
|
|
* |
197
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Order") |
198
|
|
|
* @ORM\JoinColumns({ |
199
|
|
|
* @ORM\JoinColumn(name="main_order_id", referencedColumnName="id") |
200
|
|
|
* }) |
201
|
|
|
*/ |
202
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['mainOrder' => 'exact'])] |
203
|
|
|
|
204
|
|
|
private $mainOrder; |
205
|
|
|
|
206
|
|
|
|
207
|
|
|
/** |
208
|
|
|
* @var integer |
209
|
|
|
* |
210
|
|
|
* @ORM\Column(name="main_order_id", type="integer", nullable=true) |
211
|
|
|
* @Groups({"order_product_queue:read","order:read","order_details:read","order:write"}) |
212
|
|
|
*/ |
213
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['mainOrderId' => 'exact'])] |
214
|
|
|
|
215
|
|
|
private $mainOrderId; |
216
|
|
|
|
217
|
|
|
|
218
|
|
|
|
219
|
|
|
/** |
220
|
|
|
* @var \ControleOnline\Entity\People |
221
|
|
|
* |
222
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
223
|
|
|
* @ORM\JoinColumns({ |
224
|
|
|
* @ORM\JoinColumn(name="payer_people_id", referencedColumnName="id") |
225
|
|
|
* }) |
226
|
|
|
* @Groups({"order_product_queue:read","order:read","order_details:read","order:write","invoice:read"}) |
227
|
|
|
*/ |
228
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['payer' => 'exact'])] |
229
|
|
|
|
230
|
|
|
private $payer; |
231
|
|
|
|
232
|
|
|
/** |
233
|
|
|
* @var \ControleOnline\Entity\People |
234
|
|
|
* |
235
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
236
|
|
|
* @ORM\JoinColumns({ |
237
|
|
|
* @ORM\JoinColumn(name="provider_id", referencedColumnName="id") |
238
|
|
|
* }) |
239
|
|
|
* @Groups({"order_product_queue:read","order:read","order_details:read","order:write","invoice:read"}) |
240
|
|
|
*/ |
241
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['provider' => 'exact'])] |
242
|
|
|
|
243
|
|
|
private $provider; |
244
|
|
|
|
245
|
|
|
|
246
|
|
|
|
247
|
|
|
|
248
|
|
|
|
249
|
|
|
/** |
250
|
|
|
* @var \ControleOnline\Entity\Address |
|
|
|
|
251
|
|
|
* |
252
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Address") |
253
|
|
|
* @ORM\JoinColumns({ |
254
|
|
|
* @ORM\JoinColumn(name="address_origin_id", referencedColumnName="id") |
255
|
|
|
* }) |
256
|
|
|
* @Groups({"order_details:read","order:write"}) |
257
|
|
|
*/ |
258
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['addressOrigin' => 'exact'])] |
259
|
|
|
|
260
|
|
|
private $addressOrigin; |
261
|
|
|
|
262
|
|
|
/** |
263
|
|
|
* @var \ControleOnline\Entity\Address |
264
|
|
|
* |
265
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\Address") |
266
|
|
|
* @ORM\JoinColumns({ |
267
|
|
|
* @ORM\JoinColumn(name="address_destination_id", referencedColumnName="id") |
268
|
|
|
* }) |
269
|
|
|
* @Groups({"order_details:read","order:write"}) |
270
|
|
|
*/ |
271
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['addressDestination' => 'exact'])] |
272
|
|
|
|
273
|
|
|
private $addressDestination; |
274
|
|
|
|
275
|
|
|
/** |
276
|
|
|
* @var \ControleOnline\Entity\People |
277
|
|
|
* |
278
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
279
|
|
|
* @ORM\JoinColumns({ |
280
|
|
|
* @ORM\JoinColumn(name="retrieve_contact_id", referencedColumnName="id") |
281
|
|
|
* }) |
282
|
|
|
*/ |
283
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['retrieveContact' => 'exact'])] |
284
|
|
|
|
285
|
|
|
private $retrieveContact; |
286
|
|
|
|
287
|
|
|
/** |
288
|
|
|
* @var \ControleOnline\Entity\People |
289
|
|
|
* |
290
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\People") |
291
|
|
|
* @ORM\JoinColumns({ |
292
|
|
|
* @ORM\JoinColumn(name="delivery_contact_id", referencedColumnName="id") |
293
|
|
|
* }) |
294
|
|
|
*/ |
295
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['deliveryContact' => 'exact'])] |
296
|
|
|
|
297
|
|
|
private $deliveryContact; |
298
|
|
|
|
299
|
|
|
|
300
|
|
|
/** |
301
|
|
|
* @var float |
302
|
|
|
* |
303
|
|
|
* @ORM\Column(name="price", type="float", nullable=false) |
304
|
|
|
* @Groups({"order_product_queue:read","order:read","order_details:read","order:write"}) |
305
|
|
|
*/ |
306
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['price' => 'exact'])] |
307
|
|
|
|
308
|
|
|
private $price = 0; |
309
|
|
|
|
310
|
|
|
|
311
|
|
|
|
312
|
|
|
/** |
313
|
|
|
* @var string |
314
|
|
|
* |
315
|
|
|
* @ORM\Column(name="comments", type="string", nullable=true) |
316
|
|
|
* @Groups({"order_product_queue:read","order_product_queue:read","order:read","order_details:read","order:write"}) |
317
|
|
|
*/ |
318
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['comments' => 'exact'])] |
319
|
|
|
|
320
|
|
|
private $comments; |
321
|
|
|
|
322
|
|
|
/** |
323
|
|
|
* @var boolean |
324
|
|
|
* |
325
|
|
|
* @ORM\Column(name="notified", type="boolean") |
326
|
|
|
*/ |
327
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['notified' => 'exact'])] |
328
|
|
|
|
329
|
|
|
private $notified = false; |
330
|
|
|
|
331
|
|
|
/** |
332
|
|
|
* @ORM\ManyToOne(targetEntity="ControleOnline\Entity\User") |
333
|
|
|
* @ORM\JoinColumn(nullable=true) |
334
|
|
|
* @Groups({"order_product_queue:read","display:read","order_product_queue:read","order:read","order_details:read","order:write"}) |
335
|
|
|
*/ |
336
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['user' => 'exact'])] |
337
|
|
|
private $user; |
338
|
|
|
|
339
|
|
|
/** |
340
|
|
|
* @ORM\Column(type="string", length=50) |
341
|
|
|
* @Groups({"order_product_queue:read","display:read","order_product_queue:read","order:read","order_details:read","order:write"}) |
342
|
|
|
*/ |
343
|
|
|
#[ApiFilter(filterClass: SearchFilter::class, properties: ['device' => 'exact'])] |
344
|
|
|
private $device; |
345
|
|
|
|
346
|
|
|
|
347
|
|
|
|
348
|
|
|
public function __construct() |
349
|
|
|
{ |
350
|
|
|
$this->orderDate = new \DateTime('now'); |
351
|
|
|
$this->alterDate = new \DateTime('now'); |
352
|
|
|
$this->invoiceTax = new ArrayCollection(); |
353
|
|
|
$this->invoice = new ArrayCollection(); |
354
|
|
|
$this->task = new ArrayCollection(); |
355
|
|
|
$this->orderProducts = new ArrayCollection(); |
356
|
|
|
// $this->parkingDate = new \DateTime('now'); |
357
|
|
|
$this->otherInformations = json_encode(new stdClass()); |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
public function resetId() |
361
|
|
|
{ |
362
|
|
|
$this->id = null; |
363
|
|
|
$this->orderDate = new \DateTime('now'); |
364
|
|
|
$this->alterDate = new \DateTime('now'); |
365
|
|
|
// $this->parkingDate = new \DateTime('now'); |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
/** |
369
|
|
|
* Get id |
370
|
|
|
* |
371
|
|
|
* @return integer |
372
|
|
|
*/ |
373
|
|
|
public function getId() |
374
|
|
|
{ |
375
|
|
|
return $this->id; |
376
|
|
|
} |
377
|
|
|
|
378
|
|
|
/** |
379
|
|
|
* Set status |
380
|
|
|
* |
381
|
|
|
* @param \ControleOnline\Entity\Status $status |
382
|
|
|
* @return Order |
383
|
|
|
*/ |
384
|
|
|
public function setStatus(\ControleOnline\Entity\Status $status = null) |
385
|
|
|
{ |
386
|
|
|
$this->status = $status; |
387
|
|
|
|
388
|
|
|
return $this; |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
/** |
392
|
|
|
* Get status |
393
|
|
|
* |
394
|
|
|
* @return \ControleOnline\Entity\Status |
395
|
|
|
*/ |
396
|
|
|
public function getStatus() |
397
|
|
|
{ |
398
|
|
|
return $this->status; |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
/** |
402
|
|
|
* Set client |
403
|
|
|
* |
404
|
|
|
* @param \ControleOnline\Entity\People $client |
405
|
|
|
* @return Order |
406
|
|
|
*/ |
407
|
|
|
public function setClient(\ControleOnline\Entity\People $client = null) |
408
|
|
|
{ |
409
|
|
|
$this->client = $client; |
410
|
|
|
|
411
|
|
|
return $this; |
412
|
|
|
} |
413
|
|
|
|
414
|
|
|
/** |
415
|
|
|
* Get client |
416
|
|
|
* |
417
|
|
|
* @return \ControleOnline\Entity\People |
418
|
|
|
*/ |
419
|
|
|
public function getClient() |
420
|
|
|
{ |
421
|
|
|
return $this->client; |
422
|
|
|
} |
423
|
|
|
|
424
|
|
|
/** |
425
|
|
|
* Set provider |
426
|
|
|
* |
427
|
|
|
* @param \ControleOnline\Entity\People $provider |
428
|
|
|
* @return Order |
429
|
|
|
*/ |
430
|
|
|
public function setProvider(\ControleOnline\Entity\People $provider = null) |
431
|
|
|
{ |
432
|
|
|
$this->provider = $provider; |
433
|
|
|
|
434
|
|
|
return $this; |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* Get provider |
439
|
|
|
* |
440
|
|
|
* @return \ControleOnline\Entity\People |
441
|
|
|
*/ |
442
|
|
|
public function getProvider() |
443
|
|
|
{ |
444
|
|
|
return $this->provider; |
445
|
|
|
} |
446
|
|
|
|
447
|
|
|
/** |
448
|
|
|
* Set price |
449
|
|
|
* |
450
|
|
|
* @param float $price |
451
|
|
|
* @return Order |
452
|
|
|
*/ |
453
|
|
|
public function setPrice($price) |
454
|
|
|
{ |
455
|
|
|
$this->price = $price; |
456
|
|
|
|
457
|
|
|
return $this; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
/** |
461
|
|
|
* Get price |
462
|
|
|
* |
463
|
|
|
* @return float |
464
|
|
|
*/ |
465
|
|
|
public function getPrice() |
466
|
|
|
{ |
467
|
|
|
return $this->price; |
468
|
|
|
} |
469
|
|
|
|
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* Set addressOrigin |
473
|
|
|
* |
474
|
|
|
* @param \ControleOnline\Entity\Address $address_origin |
475
|
|
|
* @return Order |
476
|
|
|
*/ |
477
|
|
|
public function setAddressOrigin(\ControleOnline\Entity\Address $address_origin = null) |
478
|
|
|
{ |
479
|
|
|
$this->addressOrigin = $address_origin; |
480
|
|
|
|
481
|
|
|
return $this; |
482
|
|
|
} |
483
|
|
|
|
484
|
|
|
/** |
485
|
|
|
* Get addressOrigin |
486
|
|
|
* |
487
|
|
|
* @return \ControleOnline\Entity\Address |
488
|
|
|
*/ |
489
|
|
|
public function getAddressOrigin() |
490
|
|
|
{ |
491
|
|
|
return $this->addressOrigin; |
492
|
|
|
} |
493
|
|
|
|
494
|
|
|
/** |
495
|
|
|
* Set addressDestination |
496
|
|
|
* |
497
|
|
|
* @param \ControleOnline\Entity\Address $address_destination |
498
|
|
|
* @return Order |
499
|
|
|
*/ |
500
|
|
|
public function setAddressDestination(\ControleOnline\Entity\Address $address_destination = null) |
501
|
|
|
{ |
502
|
|
|
$this->addressDestination = $address_destination; |
503
|
|
|
|
504
|
|
|
return $this; |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* Get quote |
509
|
|
|
* |
510
|
|
|
* @return \ControleOnline\Entity\Address |
511
|
|
|
*/ |
512
|
|
|
public function getAddressDestination() |
513
|
|
|
{ |
514
|
|
|
return $this->addressDestination; |
515
|
|
|
} |
516
|
|
|
|
517
|
|
|
/** |
518
|
|
|
* Get retrieveContact |
519
|
|
|
* |
520
|
|
|
* @return \ControleOnline\Entity\People |
521
|
|
|
*/ |
522
|
|
|
public function getRetrieveContact() |
523
|
|
|
{ |
524
|
|
|
return $this->retrieveContact; |
525
|
|
|
} |
526
|
|
|
|
527
|
|
|
/** |
528
|
|
|
* Set retrieveContact |
529
|
|
|
* |
530
|
|
|
* @param \ControleOnline\Entity\People $retrieve_contact |
531
|
|
|
* @return Order |
532
|
|
|
*/ |
533
|
|
|
public function setRetrieveContact(\ControleOnline\Entity\People $retrieve_contact = null) |
534
|
|
|
{ |
535
|
|
|
$this->retrieveContact = $retrieve_contact; |
536
|
|
|
|
537
|
|
|
return $this; |
538
|
|
|
} |
539
|
|
|
|
540
|
|
|
/** |
541
|
|
|
* Get deliveryContact |
542
|
|
|
* |
543
|
|
|
* @return \ControleOnline\Entity\People |
544
|
|
|
*/ |
545
|
|
|
public function getDeliveryContact() |
546
|
|
|
{ |
547
|
|
|
return $this->deliveryContact; |
548
|
|
|
} |
549
|
|
|
|
550
|
|
|
/** |
551
|
|
|
* Set deliveryContact |
552
|
|
|
* |
553
|
|
|
* @param \ControleOnline\Entity\People $delivery_contact |
554
|
|
|
* @return Order |
555
|
|
|
*/ |
556
|
|
|
public function setDeliveryContact(\ControleOnline\Entity\People $delivery_contact = null) |
557
|
|
|
{ |
558
|
|
|
$this->deliveryContact = $delivery_contact; |
559
|
|
|
|
560
|
|
|
return $this; |
561
|
|
|
} |
562
|
|
|
|
563
|
|
|
/** |
564
|
|
|
* Set payer |
565
|
|
|
* |
566
|
|
|
* @param \ControleOnline\Entity\People $payer |
567
|
|
|
* @return Order |
568
|
|
|
*/ |
569
|
|
|
public function setPayer(\ControleOnline\Entity\People $payer = null) |
570
|
|
|
{ |
571
|
|
|
$this->payer = $payer; |
572
|
|
|
|
573
|
|
|
return $this; |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* Get payer |
578
|
|
|
* |
579
|
|
|
* @return \ControleOnline\Entity\People |
580
|
|
|
*/ |
581
|
|
|
public function getPayer() |
582
|
|
|
{ |
583
|
|
|
return $this->payer; |
584
|
|
|
} |
585
|
|
|
|
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* Set comments |
589
|
|
|
* |
590
|
|
|
* @param string $comments |
591
|
|
|
* @return Order |
592
|
|
|
*/ |
593
|
|
|
public function setComments($comments) |
594
|
|
|
{ |
595
|
|
|
$this->comments = $comments; |
596
|
|
|
|
597
|
|
|
return $this; |
598
|
|
|
} |
599
|
|
|
|
600
|
|
|
/** |
601
|
|
|
* Get comments |
602
|
|
|
* |
603
|
|
|
* @return string |
604
|
|
|
*/ |
605
|
|
|
public function getComments() |
606
|
|
|
{ |
607
|
|
|
return $this->comments; |
608
|
|
|
} |
609
|
|
|
|
610
|
|
|
/** |
611
|
|
|
* Get otherInformations |
612
|
|
|
* |
613
|
|
|
* @return stdClass |
614
|
|
|
*/ |
615
|
|
|
public function getOtherInformations($decode = false) |
616
|
|
|
{ |
617
|
|
|
return $decode ? (object) json_decode((is_array($this->otherInformations) ? json_encode($this->otherInformations) : $this->otherInformations)) : $this->otherInformations; |
|
|
|
|
618
|
|
|
} |
619
|
|
|
|
620
|
|
|
/** |
621
|
|
|
* Set comments |
622
|
|
|
* |
623
|
|
|
* @param string $otherInformations |
624
|
|
|
* @return Order |
625
|
|
|
*/ |
626
|
|
|
public function addOtherInformations($key, $value) |
627
|
|
|
{ |
628
|
|
|
$otherInformations = $this->getOtherInformations(true); |
629
|
|
|
$otherInformations->$key = $value; |
630
|
|
|
$this->otherInformations = json_encode($otherInformations); |
631
|
|
|
return $this; |
632
|
|
|
} |
633
|
|
|
|
634
|
|
|
/** |
635
|
|
|
* Set comments |
636
|
|
|
* |
637
|
|
|
* @param string $otherInformations |
638
|
|
|
* @return Order |
639
|
|
|
*/ |
640
|
|
|
public function setOtherInformations($otherInformations) |
641
|
|
|
{ |
642
|
|
|
$this->otherInformations = json_encode($otherInformations); |
643
|
|
|
return $this; |
644
|
|
|
} |
645
|
|
|
|
646
|
|
|
|
647
|
|
|
/** |
648
|
|
|
* Get orderDate |
649
|
|
|
* |
650
|
|
|
* @return \DateTimeInterface |
651
|
|
|
*/ |
652
|
|
|
public function getOrderDate() |
653
|
|
|
{ |
654
|
|
|
return $this->orderDate; |
655
|
|
|
} |
656
|
|
|
|
657
|
|
|
/** |
658
|
|
|
* Set alter_date |
659
|
|
|
* |
660
|
|
|
* @param \DateTimeInterface $alter_date |
661
|
|
|
*/ |
662
|
|
|
public function setAlterDate(\DateTimeInterface $alter_date = null): self |
663
|
|
|
{ |
664
|
|
|
$this->alterDate = $alter_date; |
665
|
|
|
|
666
|
|
|
return $this; |
667
|
|
|
} |
668
|
|
|
|
669
|
|
|
/** |
670
|
|
|
* Get alter_date |
671
|
|
|
* |
672
|
|
|
*/ |
673
|
|
|
public function getAlterDate(): ?\DateTimeInterface |
674
|
|
|
{ |
675
|
|
|
return $this->alterDate; |
676
|
|
|
} |
677
|
|
|
|
678
|
|
|
/** |
679
|
|
|
* Add invoiceTax |
680
|
|
|
* |
681
|
|
|
* @param \ControleOnline\Entity\OrderInvoiceTax $invoice_tax |
682
|
|
|
* @return Order |
683
|
|
|
*/ |
684
|
|
|
public function addAInvoiceTax(OrderInvoiceTax $invoice_tax) |
|
|
|
|
685
|
|
|
{ |
686
|
|
|
$this->invoiceTax[] = $invoice_tax; |
687
|
|
|
|
688
|
|
|
return $this; |
689
|
|
|
} |
690
|
|
|
|
691
|
|
|
/** |
692
|
|
|
* Remove invoiceTax |
693
|
|
|
* |
694
|
|
|
* @param \ControleOnline\Entity\OrderInvoiceTax $invoice_tax |
695
|
|
|
*/ |
696
|
|
|
public function removeInvoiceTax(OrderInvoiceTax $invoice_tax) |
697
|
|
|
{ |
698
|
|
|
$this->invoiceTax->removeElement($invoice_tax); |
699
|
|
|
} |
700
|
|
|
|
701
|
|
|
/** |
702
|
|
|
* Get invoiceTax |
703
|
|
|
* |
704
|
|
|
* @return \Doctrine\Common\Collections\Collection |
705
|
|
|
*/ |
706
|
|
|
public function getInvoiceTax() |
707
|
|
|
{ |
708
|
|
|
return $this->invoiceTax; |
709
|
|
|
} |
710
|
|
|
|
711
|
|
|
|
712
|
|
|
|
713
|
|
|
/** |
714
|
|
|
* Get invoiceTax |
715
|
|
|
* |
716
|
|
|
* @return \ControleOnline\Entity\InvoiceTax |
|
|
|
|
717
|
|
|
*/ |
718
|
|
|
public function getClientInvoiceTax() |
719
|
|
|
{ |
720
|
|
|
foreach ($this->getInvoiceTax() as $invoice) { |
721
|
|
|
if ($invoice->getInvoiceType() == 55) { |
722
|
|
|
return $invoice; |
723
|
|
|
} |
724
|
|
|
} |
725
|
|
|
} |
726
|
|
|
|
727
|
|
|
|
728
|
|
|
/** |
729
|
|
|
* Get invoiceTax |
730
|
|
|
* |
731
|
|
|
* @return \ControleOnline\Entity\InvoiceTax |
732
|
|
|
*/ |
733
|
|
|
public function getCarrierInvoiceTax() |
734
|
|
|
{ |
735
|
|
|
foreach ($this->getInvoiceTax() as $invoice) { |
736
|
|
|
if ($invoice->getInvoiceType() == 57) { |
737
|
|
|
return $invoice->getInvoiceTax(); |
738
|
|
|
} |
739
|
|
|
} |
740
|
|
|
} |
741
|
|
|
|
742
|
|
|
/** |
743
|
|
|
* Add OrderInvoice |
744
|
|
|
* |
745
|
|
|
* @param \ControleOnline\Entity\OrderInvoice $invoice |
746
|
|
|
* @return People |
747
|
|
|
*/ |
748
|
|
|
public function addInvoice(OrderInvoice $invoice) |
749
|
|
|
{ |
750
|
|
|
$this->invoice[] = $invoice; |
751
|
|
|
|
752
|
|
|
return $this; |
|
|
|
|
753
|
|
|
} |
754
|
|
|
|
755
|
|
|
/** |
756
|
|
|
* Remove OrderInvoice |
757
|
|
|
* |
758
|
|
|
* @param \ControleOnline\Entity\OrderInvoice $invoice |
759
|
|
|
*/ |
760
|
|
|
public function removeInvoice(OrderInvoice $invoice) |
761
|
|
|
{ |
762
|
|
|
$this->invoice->removeElement($invoice); |
763
|
|
|
} |
764
|
|
|
|
765
|
|
|
/** |
766
|
|
|
* Get OrderInvoice |
767
|
|
|
* |
768
|
|
|
* @return \Doctrine\Common\Collections\Collection |
769
|
|
|
*/ |
770
|
|
|
public function getInvoice() |
771
|
|
|
{ |
772
|
|
|
return $this->invoice; |
773
|
|
|
} |
774
|
|
|
|
775
|
|
|
|
776
|
|
|
/** |
777
|
|
|
* Get Notified |
778
|
|
|
* |
779
|
|
|
* @return boolean |
780
|
|
|
*/ |
781
|
|
|
public function getNotified() |
782
|
|
|
{ |
783
|
|
|
return $this->notified; |
784
|
|
|
} |
785
|
|
|
|
786
|
|
|
/** |
787
|
|
|
* Set Notified |
788
|
|
|
* |
789
|
|
|
* @param boolean $notified |
790
|
|
|
* @return People |
791
|
|
|
*/ |
792
|
|
|
public function setNotified($notified) |
793
|
|
|
{ |
794
|
|
|
$this->notified = $notified ? 1 : 0; |
|
|
|
|
795
|
|
|
|
796
|
|
|
return $this; |
|
|
|
|
797
|
|
|
} |
798
|
|
|
|
799
|
|
|
/** |
800
|
|
|
* Set orderType |
801
|
|
|
* |
802
|
|
|
* @param string $orderType |
803
|
|
|
* @return Order |
804
|
|
|
*/ |
805
|
|
|
public function setOrderType($order_type) |
806
|
|
|
{ |
807
|
|
|
$this->orderType = $order_type; |
808
|
|
|
|
809
|
|
|
return $this; |
810
|
|
|
} |
811
|
|
|
|
812
|
|
|
/** |
813
|
|
|
* Get orderType |
814
|
|
|
* |
815
|
|
|
* @return string |
816
|
|
|
*/ |
817
|
|
|
public function getOrderType() |
818
|
|
|
{ |
819
|
|
|
return $this->orderType; |
820
|
|
|
} |
821
|
|
|
|
822
|
|
|
/** |
823
|
|
|
* Set app |
824
|
|
|
* |
825
|
|
|
* @param string $app |
826
|
|
|
* @return Order |
827
|
|
|
*/ |
828
|
|
|
public function setApp($app) |
829
|
|
|
{ |
830
|
|
|
$this->app = $app; |
831
|
|
|
|
832
|
|
|
return $this; |
833
|
|
|
} |
834
|
|
|
|
835
|
|
|
/** |
836
|
|
|
* Get app |
837
|
|
|
* |
838
|
|
|
* @return string |
839
|
|
|
*/ |
840
|
|
|
public function getApp() |
841
|
|
|
{ |
842
|
|
|
return $this->app; |
843
|
|
|
} |
844
|
|
|
|
845
|
|
|
|
846
|
|
|
|
847
|
|
|
/** |
848
|
|
|
* Set mainOrder |
849
|
|
|
* |
850
|
|
|
* @param \ControleOnline\Entity\Order $mainOrder |
851
|
|
|
* @return Order |
852
|
|
|
*/ |
853
|
|
|
public function setMainOrder(\ControleOnline\Entity\Order $main_order = null) |
854
|
|
|
{ |
855
|
|
|
$this->mainOrder = $main_order; |
856
|
|
|
|
857
|
|
|
return $this; |
858
|
|
|
} |
859
|
|
|
|
860
|
|
|
/** |
861
|
|
|
* Get mainOrder |
862
|
|
|
* |
863
|
|
|
* @return \ControleOnline\Entity\Order |
864
|
|
|
*/ |
865
|
|
|
public function getMainOrder() |
866
|
|
|
{ |
867
|
|
|
return $this->mainOrder; |
868
|
|
|
} |
869
|
|
|
|
870
|
|
|
/** |
871
|
|
|
* Set mainOrderId |
872
|
|
|
* |
873
|
|
|
* @param integer $mainOrderId |
874
|
|
|
* @return Order |
875
|
|
|
*/ |
876
|
|
|
public function setMainOrderId($mainOrderId) |
877
|
|
|
{ |
878
|
|
|
$this->mainOrderId = $mainOrderId; |
879
|
|
|
|
880
|
|
|
return $this; |
881
|
|
|
} |
882
|
|
|
|
883
|
|
|
/** |
884
|
|
|
* Get mainOrderId |
885
|
|
|
* |
886
|
|
|
* @return integer |
887
|
|
|
*/ |
888
|
|
|
public function getMainOrderId() |
889
|
|
|
{ |
890
|
|
|
return $this->mainOrderId; |
891
|
|
|
} |
892
|
|
|
|
893
|
|
|
|
894
|
|
|
|
895
|
|
|
public function getInvoiceByStatus(array $status) |
896
|
|
|
{ |
897
|
|
|
foreach ($this->getInvoice() as $purchasingOrderInvoice) { |
898
|
|
|
$invoice = $purchasingOrderInvoice->getInvoice(); |
899
|
|
|
if (in_array($invoice->getStatus()->getStatus(), $status)) { |
900
|
|
|
return $invoice; |
901
|
|
|
} |
902
|
|
|
} |
903
|
|
|
} |
904
|
|
|
|
905
|
|
|
|
906
|
|
|
public function canAccess($currentUser): bool |
907
|
|
|
{ |
908
|
|
|
if (($provider = $this->getProvider()) === null) |
909
|
|
|
return false; |
910
|
|
|
|
911
|
|
|
return $currentUser->getPeople()->getLink()->exists( |
912
|
|
|
function ($key, $element) use ($provider) { |
913
|
|
|
return $element->getCompany() === $provider; |
914
|
|
|
} |
915
|
|
|
); |
916
|
|
|
} |
917
|
|
|
|
918
|
|
|
public function justOpened(): bool |
919
|
|
|
{ |
920
|
|
|
return $this->getStatus()->getStatus() == 'quote'; |
921
|
|
|
} |
922
|
|
|
|
923
|
|
|
|
924
|
|
|
public function getOneInvoice() |
925
|
|
|
{ |
926
|
|
|
return (($invoiceOrders = $this->getInvoice()->first()) === false) ? |
927
|
|
|
null : $invoiceOrders->getInvoice(); |
928
|
|
|
} |
929
|
|
|
|
930
|
|
|
/** |
931
|
|
|
* Add Task |
932
|
|
|
* |
933
|
|
|
* @param \ControleOnline\Entity\Task $task |
934
|
|
|
* @return Order |
935
|
|
|
*/ |
936
|
|
|
public function addTask(\ControleOnline\Entity\Task $task) |
|
|
|
|
937
|
|
|
{ |
938
|
|
|
$this->task[] = $task; |
939
|
|
|
|
940
|
|
|
return $this; |
941
|
|
|
} |
942
|
|
|
|
943
|
|
|
/** |
944
|
|
|
* Remove Task |
945
|
|
|
* |
946
|
|
|
* @param \ControleOnline\Entity\Task $task |
947
|
|
|
*/ |
948
|
|
|
public function removeTask(\ControleOnline\Entity\Task $task) |
949
|
|
|
{ |
950
|
|
|
$this->task->removeElement($task); |
951
|
|
|
} |
952
|
|
|
|
953
|
|
|
/** |
954
|
|
|
* Get Task |
955
|
|
|
* |
956
|
|
|
* @return \Doctrine\Common\Collections\Collection |
957
|
|
|
*/ |
958
|
|
|
public function getTask() |
959
|
|
|
{ |
960
|
|
|
return $this->task; |
961
|
|
|
} |
962
|
|
|
|
963
|
|
|
public function isOriginAndDestinationTheSame(): ?bool |
964
|
|
|
{ |
965
|
|
|
if (($origin = $this->getAddressOrigin()) === null) { |
966
|
|
|
return null; |
967
|
|
|
} |
968
|
|
|
|
969
|
|
|
if (($destination = $this->getAddressDestination()) === null) { |
970
|
|
|
return null; |
971
|
|
|
} |
972
|
|
|
|
973
|
|
|
$origCity = $origin->getStreet()->getDistrict()->getCity(); |
974
|
|
|
$destCity = $destination->getStreet()->getDistrict()->getCity(); |
975
|
|
|
|
976
|
|
|
// both objects are the same entity ( = same name and same state) |
977
|
|
|
|
978
|
|
|
if ($origCity === $destCity) { |
979
|
|
|
return true; |
980
|
|
|
} |
981
|
|
|
|
982
|
|
|
return false; |
983
|
|
|
} |
984
|
|
|
|
985
|
|
|
public function isOriginAndDestinationTheSameState(): ?bool |
986
|
|
|
{ |
987
|
|
|
if (($origin = $this->getAddressOrigin()) === null) { |
988
|
|
|
return null; |
989
|
|
|
} |
990
|
|
|
|
991
|
|
|
if (($destination = $this->getAddressDestination()) === null) { |
992
|
|
|
return null; |
993
|
|
|
} |
994
|
|
|
|
995
|
|
|
$origState = $origin->getStreet()->getDistrict()->getCity()->getState(); |
996
|
|
|
$destState = $destination->getStreet()->getDistrict()->getCity()->getState(); |
997
|
|
|
|
998
|
|
|
// both objects are the same entity ( = same name and same country) |
999
|
|
|
|
1000
|
|
|
if ($origState === $destState) { |
1001
|
|
|
return true; |
1002
|
|
|
} |
1003
|
|
|
|
1004
|
|
|
return false; |
1005
|
|
|
} |
1006
|
|
|
|
1007
|
|
|
|
1008
|
|
|
public function getOrderProducts() |
1009
|
|
|
{ |
1010
|
|
|
return $this->orderProducts; |
1011
|
|
|
} |
1012
|
|
|
|
1013
|
|
|
public function addOrderProduct(OrderProduct $orderProduct): self |
1014
|
|
|
{ |
1015
|
|
|
$this->orderProducts[] = $orderProduct; |
1016
|
|
|
return $this; |
1017
|
|
|
} |
1018
|
|
|
|
1019
|
|
|
public function removeOrderProduct(OrderProduct $orderProduct): self |
1020
|
|
|
{ |
1021
|
|
|
$this->orderProducts->removeElement($orderProduct); |
1022
|
|
|
return $this; |
1023
|
|
|
} |
1024
|
|
|
|
1025
|
|
|
/** |
1026
|
|
|
* Get the value of user |
1027
|
|
|
*/ |
1028
|
|
|
public function getUser() |
1029
|
|
|
{ |
1030
|
|
|
return $this->user; |
1031
|
|
|
} |
1032
|
|
|
|
1033
|
|
|
/** |
1034
|
|
|
* Set the value of user |
1035
|
|
|
*/ |
1036
|
|
|
public function setUser($user): self |
1037
|
|
|
{ |
1038
|
|
|
$this->user = $user; |
1039
|
|
|
|
1040
|
|
|
return $this; |
1041
|
|
|
} |
1042
|
|
|
|
1043
|
|
|
/** |
1044
|
|
|
* Get the value of device |
1045
|
|
|
*/ |
1046
|
|
|
public function getDevice() |
1047
|
|
|
{ |
1048
|
|
|
return $this->device; |
1049
|
|
|
} |
1050
|
|
|
|
1051
|
|
|
/** |
1052
|
|
|
* Set the value of device |
1053
|
|
|
*/ |
1054
|
|
|
public function setDevice($device): self |
1055
|
|
|
{ |
1056
|
|
|
$this->device = $device; |
1057
|
|
|
|
1058
|
|
|
return $this; |
1059
|
|
|
} |
1060
|
|
|
} |
1061
|
|
|
|
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