1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of RussianPost SDK package. |
5
|
|
|
* |
6
|
|
|
* © Appwilio (http://appwilio.com), greabock (https://github.com/greabock), JhaoDa (https://github.com/jhaoda) |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
declare(strict_types = 1); |
13
|
|
|
|
14
|
|
|
namespace Appwilio\RussianPostSDK\Dispatching\Endpoints\Orders\Entites; |
15
|
|
|
|
16
|
|
|
use Appwilio\RussianPostSDK\Dispatching\Contracts\Arrayable; |
17
|
|
|
|
18
|
|
|
final class OrderItem implements Arrayable |
19
|
|
|
{ |
20
|
|
|
public const VAT_NO = -1; |
21
|
|
|
public const VAT_0 = 0; |
22
|
|
|
public const VAT_10 = 10; |
23
|
|
|
public const VAT_20 = 20; |
24
|
|
|
|
25
|
|
|
/** @var array */ |
26
|
|
|
private $data; |
27
|
|
|
|
28
|
|
|
public static function create( |
29
|
|
|
string $title, |
30
|
|
|
int $quantity, |
31
|
|
|
int $price, |
32
|
|
|
?string $code = null, |
33
|
|
|
?string $article = null |
34
|
|
|
): self { |
35
|
|
|
return new self(...\func_get_args()); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function __construct(string $title, int $quantity, int $price, ?string $code = null, ?string $article = null) |
39
|
|
|
{ |
40
|
|
|
$this->data['description'] = $title; |
41
|
|
|
$this->data['quantity'] = $quantity; |
42
|
|
|
$this->data['price'] = $price; |
43
|
|
|
$this->data['code'] = $code; |
44
|
|
|
$this->data['item-number'] = $article; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function bySupplier(string $inn, string $name, string $phone) |
48
|
|
|
{ |
49
|
|
|
$this->data['supplier-inn'] = $inn; |
50
|
|
|
$this->data['supplier-name'] = $name; |
51
|
|
|
$this->data['supplier-phone'] = $phone; |
52
|
|
|
|
53
|
|
|
return $this; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
public function withVAT(int $vat) |
57
|
|
|
{ |
58
|
|
|
$this->data['vat-rate'] = $vat; |
59
|
|
|
|
60
|
|
|
return $this; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
public function withInshurance(int $value) |
64
|
|
|
{ |
65
|
|
|
$this->data['insr-value'] = $value; |
66
|
|
|
|
67
|
|
|
return $this; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function toArray(): array |
71
|
|
|
{ |
72
|
|
|
return $this->data; |
73
|
|
|
} |
74
|
|
|
} |
75
|
|
|
|