Passed
Push — main ( 6bf038...55787e )
by Aleksandr
08:10
created

Item   A

Complexity

Total Complexity 36

Size/Duplication

Total Lines 513
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 74
c 1
b 0
f 0
dl 0
loc 513
ccs 90
cts 90
cp 1
rs 9.52
wmc 36

36 Methods

Rating   Name   Duplication   Size   Complexity  
A setBarcode() 0 4 1
A getSuppCompany() 0 3 1
A getSuppINN() 0 3 1
A getExcise() 0 3 1
A setGovernmentCode() 0 4 1
A getSuppPhone() 0 3 1
A getRetPrice() 0 3 1
A setExtCode() 0 4 1
A setMass() 0 4 1
A getName() 0 3 1
A setWeight() 0 4 1
A getBarcode() 0 3 1
A setArticle() 0 4 1
A getVatRate() 0 3 1
A setRetPrice() 0 4 1
A getGovernmentCode() 0 3 1
A setSuppPhone() 0 4 1
A setVatRate() 0 4 1
A setExcise() 0 4 1
A setSuppINN() 0 4 1
A setInshPrice() 0 4 1
A setSuppCompany() 0 4 1
A getArticle() 0 3 1
A getType() 0 3 1
A getGtd() 0 3 1
A getQuantity() 0 3 1
A getMass() 0 3 1
A setName() 0 4 1
A setGtd() 0 4 1
A getOriginCountry() 0 3 1
A setOriginCountry() 0 4 1
A setQuantity() 0 4 1
A getExtCode() 0 3 1
A getWeight() 0 3 1
A getInshPrice() 0 3 1
A setType() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DalliSDK\Models;
6
7
use DalliSDK\Traits\Fillable;
8
use JMS\Serializer\Annotation as JMS;
9
10
/**
11
 * Модель с информацией о позиции (товаре) в заказе
12
 *
13
 * @see https://api.dalli-service.com/v1/doc/createbasket
14
 * @JMS\XmlRoot("item")
15
 */
