1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file has been created by developers from BitBag. |
5
|
|
|
* Feel free to contact us once you face any issues or want to start |
6
|
|
|
* another great project. |
7
|
|
|
* You can find more information about us on https://bitbag.shop and write us |
8
|
|
|
* an email on [email protected]. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
declare(strict_types=1); |
12
|
|
|
|
13
|
|
|
namespace BitBag\SyliusMolliePlugin\DTO; |
14
|
|
|
|
15
|
|
|
final class PartialRefundItem |
16
|
|
|
{ |
17
|
|
|
/** @var int */ |
18
|
|
|
private $id; |
19
|
|
|
|
20
|
|
|
/** @var string */ |
21
|
|
|
private $type; |
22
|
|
|
|
23
|
|
|
/** @var int */ |
24
|
|
|
private $amountTotal = 0; |
25
|
|
|
|
26
|
|
|
/** @var int */ |
27
|
|
|
private $amountRefunded = 0; |
28
|
|
|
|
29
|
|
|
/** @var int */ |
30
|
|
|
private $quantity = 1; |
31
|
|
|
|
32
|
|
|
/** @var int */ |
33
|
|
|
private $amountToRefund = 0; |
34
|
|
|
|
35
|
|
|
public function getId(): int |
36
|
|
|
{ |
37
|
|
|
return $this->id; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
public function setId(int $id): void |
41
|
|
|
{ |
42
|
|
|
$this->id = $id; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function getType(): string |
46
|
|
|
{ |
47
|
|
|
return $this->type; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
public function setType(string $type): void |
51
|
|
|
{ |
52
|
|
|
$this->type = $type; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public function getAmountTotal(): int |
56
|
|
|
{ |
57
|
|
|
return $this->amountTotal; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function setAmountTotal(int $amountTotal): void |
61
|
|
|
{ |
62
|
|
|
$this->amountTotal = $amountTotal; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getAmountRefunded(): int |
66
|
|
|
{ |
67
|
|
|
return $this->amountRefunded; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setAmountRefunded(int $amountRefunded): void |
71
|
|
|
{ |
72
|
|
|
$this->amountRefunded += $amountRefunded; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
public function getQuantity(): int |
76
|
|
|
{ |
77
|
|
|
return $this->quantity; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
public function setQuantity(int $quantity): void |
81
|
|
|
{ |
82
|
|
|
$this->quantity = $quantity; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function getAvailableAmountToRefund(): int |
86
|
|
|
{ |
87
|
|
|
return $this->getAmountTotal() - $this->getAmountRefunded() - $this->getAmountToRefund(); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function setAmountToRefund(int $amount): int |
91
|
|
|
{ |
92
|
|
|
$value = $this->getAvailableAmountToRefund() - $amount; |
93
|
|
|
|
94
|
|
|
if ($value < 0) { |
95
|
|
|
$this->amountToRefund = $this->getAvailableAmountToRefund(); |
96
|
|
|
|
97
|
|
|
return abs($value); |
|
|
|
|
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
$this->amountToRefund = $amount; |
101
|
|
|
|
102
|
|
|
return 0; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function getAmountToRefund() |
106
|
|
|
{ |
107
|
|
|
return $this->amountToRefund; |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|