Completed
Push — master ( 31ac84...e79cb7 )
by Laurent
12:51 queued 09:39
created

Article::setTva()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
/**
4
 * Entité Article.
5
 *
6
 * PHP Version 5
7
 *
8
 * @author     Quétier Laurent <[email protected]>
9
 * @copyright  2014 Dev-Int GLSR
10
 * @license    http://opensource.org/licenses/gpl-license.php GNU Public License
11
 *
12
 * @version    since 1.0.0
13
 *
14
 * @link       https://github.com/Dev-Int/glsr
15
 */
16
namespace AppBundle\Entity;
17
18
use Doctrine\ORM\Mapping as ORM;
19
use Symfony\Component\Validator\Constraints as Assert;
20
use Gedmo\Mapping\Annotation as Gedmo;
21
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
22
use Doctrine\Common\Collections\ArrayCollection;
23
use AppBundle\Entity\Supplier;
24
use AppBundle\Entity\UnitStorage;
25
use AppBundle\Entity\ZoneStorage;
26
use AppBundle\Entity\FamilyLog;
27
28
/**
29
 * Article.
30
 *
31
 * @category   Entity
32
 *
33
 * @ORM\Table(name="gs_article")
34
 * @ORM\Entity(repositoryClass="AppBundle\Entity\ArticleRepository")
35
 * @UniqueEntity(fields="name", message="Ce nom d'article est déjà utilisé.")
36
 * @ORM\HasLifecycleCallbacks()
37
 */
