1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Loevgaard\Dandomain\Pay\Model; |
4
|
|
|
|
5
|
|
|
use Brick\Math\BigDecimal; |
6
|
|
|
use Money\Money; |
7
|
|
|
|
8
|
|
|
class PaymentLine |
9
|
|
|
{ |
10
|
|
|
/** |
11
|
|
|
* @var string |
12
|
|
|
*/ |
13
|
|
|
protected $productNumber; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @var string |
17
|
|
|
*/ |
18
|
|
|
protected $name; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* @var int |
22
|
|
|
*/ |
23
|
|
|
protected $quantity; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* The price excl vat. |
27
|
|
|
* |
28
|
|
|
* @var Money |
29
|
|
|
*/ |
30
|
|
|
protected $price; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* This is the VAT percentage, i.e. 25 for Denmark. |
34
|
|
|
* |
35
|
|
|
* @var int |
36
|
|
|
*/ |
37
|
|
|
protected $vat; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var Payment |
41
|
|
|
*/ |
42
|
|
|
protected $payment; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param string $productNumber |
46
|
|
|
* @param string $name |
47
|
|
|
* @param int $quantity |
48
|
|
|
* @param Money $price |
49
|
|
|
* @param int $vat |
50
|
|
|
*/ |
51
|
9 |
|
public function __construct(string $productNumber, string $name, int $quantity, Money $price, int $vat) |
52
|
|
|
{ |
53
|
9 |
|
$this->setProductNumber($productNumber) |
54
|
9 |
|
->setName($name) |
55
|
9 |
|
->setQuantity($quantity) |
56
|
9 |
|
->setPrice($price) |
57
|
9 |
|
->setVat($vat); |
58
|
9 |
|
} |
59
|
|
|
|
60
|
|
|
/****************** |
61
|
|
|
* Helper methods * |
62
|
|
|
*****************/ |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return Money |
66
|
|
|
*/ |
67
|
3 |
|
public function getPriceExclVat(): Money |
68
|
|
|
{ |
69
|
3 |
|
return $this->getPrice(); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return Money |
74
|
|
|
*/ |
75
|
3 |
|
public function getPriceInclVat(): Money |
76
|
|
|
{ |
77
|
3 |
|
return $this->price |
78
|
3 |
|
->multiply(100 + $this->getVat()) |
79
|
3 |
|
->divide(100) |
80
|
|
|
; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
/********************* |
84
|
|
|
* Getters / Setters * |
85
|
|
|
********************/ |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @return string |
89
|
|
|
*/ |
90
|
6 |
|
public function getProductNumber(): string |
91
|
|
|
{ |
92
|
6 |
|
return $this->productNumber; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* @param string $productNumber |
97
|
|
|
* |
98
|
|
|
* @return PaymentLine |
99
|
|
|
*/ |
100
|
9 |
|
public function setProductNumber(string $productNumber): self |
101
|
|
|
{ |
102
|
9 |
|
$this->productNumber = $productNumber; |
103
|
|
|
|
104
|
9 |
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return string |
109
|
|
|
*/ |
110
|
6 |
|
public function getName(): string |
111
|
|
|
{ |
112
|
6 |
|
return $this->name; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* @param string $name |
117
|
|
|
* |
118
|
|
|
* @return PaymentLine |
119
|
|
|
*/ |
120
|
9 |
|
public function setName(string $name): self |
121
|
|
|
{ |
122
|
9 |
|
$this->name = $name; |
123
|
|
|
|
124
|
9 |
|
return $this; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* @return int |
129
|
|
|
*/ |
130
|
6 |
|
public function getQuantity(): int |
131
|
|
|
{ |
132
|
6 |
|
return $this->quantity; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* @param int $quantity |
137
|
|
|
* |
138
|
|
|
* @return PaymentLine |
139
|
|
|
*/ |
140
|
9 |
|
public function setQuantity(int $quantity): self |
141
|
|
|
{ |
142
|
9 |
|
$this->quantity = $quantity; |
143
|
|
|
|
144
|
9 |
|
return $this; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Returns the price excl vat. |
149
|
|
|
* |
150
|
|
|
* @return Money |
151
|
|
|
*/ |
152
|
6 |
|
public function getPrice(): Money |
153
|
|
|
{ |
154
|
6 |
|
return $this->price; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* @param Money $price |
159
|
|
|
* |
160
|
|
|
* @return PaymentLine |
161
|
|
|
*/ |
162
|
9 |
|
public function setPrice(Money $price): self |
163
|
|
|
{ |
164
|
9 |
|
$this->price = $price; |
165
|
|
|
|
166
|
9 |
|
return $this; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* Returns the VAT percentage. |
171
|
|
|
* |
172
|
|
|
* @return int |
173
|
|
|
*/ |
174
|
6 |
|
public function getVat(): int |
175
|
|
|
{ |
176
|
6 |
|
return $this->vat; |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* @param int $vat |
181
|
|
|
* |
182
|
|
|
* @return PaymentLine |
183
|
|
|
*/ |
184
|
9 |
|
public function setVat(int $vat): self |
185
|
|
|
{ |
186
|
9 |
|
$this->vat = $vat; |
187
|
|
|
|
188
|
9 |
|
return $this; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @return Payment |
193
|
|
|
*/ |
194
|
3 |
|
public function getPayment(): Payment |
195
|
|
|
{ |
196
|
3 |
|
return $this->payment; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
/** |
200
|
|
|
* @param Payment $payment |
201
|
|
|
* |
202
|
|
|
* @return PaymentLine |
203
|
|
|
*/ |
204
|
6 |
|
public function setPayment(Payment $payment): self |
205
|
|
|
{ |
206
|
6 |
|
$this->payment = $payment; |
207
|
|
|
|
208
|
6 |
|
return $this; |
209
|
|
|
} |
210
|
|
|
} |
211
|
|
|
|