1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Korobovn\CloudPayments\Message\Receipts; |
4
|
|
|
|
5
|
|
|
use Korobovn\CloudPayments\Message\References\TaxationSystem; |
6
|
|
|
use Korobovn\CloudPayments\Message\References\Vat; |
7
|
|
|
use Korobovn\CloudPayments\Message\References\PaymentType; |
8
|
|
|
use Korobovn\CloudPayments\Message\References\PaymentObject; |
9
|
|
|
|
10
|
|
|
class Item |
11
|
|
|
{ |
12
|
|
|
/** |
13
|
|
|
* Product name |
14
|
|
|
* |
15
|
|
|
* @var string |
16
|
|
|
*/ |
17
|
|
|
protected $label; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Price. |
21
|
|
|
* |
22
|
|
|
* @var float |
23
|
|
|
*/ |
24
|
|
|
protected $price; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Quantity |
28
|
|
|
* |
29
|
|
|
* @var float |
30
|
|
|
*/ |
31
|
|
|
protected $quantity; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Amount. |
35
|
|
|
* |
36
|
|
|
* @var float |
37
|
|
|
*/ |
38
|
|
|
protected $amount; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* VAT rate. |
42
|
|
|
* |
43
|
|
|
* @see Vat |
44
|
|
|
* |
45
|
|
|
* @var int|null |
46
|
|
|
*/ |
47
|
|
|
protected $vat; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* A sign of a calculation method is a sign of a calculation method. |
51
|
|
|
* |
52
|
|
|
* @see PaymentType |
53
|
|
|
* |
54
|
|
|
* @var int |
55
|
|
|
*/ |
56
|
|
|
protected $method; |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Sign of the subject of calculation - a sign of the subject of goods, work, services, payment, payment, other subject of calculation. |
60
|
|
|
* |
61
|
|
|
* @see PaymentObject |
62
|
|
|
* |
63
|
|
|
* @var int |
64
|
|
|
*/ |
65
|
|
|
protected $object; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Unit of measurement. |
69
|
|
|
* |
70
|
|
|
* @var string |
71
|
|
|
*/ |
72
|
|
|
protected $measurement_unit; |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Product name. |
76
|
|
|
* |
77
|
|
|
* @param string $label |
78
|
|
|
* |
79
|
|
|
* @return Item |
80
|
|
|
*/ |
81
|
|
|
public function setLabel(string $label): self |
82
|
|
|
{ |
83
|
|
|
$this->label = $label; |
84
|
|
|
|
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Price. |
90
|
|
|
* |
91
|
|
|
* @param float $price |
92
|
|
|
* |
93
|
|
|
* @return Item |
94
|
|
|
*/ |
95
|
|
|
public function setPrice(float $price): self |
96
|
|
|
{ |
97
|
|
|
$this->price = $price; |
98
|
|
|
|
99
|
|
|
return $this; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Quantity. |
104
|
|
|
* |
105
|
|
|
* @param float $quantity |
106
|
|
|
* |
107
|
|
|
* @return Item |
108
|
|
|
*/ |
109
|
|
|
public function setQuantity(float $quantity): self |
110
|
|
|
{ |
111
|
|
|
$this->quantity = $quantity; |
112
|
|
|
|
113
|
|
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
/** |
117
|
|
|
* Amount. |
118
|
|
|
* |
119
|
|
|
* @param float $amount |
120
|
|
|
* |
121
|
|
|
* @return Item |
122
|
|
|
*/ |
123
|
|
|
public function setAmount(float $amount): self |
124
|
|
|
{ |
125
|
|
|
$this->amount = $amount; |
126
|
|
|
|
127
|
|
|
return $this; |
128
|
|
|
} |
129
|
|
|
|
130
|
|
|
/** |
131
|
|
|
* VAT rate. |
132
|
|
|
* |
133
|
|
|
* @param int|null $vat |
134
|
|
|
* |
135
|
|
|
* @return Item |
136
|
|
|
*/ |
137
|
|
|
public function setVat(?int $vat): self |
138
|
|
|
{ |
139
|
|
|
$this->vat = $vat; |
140
|
|
|
|
141
|
|
|
return $this; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* A sign of a calculation method is a sign of a calculation method. |
146
|
|
|
* |
147
|
|
|
* @param int $method |
148
|
|
|
* |
149
|
|
|
* @see PaymentType |
150
|
|
|
* |
151
|
|
|
* @return Item |
152
|
|
|
*/ |
153
|
|
|
public function setMethod(int $method): self |
154
|
|
|
{ |
155
|
|
|
$this->method = $method; |
156
|
|
|
|
157
|
|
|
return $this; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* Sign of the subject of calculation - a sign of the subject of goods, work, services, payment, payment, other subject of calculation. |
162
|
|
|
* |
163
|
|
|
* @param int $object |
164
|
|
|
* |
165
|
|
|
* @return Item |
166
|
|
|
*/ |
167
|
|
|
public function setObject(int $object): self |
168
|
|
|
{ |
169
|
|
|
$this->object = $object; |
170
|
|
|
|
171
|
|
|
return $this; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* Unit of measurement. |
176
|
|
|
* |
177
|
|
|
* @param string $measurement_unit |
178
|
|
|
* |
179
|
|
|
* @return Item |
180
|
|
|
*/ |
181
|
|
|
public function setMeasurementUnit(string $measurement_unit): self |
182
|
|
|
{ |
183
|
|
|
$this->measurement_unit = $measurement_unit; |
184
|
|
|
|
185
|
|
|
return $this; |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
/** |
189
|
|
|
* @return array |
190
|
|
|
*/ |
191
|
|
|
public function toArray(): array |
192
|
|
|
{ |
193
|
|
|
return \array_filter([ |
194
|
|
|
'label' => $this->label, |
195
|
|
|
'price' => $this->price, |
196
|
|
|
'quantity' => $this->quantity, |
197
|
|
|
'amount' => $this->amount, |
198
|
|
|
'vat' => $this->vat, |
199
|
|
|
'method' => $this->method, |
200
|
|
|
'object' => $this->object, |
201
|
|
|
'measurementUnit' => $this->measurement_unit, |
202
|
|
|
]); |
203
|
|
|
} |
204
|
|
|
} |
205
|
|
|
|