|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Loevgaard\Dandomain\Pay\PaymentRequest; |
|
4
|
|
|
|
|
5
|
|
|
use Brick\Math\BigDecimal; |
|
6
|
|
|
use Loevgaard\Dandomain\Pay\PaymentRequest; |
|
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 float |
|
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 PaymentRequest |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $payment; |
|
43
|
|
|
|
|
44
|
|
|
/****************** |
|
45
|
|
|
* Helper methods * |
|
46
|
3 |
|
*****************/ |
|
47
|
|
|
|
|
48
|
3 |
|
/** |
|
49
|
|
|
* @return float |
|
50
|
|
|
*/ |
|
51
|
|
|
public function getPriceExclVat(): float |
|
52
|
|
|
{ |
|
53
|
|
|
return $this->getPrice(); |
|
54
|
|
|
} |
|
55
|
6 |
|
|
|
56
|
|
|
/** |
|
57
|
6 |
|
* @return float |
|
58
|
6 |
|
*/ |
|
59
|
|
|
public function getPriceInclVat(): float |
|
60
|
|
|
{ |
|
61
|
|
|
$price = BigDecimal::of($this->getPrice()); |
|
62
|
|
|
|
|
63
|
|
|
return $price |
|
64
|
3 |
|
->multipliedBy(100 + $this->getVat()) |
|
65
|
|
|
->dividedBy(100, 2) |
|
66
|
3 |
|
->toFloat() |
|
67
|
|
|
; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/********************* |
|
71
|
|
|
* Getters / Setters * |
|
72
|
|
|
********************/ |
|
73
|
6 |
|
|
|
74
|
|
|
/** |
|
75
|
6 |
|
* @return string |
|
76
|
6 |
|
*/ |
|
77
|
|
|
public function getProductNumber(): string |
|
78
|
|
|
{ |
|
79
|
|
|
return $this->productNumber; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
3 |
|
/** |
|
83
|
|
|
* @param string $productNumber |
|
84
|
3 |
|
* |
|
85
|
|
|
* @return PaymentLine |
|
86
|
|
|
*/ |
|
87
|
|
|
public function setProductNumber(string $productNumber): self |
|
88
|
|
|
{ |
|
89
|
|
|
$this->productNumber = $productNumber; |
|
90
|
|
|
|
|
91
|
6 |
|
return $this; |
|
92
|
|
|
} |
|
93
|
6 |
|
|
|
94
|
6 |
|
/** |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
|
|
public function getName(): string |
|
98
|
|
|
{ |
|
99
|
|
|
return $this->name; |
|
100
|
3 |
|
} |
|
101
|
|
|
|
|
102
|
3 |
|
/** |
|
103
|
|
|
* @param string $name |
|
104
|
|
|
* |
|
105
|
|
|
* @return PaymentLine |
|
106
|
|
|
*/ |
|
107
|
|
|
public function setName($name): self |
|
108
|
|
|
{ |
|
109
|
6 |
|
$this->name = $name; |
|
110
|
|
|
|
|
111
|
6 |
|
return $this; |
|
112
|
6 |
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @return int |
|
116
|
|
|
*/ |
|
117
|
|
|
public function getQuantity(): int |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->quantity; |
|
120
|
3 |
|
} |
|
121
|
|
|
|
|
122
|
3 |
|
/** |
|
123
|
|
|
* @param int $quantity |
|
124
|
|
|
* |
|
125
|
|
|
* @return PaymentLine |
|
126
|
|
|
*/ |
|
127
|
|
|
public function setQuantity($quantity): self |
|
128
|
|
|
{ |
|
129
|
6 |
|
$this->quantity = $quantity; |
|
130
|
|
|
|
|
131
|
6 |
|
return $this; |
|
132
|
6 |
|
} |
|
133
|
|
|
|
|
134
|
|
|
/** |
|
135
|
|
|
* Returns the price excl vat. |
|
136
|
|
|
* |
|
137
|
|
|
* @return float |
|
138
|
|
|
*/ |
|
139
|
|
|
public function getPrice(): float |
|
140
|
|
|
{ |
|
141
|
|
|
return $this->price; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @param float $price |
|
146
|
|
|
* |
|
147
|
3 |
|
* @return PaymentLine |
|
148
|
|
|
*/ |
|
149
|
3 |
|
public function setPrice($price): self |
|
150
|
3 |
|
{ |
|
151
|
|
|
$this->price = $price; |
|
152
|
|
|
|
|
153
|
|
|
return $this; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* Returns the VAT percentage. |
|
158
|
|
|
* |
|
159
|
|
|
* @return int |
|
160
|
|
|
*/ |
|
161
|
|
|
public function getVat(): int |
|
162
|
|
|
{ |
|
163
|
|
|
return $this->vat; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* @param int $vat |
|
168
|
|
|
* |
|
169
|
|
|
* @return PaymentLine |
|
170
|
|
|
*/ |
|
171
|
|
|
public function setVat($vat): self |
|
172
|
|
|
{ |
|
173
|
|
|
$this->vat = $vat; |
|
174
|
|
|
|
|
175
|
|
|
return $this; |
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @return PaymentRequest |
|
180
|
|
|
*/ |
|
181
|
|
|
public function getPayment(): PaymentRequest |
|
182
|
|
|
{ |
|
183
|
|
|
return $this->payment; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @param PaymentRequest $payment |
|
188
|
|
|
* |
|
189
|
|
|
* @return PaymentLine |
|
190
|
|
|
*/ |
|
191
|
|
|
public function setPayment(PaymentRequest $payment): self |
|
192
|
|
|
{ |
|
193
|
|
|
$this->payment = $payment; |
|
194
|
|
|
|
|
195
|
|
|
return $this; |
|
196
|
|
|
} |
|
197
|
|
|
} |
|
198
|
|
|
|