16
class Item
17
{
18
    use Fillable;
19
20
    /**
21
     * Количество товаров
22
     *
23
     * @JMS\XmlAttribute()
24
     * @JMS\Type("int")
25
     * @JMS\SerializedName("quantity")
26
     */
27
    private int $quantity;
28
29
    /**
30
     * Масса единицы товара в килограммах
31
     *
32
     * @JMS\XmlAttribute()
33
     * @JMS\Type("float")
34
     * @JMS\SerializedName("weight")
35
     */
36
    private ?float $weight = null;
37
38
    /**
39
     * Масса единицы товара в килограммах (иногда ответ приходит именно в этом аттрибуте)
40
     *
41
     * @JMS\XmlAttribute()
42
     * @JMS\Type("float")
43
     * @JMS\SerializedName("mass")
44
     */
45
    private ?float $mass = null;
46
47
    /**
48
     * Цена за штуку
49
     *
50
     * @JMS\XmlAttribute()
51
     * @JMS\Type("float")
52
     * @JMS\SerializedName("retprice")
53
     */
54
    private float $retPrice;
55
56
    /**
57
     * Оценочная стоимость за штуку
58
     *
59
     * @JMS\XmlAttribute()
60
     * @JMS\Type("float")
61
     * @JMS\SerializedName("inshprice")
62
     */
63
    private ?float $inshPrice = null;
64
65
    /**
66
     * Штрих-код товара
67
     *
68
     * @JMS\XmlAttribute()
69
     * @JMS\Type("string")
70
     * @JMS\SerializedName("barcode")
71
     */
72
    private ?string $barcode = null;
73
74
    /**
75
     * Артикул товара(необязательный). После добавления заявки в Забор (выгрузки из корзины)
76
     * будет объединен с наименованием в формате "АРТИКУЛ - НАЗВАНИЕ"
77
     *
78
     * @JMS\XmlAttribute()
79
     * @JMS\Type("string")
80
     * @JMS\SerializedName("article")
81
     */
82
    private ?string $article = null;
83
84
85
    /**
86
     * Ставка НДС - целое число процентов. Если значение не указано, подставляется значение "20".
87
     * Значение "0" означает ставку "Без НДС", ставка "0%" на данный момент не поддерживается.
88
     *
89
     * @JMS\XmlAttribute()
90
     * @JMS\Type("int")
91
     * @JMS\SerializedName("VATrate")
92
     */
93
    private ?int $vatRate = null;
94
95
    /**
96
     * Код страны-производителя в соответствии с стандартом ISO_3166-1, например, "RU", "RUS" или "643" для России.
97
     *
98
     * @JMS\XmlAttribute()
99
     * @JMS\Type("string")
100
     * @JMS\SerializedName("origincountry")
101
     */
102
    private ?string $originCountry = null;
103
104
    /**
105
     * Номер ГТД
106
     *
107
     * @JMS\XmlAttribute()
108
     * @JMS\Type("string")
109
     * @JMS\SerializedName("GTD")
110
     */
111
    private ?string $gtd = null;
112
113
    /**
114
     * Сумма акциза
115
     *
116
     * @JMS\XmlAttribute()
117
     * @JMS\Type("float")
118
     */
119
    private ?float $excise = null;
120
121
    /**
122
     * Наименование компании поставщика, если отличается от заказчика
123
     *
124
     * @JMS\XmlAttribute()
125
     * @JMS\Type("string")
126
     * @JMS\SerializedName("suppcompany")
127
     */
128
    private ?string $suppCompany = null;
129
130
    /**
131
     * Номер телефона компании поставщика, если отличается от заказчика
132
     *
133
     * @JMS\XmlAttribute()
134
     * @JMS\Type("string")
135
     * @JMS\SerializedName("suppphone")
136
     */
137
    private ?string $suppPhone = null;
138
139
    /**
140
     * ИНН компании поставщика, если отличается от заказчика
141
     *
142
     * @JMS\XmlAttribute()
143
     * @JMS\Type("string")
144
     * @JMS\SerializedName("suppINN")
145
     */
146
    private ?string $suppINN = null;
147
148
    /**
149
     * Код товарной номенклатуры. Используется для маркированных товаров ("Честный знак").
150
     * Нужно указывать все данные из нанесенного QR-кода, кроме нечитаемых символов (#29).
151
     * Если поле заполнено - поле quantity должно содержать только "1"
152
     *
153
     * @JMS\XmlAttribute()
154
     * @JMS\Type("string")
155
     * @JMS\SerializedName("governmentcode")
156
     */
157
    private ?string $governmentCode = null;
158
159
    /**
160
     * Тип вложения. Принимает значения:
161
     *      1 - Товар. По умолчанию
162
     *      7 - Забор товара.
163
     * Если товар нужно у получателя забрать, возможно - вернуть деньги,
164
     * или его стоимость вычитается из суммы других товаров.
165
     * У такого товара в заявке будет отрицательное количество независимо от знака в запросе
166
     *
167
     * @JMS\XmlAttribute()
168
     * @JMS\Type("int")
169
     */
170
    private int $type = 1;
171
172
    /**
173
     * Внутренний код товарной позиции
174
     *
175
     * @JMS\XmlAttribute()
176
     * @JMS\Type("string")
177
     * @JMS\SerializedName("extcode")
178
     */
179
    private ?string $extCode = null;
180
181
    /**
182
     * Название товара
183
     *
184
     * @JMS\XmlValue
185
     * @JMS\Type("string")
186
     */
187
    private string $name;
188
189
    /**
190
     * @return int
191
     */
192 2
    public function getQuantity(): int
193
    {
194 2
        return $this->quantity;
195
    }
196
197
    /**
198
     * @param int $quantity
199
     *
200
     * @return Item
201
     */
202 20
    public function setQuantity(int $quantity): Item
203
    {
204 20
        $this->quantity = $quantity;
205 20
        return $this;
206
    }
207
208
    /**
209
     * @return float|null
210
     */
211 2
    public function getWeight(): ?float
212
    {
213 2
        return max($this->weight, $this->mass);
214
    }
215
216
    /**
217
     * @param float|null $weight
218
     *
219
     * @return Item
220
     */
221 19
    public function setWeight(?float $weight): Item
222
    {
223 19
        $this->weight = $weight;
224 19
        return $this;
225
    }
226
227
    /**
228
     * @return float|null
229
     */
230 2
    public function getMass(): ?float
231
    {
232 2
        return $this->mass;
233
    }
234
235
    /**
236
     * @param float|null $mass
237
     *
238
     * @return Item
239
     */
240 1
    public function setMass(?float $mass): Item
241
    {
242 1
        $this->mass = $mass;
243 1
        return $this;
244
    }
245
246
    /**
247
     * @return float
248
     */
249 2
    public function getRetPrice(): float
250
    {
251 2
        return $this->retPrice;
252
    }
253
254
    /**
255
     * @param float $retPrice
256
     *
257
     * @return Item
258
     */
259 20
    public function setRetPrice(float $retPrice): Item
260
    {
261 20
        $this->retPrice = $retPrice;
262 20
        return $this;
263
    }
264
265
    /**
266
     * @return float|null
267
     */
268 2
    public function getInshPrice(): ?float
269
    {
270 2
        return $this->inshPrice;
271
    }
272
273
    /**
274
     * @param float|null $inshPrice
275
     *
276
     * @return Item
277
     */
278 19
    public function setInshPrice(?float $inshPrice): Item
279
    {
280 19
        $this->inshPrice = $inshPrice;
281 19
        return $this;
282
    }
283
284
    /**
285
     * @return string|null
286
     */
287 2
    public function getBarcode(): ?string
288
    {
289 2
        return $this->barcode;
290
    }
291
292
    /**
293
     * @param string|null $barcode
294
     *
295
     * @return Item
296
     */
297 1
    public function setBarcode(?string $barcode): Item
298
    {
299 1
        $this->barcode = $barcode;
300 1
        return $this;
301
    }
302
303
    /**
304
     * @return string|null
305
     */
306 3
    public function getArticle(): ?string
307
    {
308 3
        return $this->article;
309
    }
310
311
    /**
312
     * @param string|null $article
313
     *
314
     * @return Item
315
     */
316 1
    public function setArticle(?string $article): Item
317
    {
318 1
        $this->article = $article;
319 1
        return $this;
320
    }
321
322
    /**
323
     * @return int|null
324
     */
325 3
    public function getVatRate(): ?int
326
    {
327 3
        return $this->vatRate;
328
    }
329
330
    /**
331
     * @param int|null $vatRate
332
     *
333
     * @return Item
334
     */
335 1
    public function setVatRate(?int $vatRate): Item
336
    {
337 1
        $this->vatRate = $vatRate;
338 1
        return $this;
339
    }
340
341
    /**
342
     * @return string|null
343
     */
344 2
    public function getOriginCountry(): ?string
345
    {
346 2
        return $this->originCountry;
347
    }
348
349
    /**
350
     * @param string|null $originCountry
351
     *
352
     * @return Item
353
     */
354 19
    public function setOriginCountry(?string $originCountry): Item
355
    {
356 19
        $this->originCountry = $originCountry;
357 19
        return $this;
358
    }
359
360
    /**
361
     * @return string|null
362
     */
363 2
    public function getGtd(): ?string
364
    {
365 2
        return $this->gtd;
366
    }
367
368
    /**
369
     * @param string|null $gtd
370
     *
371
     * @return Item
372
     */
373 19
    public function setGtd(?string $gtd): Item
374
    {
375 19
        $this->gtd = $gtd;
376 19
        return $this;
377
    }
378
379
    /**
380
     * @return float|null
381
     */
382 3
    public function getExcise(): ?float
383
    {
384 3
        return $this->excise;
385
    }
386
387
    /**
388
     * @param float|null $excise
389
     *
390
     * @return Item
391
     */
392 1
    public function setExcise(?float $excise): Item
393
    {
394 1
        $this->excise = $excise;
395 1
        return $this;
396
    }
397
398
    /**
399
     * @return string|null
400
     */
401 2
    public function getSuppCompany(): ?string
402
    {
403 2
        return $this->suppCompany;
404
    }
405
406
    /**
407
     * @param string|null $suppCompany
408
     *
409
     * @return Item
410
     */
411 19
    public function setSuppCompany(?string $suppCompany): Item
412
    {
413 19
        $this->suppCompany = $suppCompany;
414 19
        return $this;
415
    }
416
417
    /**
418
     * @return string|null
419
     */
420 2
    public function getSuppPhone(): ?string
421
    {
422 2
        return $this->suppPhone;
423
    }
424
425
    /**
426
     * @param string|null $suppPhone
427
     *
428
     * @return Item
429
     */
430 19
    public function setSuppPhone(?string $suppPhone): Item
431
    {
432 19
        $this->suppPhone = $suppPhone;
433 19
        return $this;
434
    }
435
436
    /**
437
     * @return string|null
438
     */
439 2
    public function getSuppINN(): ?string
440
    {
441 2
        return $this->suppINN;
442
    }
443
444
    /**
445
     * @param string|null $suppINN
446
     *
447
     * @return Item
448
     */
449 19
    public function setSuppINN(?string $suppINN): Item
450
    {
451 19
        $this->suppINN = $suppINN;
452 19
        return $this;
453
    }
454
455
    /**
456
     * @return string|null
457
     */
458 3
    public function getGovernmentCode(): ?string
459
    {
460 3
        return $this->governmentCode;
461
    }
462
463
    /**
464
     * @param string|null $governmentCode
465
     *
466
     * @return Item
467
     */
468 1
    public function setGovernmentCode(?string $governmentCode): Item
469
    {
470 1
        $this->governmentCode = $governmentCode;
471 1
        return $this;
472
    }
473
474
    /**
475
     * @return int
476
     */
477 2
    public function getType(): int
478
    {
479 2
        return $this->type;
480
    }
481
482
    /**
483
     * @param int $type
484
     *
485
     * @return Item
486
     */
487 19
    public function setType(int $type): Item
488
    {
489 19
        $this->type = $type;
490 19
        return $this;
491
    }
492
493
    /**
494
     * @return string|null
495
     */
496 3
    public function getExtCode(): ?string
497
    {
498 3
        return $this->extCode;
499
    }
500
501
    /**
502
     * @param string|null $extCode
503
     *
504
     * @return Item
505
     */
506 1
    public function setExtCode(?string $extCode): Item
507
    {
508 1
        $this->extCode = $extCode;
509 1
        return $this;
510
    }
511
512
    /**
513
     * @return string
514
     */
515 3
    public function getName(): string
516
    {
517 3
        return $this->name;
518
    }
519
520
    /**
521
     * @param string $name
522
     *
523
     * @return Item
524
     */
525 20
    public function setName(string $name): Item
526
    {
527 20
        $this->name = $name;
528 20
        return $this;
529
    }
530
}
531