Passed
Push — main ( 48fe19...91a3be )
by Iain
16:03
created

Receipt::setCustomer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright Iain Cambridge 2020-2023.
7
 *
8
 * Use of this software is governed by the Business Source License included in the LICENSE file and at https://getparthenon.com/docs/next/license.
9
 *
10
 * Change Date: TBD ( 3 years after 2.2.0 release )
11
 *
12
 * On the date above, in accordance with the Business Source License, use of this software will be governed by the open source license specified in the LICENSE file.
13
 */
14
15
namespace Parthenon\Billing\Entity;
16
17
use Brick\Money\Money;
18
use Doctrine\Common\Collections\ArrayCollection;
19
use Doctrine\Common\Collections\Collection;
20
use Parthenon\Common\Address;
21
22
class Receipt
23
{
24
    private $id;
25
26
    private string $invoiceNumber;
27
28
    private bool $valid;
29
30
    private Address $billerAddress;
31
32
    private Address $payeeAddress;
33
34
    private CustomerInterface $customer;
35
36
    private array|Collection $payments;
37
38
    private array|Collection $subscriptions;
39
40
    private array|Collection $lines;
41
42
    private ?string $comment;
43
44
    private string $currency;
45
46
    private int $total;
47
48
    private int $subTotal;
49
50
    private int $vatTotal;
51
52
    private \DateTimeInterface $createdAt;
53
54
    public function __construct()
55
    {
56
        $this->payments = new ArrayCollection([]);
57
        $this->subscriptions = new ArrayCollection([]);
58
        $this->lines = new ArrayCollection([]);
59
    }
60
61
    public function getId()
62
    {
63
        return $this->id;
64
    }
65
66
    public function setId($id): void
67
    {
68
        $this->id = $id;
69
    }
70
71
    public function getInvoiceNumber(): string
72
    {
73
        return $this->invoiceNumber;
74
    }
75
76
    public function setInvoiceNumber(string $invoiceNumber): void
77
    {
78
        $this->invoiceNumber = $invoiceNumber;
79
    }
80
81
    public function isValid(): bool
82
    {
83
        return $this->valid;
84
    }
85
86
    public function setValid(bool $valid): void
87
    {
88
        $this->valid = $valid;
89
    }
90
91
    public function getBillerAddress(): Address
92
    {
93
        return $this->billerAddress;
94
    }
95
96
    public function setBillerAddress(Address $billerAddress): void
97
    {
98
        $this->billerAddress = $billerAddress;
99
    }
100
101
    public function getPayeeAddress(): Address
102
    {
103
        return $this->payeeAddress;
104
    }
105
106
    public function setPayeeAddress(Address $payeeAddress): void
107
    {
108
        $this->payeeAddress = $payeeAddress;
109
    }
110
111
    public function getCustomer(): CustomerInterface
112
    {
113
        return $this->customer;
114
    }
115
116
    public function setCustomer(CustomerInterface $customer): void
117
    {
118
        $this->customer = $customer;
119
    }
120
121
    public function addPayment(Payment $payment): void
122
    {
123
        $this->payments->add($payment);
124
    }
125
126
    /**
127
     * @return Collection|Payment[]
128
     */
129
    public function getPayments(): Collection|array
130
    {
131
        return $this->payments;
132
    }
133
134
    public function setPayments(Collection|array $payments): void
135
    {
136
        $this->payments = $payments;
137
    }
138
139
    public function getComment(): ?string
140
    {
141
        return $this->comment;
142
    }
143
144
    public function setComment(?string $comment): void
145
    {
146
        $this->comment = $comment;
147
    }
148
149
    public function getCurrency(): string
150
    {
151
        return $this->currency;
152
    }
153
154
    public function setCurrency(string $currency): void
155
    {
156
        $this->currency = $currency;
157
    }
158
159
    public function getTotal(): int
160
    {
161
        return $this->total;
162
    }
163
164
    public function setTotal(int $total): void
165
    {
166
        $this->total = $total;
167
    }
168
169
    public function getSubTotal(): int
170
    {
171
        return $this->subTotal;
172
    }
173
174
    public function setSubTotal(int $subTotal): void
175
    {
176
        $this->subTotal = $subTotal;
177
    }
178
179
    public function getVatTotal(): int
180
    {
181
        return $this->vatTotal;
182
    }
183
184
    public function setVatTotal(int $vatTotal): void
185
    {
186
        $this->vatTotal = $vatTotal;
187
    }
188
189
    public function getCreatedAt(): \DateTimeInterface
190
    {
191
        return $this->createdAt;
192
    }
193
194
    public function setCreatedAt(\DateTimeInterface $createdAt): void
195
    {
196
        $this->createdAt = $createdAt;
197
    }
198
199
    /**
200
     * @return Collection|ReceiptLine[]
201
     */
202
    public function getLines(): Collection|array
203
    {
204
        return $this->lines;
205
    }
206
207
    public function setLines(Collection|array $lines): void
208
    {
209
        $this->lines = $lines;
210
    }
211
212
    /**
213
     * @return Subscription[]|Collection
214
     */
215
    public function getSubscriptions(): Collection|array
216
    {
217
        return $this->subscriptions;
218
    }
219
220
    public function setSubscriptions(Collection|array $subscriptions): void
221
    {
222
        $this->subscriptions = $subscriptions;
223
    }
224
225
    public function getTotalMoney(): Money
226
    {
227
        return Money::ofMinor($this->total, strtoupper($this->currency));
228
    }
229
230
    public function getVatTotalMoney(): Money
231
    {
232
        return Money::ofMinor($this->vatTotal, strtoupper($this->currency));
233
    }
234
235
    public function getSubTotalMoney(): Money
236
    {
237
        return Money::ofMinor($this->subTotal, strtoupper($this->currency));
238
    }
239
}
240