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 Symfony\Component\Validator\Constraints as Assert; |
8
|
|
|
use Loevgaard\Dandomain\Pay\Model\PaymentLine as DandomainPaymentLine; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @ORM\Table(name="dandomain_altapay_payment_lines") |
12
|
|
|
* @ORM\Entity() |
13
|
|
|
*/ |
14
|
|
|
class PaymentLine extends BasePaymentLine |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* @var int |
18
|
|
|
* |
19
|
|
|
* @ORM\Id |
20
|
|
|
* @ORM\Column(name="id", type="integer") |
21
|
|
|
* @ORM\GeneratedValue(strategy="AUTO") |
22
|
|
|
*/ |
23
|
|
|
protected $id; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @Assert\NotBlank() |
27
|
|
|
* @Assert\Length(max="191") |
28
|
|
|
* |
29
|
|
|
* @ORM\Column(type="string", length=191) |
30
|
|
|
*/ |
31
|
|
|
protected $productNumber; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @Assert\NotBlank() |
35
|
|
|
* @Assert\Length(max="191") |
36
|
|
|
* |
37
|
|
|
* @ORM\Column(type="string", length=191) |
38
|
|
|
*/ |
39
|
|
|
protected $name; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @Assert\NotBlank() |
43
|
|
|
* @Assert\GreaterThan(0) |
44
|
|
|
* |
45
|
|
|
* @ORM\Column(type="integer") |
46
|
|
|
*/ |
47
|
|
|
protected $quantity; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @Assert\NotBlank() |
51
|
|
|
* |
52
|
|
|
* @ORM\Column(type="decimal", precision=12, scale=2) |
53
|
|
|
*/ |
54
|
|
|
protected $price; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @Assert\NotBlank() |
58
|
|
|
* @Assert\GreaterThanOrEqual(0) |
59
|
|
|
* |
60
|
|
|
* @ORM\Column(type="integer") |
61
|
|
|
*/ |
62
|
|
|
protected $vat; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @Assert\NotNull() |
66
|
|
|
* |
67
|
|
|
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE") |
68
|
|
|
* @ORM\ManyToOne(targetEntity="Payment", inversedBy="paymentLines") |
69
|
|
|
*/ |
70
|
|
|
protected $payment; |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* This will transform a Dandomain Payment Line (parent) to a Payment Line (child). |
74
|
|
|
* |
75
|
|
|
* @param DandomainPaymentLine $dandomainPaymentLine |
76
|
|
|
* |
77
|
|
|
* @return PaymentLine |
78
|
|
|
*/ |
79
|
|
|
public static function createFromDandomainPaymentLine(DandomainPaymentLine $dandomainPaymentLine) |
80
|
|
|
{ |
81
|
|
|
$paymentLine = new self(); |
82
|
|
|
|
83
|
|
|
$methods = get_class_methods($dandomainPaymentLine); |
84
|
|
|
foreach ($methods as $method) { |
85
|
|
|
if ('get' === substr($method, 0, 3)) { |
86
|
|
|
$val = $dandomainPaymentLine->{$method}(); |
87
|
|
|
$property = substr($method, 3); |
88
|
|
|
} elseif ('is' === substr($method, 0, 2)) { |
89
|
|
|
$val = $dandomainPaymentLine->{$method}(); |
90
|
|
|
$property = substr($method, 2); |
91
|
|
|
} else { |
92
|
|
|
continue; |
93
|
|
|
} |
94
|
|
|
if (!is_scalar($val)) { |
95
|
|
|
continue; |
96
|
|
|
} |
97
|
|
|
$setter = 'set'.$property; |
98
|
|
|
if (method_exists($paymentLine, $setter)) { |
99
|
|
|
$paymentLine->{$setter}($val); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
return $paymentLine; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @return int |
107
|
|
|
*/ |
108
|
|
|
public function getId() : ?int |
109
|
|
|
{ |
110
|
|
|
return $this->id; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @param mixed $id |
115
|
|
|
* @return PaymentLine |
116
|
|
|
*/ |
117
|
|
|
public function setId($id) : self |
118
|
|
|
{ |
119
|
|
|
$this->id = $id; |
120
|
|
|
return $this; |
121
|
|
|
} |
122
|
|
|
} |
123
|
|
|
|