|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Loevgaard\DandomainAltapayBundle\Entity; |
|
4
|
|
|
|
|
5
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
6
|
|
|
use Loevgaard\Dandomain\Pay\Model\PaymentLine as BasePaymentLine; |
|
7
|
|
|
use Loevgaard\Dandomain\Pay\Model\PaymentLine as DandomainPaymentLine; |
|
8
|
|
|
use Money\Currency; |
|
9
|
|
|
use Money\Money; |
|
10
|
|
|
use Symfony\Component\Validator\Constraints as Assert; |
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* @ORM\Table(name="dandomain_altapay_payment_lines") |
|
14
|
|
|
* @ORM\Entity() |
|
15
|
|
|
*/ |
|
16
|
|
|
class PaymentLine extends BasePaymentLine |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* @var int |
|
20
|
|
|
* |
|
21
|
|
|
* @ORM\Id |
|
22
|
|
|
* @ORM\Column(name="id", type="integer") |
|
23
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $id; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @Assert\NotBlank() |
|
29
|
|
|
* @Assert\Length(max="191") |
|
30
|
|
|
* |
|
31
|
|
|
* @ORM\Column(type="string", length=191) |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $productNumber; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @Assert\NotBlank() |
|
37
|
|
|
* @Assert\Length(max="191") |
|
38
|
|
|
* |
|
39
|
|
|
* @ORM\Column(type="string", length=191) |
|
40
|
|
|
*/ |
|
41
|
|
|
protected $name; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @Assert\NotBlank() |
|
45
|
|
|
* @Assert\GreaterThan(0) |
|
46
|
|
|
* |
|
47
|
|
|
* @ORM\Column(type="integer") |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $quantity; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* @Assert\NotBlank() |
|
53
|
|
|
* |
|
54
|
|
|
* @ORM\Column(type="integer") |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $priceAmount; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @Assert\NotBlank() |
|
60
|
|
|
* |
|
61
|
|
|
* @ORM\Column(type="string") |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $priceCurrency; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* @Assert\NotBlank() |
|
67
|
|
|
* @Assert\GreaterThanOrEqual(0) |
|
68
|
|
|
* |
|
69
|
|
|
* @ORM\Column(type="integer") |
|
70
|
|
|
*/ |
|
71
|
|
|
protected $vat; |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @Assert\NotNull() |
|
75
|
|
|
* |
|
76
|
|
|
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE") |
|
77
|
|
|
* @ORM\ManyToOne(targetEntity="Payment", inversedBy="paymentLines") |
|
78
|
|
|
*/ |
|
79
|
|
|
protected $payment; |
|
80
|
|
|
|
|
81
|
|
|
/** |
|
82
|
|
|
* @return int |
|
83
|
|
|
*/ |
|
84
|
|
|
public function getId(): ?int |
|
85
|
|
|
{ |
|
86
|
|
|
return $this->id; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* @param mixed $id |
|
91
|
|
|
* |
|
92
|
|
|
* @return PaymentLine |
|
93
|
|
|
*/ |
|
94
|
|
|
public function setId($id): self |
|
95
|
|
|
{ |
|
96
|
|
|
$this->id = $id; |
|
97
|
|
|
|
|
98
|
|
|
return $this; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
public function setPrice(Money $price): DandomainPaymentLine |
|
102
|
|
|
{ |
|
103
|
|
|
parent::setPrice($price); |
|
104
|
|
|
|
|
105
|
|
|
$this->priceAmount = $price->getAmount(); |
|
106
|
|
|
$this->priceCurrency = $price->getCurrency()->getCode(); |
|
107
|
|
|
|
|
108
|
|
|
return $this; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
public function getPrice(): Money |
|
112
|
|
|
{ |
|
113
|
|
|
if (!$this->priceCurrency) { |
|
114
|
|
|
return null; |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
$amount = $this->priceAmount; |
|
118
|
|
|
if (!$amount) { |
|
119
|
|
|
$amount = 0; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
return new Money($amount, new Currency($this->priceCurrency)); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
|