38
class Article
39
{
40
    /**
41
     * @var int Id de l'article
42
     *
43
     * @ORM\Column(name="id", type="integer")
44
     * @ORM\Id
45
     * @ORM\GeneratedValue(strategy="AUTO")
46
     */
47
    private $id;
48
49
    /**
50
     * @var string intitulé de l'article
51
     *
52
     * @ORM\Column(name="name", type="string", length=255)
53
     * @Assert\NotBlank()
54
     * @Assert\Regex(
55
     *     pattern="'^\w+[^/]'",
56
     *     message="L'intitulé ne peut contenir que des lettres,
57
     *     chiffres et _ ou -"
58
     * )
59
     */
60
    private $name;
61
62
    /**
63
     * @var string|\AppBundle\Entity\Supplier Nom du fournisseur
64
     *
65
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Supplier")
66
     */
67
    private $supplier;
68
69
    /**
70
     * @var string|\AppBundle\Entity\UnitStorage Unité de stockage
71
     *
72
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\UnitStorage")
73
     */
74
    private $unitStorage;
75
76
    /**
77
     * @var double Conditionement (quantité)
78
     *
79
     * @ORM\Column(name="packaging", type="decimal", precision=7, scale=3)
80
     * @Assert\Type(type="numeric",
81
     * message="La valeur {{ value }} n'est pas un type {{ type }} valide.")
82
     */
83
    private $packaging;
84
85
    /**
86
     * @var double prix de l'article
87
     *
88
     * @ORM\Column(name="price", type="decimal", precision=7, scale=3)
89
     * @Assert\Type(type="numeric",
90
     * message="La valeur {{ value }} n'est pas un type {{ type }} valide.")
91
     */
92
    private $price;
93
94
    /**
95
     * @var string|\AppBundle\Entity\Tva Taux de TVA
96
     *
97
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\Tva")
98
     */
99
    private $tva;
100
101
    /**
102
     * @var double Quantité en stock
103
     *
104
     * @ORM\Column(name="quantity", type="decimal", precision=7, scale=3)
105
     * @Assert\Type(type="numeric",
106
     * message="La valeur {{ value }} n'est pas un type {{ type }} valide.")
107
     */
108
    private $quantity;
109
110
    /**
111
     * @var double Stock minimum
112
     *
113
     * @ORM\Column(name="minstock", type="decimal", precision=7, scale=3)
114
     * @Assert\Type(type="numeric",
115
     * message="La valeur {{ value }} n'est pas un type {{ type }} valide.")
116
     */
117
    private $minstock;
118
119
    /**
120
     * @var \Doctrine\Common\Collections\ArrayCollection Zone(s) de stockage
121
     *
122
     * @ORM\ManyToMany(targetEntity="AppBundle\Entity\ZoneStorage")
123
     * @ORM\JoinTable(name="gs_article_zonestorage")
124
     * @Assert\NotBlank()
125
     */
126
    private $zoneStorages;
127
128
    /**
129
     * @var string|\AppBundle\Entity\FamilyLog Famille logistique
130
     *
131
     * @ORM\ManyToOne(targetEntity="AppBundle\Entity\FamilyLog")
132
     * @Assert\NotBlank()
133
     */
134
    private $familyLog;
135
136
    /**
137
     * @var bool Activé/Désactivé
138
     *
139
     * @ORM\Column(name="active", type="boolean")
140
     */
141
    private $active;
142
143
    /**
144
     * @Gedmo\Slug(fields={"name"}, updatable=false)
145
     * @ORM\Column(length=128, unique=true)
146
     */
147
    private $slug;
148
149
    /**
150
     * Constructor.
151
     */
152
    public function __construct()
153
    {
154
        $this->zoneStorages = new ArrayCollection();
155
        $this->active = true;
156
        $this->quantity = 0.000;
157
    }
158
159
    /**
160
     * Get id.
161
     *
162
     * @return int
163
     */
164
    public function getId()
165
    {
166
        return $this->id;
167
    }
168
169
    /**
170
     * Set name.
171
     *
172
     * @param string $name Nom de l'article
173
     *
174
     * @return Article
175
     */
176
    public function setName($name)
177
    {
178
        $this->name = $name;
179
180
        return $this;
181
    }
182
183
    /**
184
     * Get name.
185
     *
186
     * @return string
187
     */
188
    public function getName()
189
    {
190
        return $this->name;
191
    }
192
193
    /**
194
     * Set packaging.
195
     *
196
     * @param double $packaging Conditionnement (quantité)
197
     *
198
     * @return Article
199
     */
200
    public function setPackaging($packaging)
201
    {
202
        $this->packaging = $packaging;
203
204
        return $this;
205
    }
206
207
    /**
208
     * Get packaging.
209
     *
210
     * @return double
211
     */
212
    public function getPackaging()
213
    {
214
        return $this->packaging;
215
    }
216
217
    /**
218
     * Set price.
219
     *
220
     * @param double $price prix de l'article
221
     *
222
     * @return Article
223
     */
224
    public function setPrice($price)
225
    {
226
        $this->price = $price;
227
228
        return $this;
229
    }
230
231
    /**
232
     * Get price.
233
     *
234
     * @return double
235
     */
236
    public function getPrice()
237
    {
238
        return $this->price;
239
    }
240
241
    /**
242
     * Set quantity.
243
     *
244
     * @param double $quantity quantité en stock
245
     *
246
     * @return Article
247
     */
248
    public function setQuantity($quantity)
249
    {
250
        $this->quantity = $quantity;
251
252
        return $this;
253
    }
254
255
    /**
256
     * Get quantity.
257
     *
258
     * @return double
259
     */
260
    public function getQuantity()
261
    {
262
        return $this->quantity;
263
    }
264
265
    /**
266
     * Set minstock.
267
     *
268
     * @param double $minstock stock minimum
269
     *
270
     * @return Article
271
     */
272
    public function setMinstock($minstock)
273
    {
274
        $this->minstock = $minstock;
275
276
        return $this;
277
    }
278
279
    /**
280
     * Get minstock.
281
     *
282
     * @return double
283
     */
284
    public function getMinstock()
285
    {
286
        return $this->minstock;
287
    }
288
289
    /**
290
     * Set supplier.
291
     *
292
     * @param null|\AppBundle\Entity\Supplier $supplier Fournisseur de l'article
293
     *
294
     * @return Article
295
     */
296
    public function setSupplier(Supplier $supplier = null)
297
    {
298
        $this->supplier = $supplier;
299
300
        return $this;
301
    }
302
303
    /**
304
     * Get supplier.
305
     *
306
     * @return string|\AppBundle\Entity\Supplier
307
     */
308
    public function getSupplier()
309
    {
310
        return $this->supplier;
311
    }
312
313
    /**
314
     * Set unitStorage.
315
     *
316
     * @param null|\AppBundle\Entity\UnitStorage $unitStorage Unité de stockage
317
     *
318
     * @return Article
319
     */
320
    public function setUnitStorage(UnitStorage $unitStorage = null)
321
    {
322
        $this->unitStorage = $unitStorage;
323
324
        return $this;
325
    }
326
327
    /**
328
     * Get unitStorage.
329
     *
330
     * @return string|\AppBundle\Entity\UnitStorage
331
     */
332
    public function getUnitStorage()
333
    {
334
        return $this->unitStorage;
335
    }
336
337
    /**
338
     * Add zoneStorage.
339
     *
340
     * @param \AppBundle\Entity\ZoneStorage
341
     * $zoneStorages Zone(s) de stockage
342
     *
343
     * @return Article
344
     */
345
    public function addZoneStorage(ZoneStorage $zoneStorages)
346
    {
347
        $this->zoneStorages[] = $zoneStorages;
348
349
        return $this;
350
    }
351
352
    /**
353
     * Remove zoneStorage.
354
     *
355
     * @param ZoneStorage $zoneStorages Zone de stockage à supprimer
356
     *
357
     * @return \Doctrine\Common\Collections\ArrayCollection|null
358
     */
359
    public function removeZoneStorage(ZoneStorage $zoneStorages)
360
    {
361
        $this->zoneStorages->removeElement($zoneStorages);
362
    }
363
364
    /**
365
     * Get zoneStorage.
366
     *
367
     * @return \Doctrine\Common\Collections\ArrayCollection
368
     */
369
    public function getZoneStorages()
370
    {
371
        return $this->zoneStorages;
372
    }
373
374
    /**
375
     * Set familyLog.
376
     *
377
     * @param null|\AppBundle\Entity\FamilyLog $familyLog Famille Logistique
378
     *
379
     * @return Article
380
     */
381
    public function setFamilyLog(FamilyLog $familyLog = null)
382
    {
383
        $this->familyLog = $familyLog;
384
385
        return $this;
386
    }
387
388
    /**
389
     * Get familyLog.
390
     *
391
     * @return \AppBundle\Entity\FamilyLog
392
     */
393
    public function getFamilyLog()
394
    {
395
        return $this->familyLog;
396
    }
397
398
    /**
399
     * Set active.
400
     *
401
     * @param bool $active Activé/Désactivé
402
     *
403
     * @return Article
404
     */
405
    public function setActive($active)
406
    {
407
        $this->active = $active;
408
409
        return $this;
410
    }
411
412
    /**
413
     * Is active
414
     *
415
     * @return boolean
416
     */
417
    public function isActive()
418
    {
419
        return $this->active;
420
    }
421
422
    /**
423
     * Get slug
424
     *
425
     * @return string
426
     */
427
    public function getSlug()
428
    {
429
        return $this->slug;
430
    }
431
432
    /**
433
     * Cette méthode permet de faire "echo $article".
434
     * <p>Ainsi, pour "afficher" $article,
435
     * PHP affichera en réalité le retour de cette méthode.<br />
436
     * Ici, le nom, donc "echo $article"
437
     * est équivalent à "echo $article->getName()".</p>
438
     *
439
     * @return string name
440
     */
441
    public function __toString()
442
    {
443
        return $this->name;
444
    }
445
446
    /**
447
     * Set tva
448
     *
449
     * @param \AppBundle\Entity\Tva $tva
450
     * @return Article
451
     */
452
    public function setTva(\AppBundle\Entity\Tva $tva = null)
453
    {
454
        $this->tva = $tva;
455
456
        return $this;
457
    }
458
459
    /**
460
     * Get tva
461
     *
462
     * @return \AppBundle\Entity\Tva
463
     */
464
    public function getTva()
465
    {
466
        return $this->tva;
467
    }
468
}
469