1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* BillLine.php |
4
|
|
|
* Copyright (c) 2017 [email protected] |
5
|
|
|
* |
6
|
|
|
* This file is part of Firefly III. |
7
|
|
|
* |
8
|
|
|
* Firefly III is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU General Public License as published by |
10
|
|
|
* the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
* (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* Firefly III is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU General Public License |
19
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
*/ |
21
|
|
|
declare(strict_types=1); |
22
|
|
|
|
23
|
|
|
namespace FireflyIII\Helpers\Collection; |
24
|
|
|
|
25
|
|
|
use Carbon\Carbon; |
26
|
|
|
use FireflyIII\Models\Bill as BillModel; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Class BillLine. |
30
|
|
|
*/ |
31
|
|
|
class BillLine |
32
|
|
|
{ |
33
|
|
|
/** @var string */ |
34
|
|
|
protected $amount; |
35
|
|
|
/** @var BillModel */ |
36
|
|
|
protected $bill; |
37
|
|
|
/** @var bool */ |
38
|
|
|
protected $hit; |
39
|
|
|
/** @var string */ |
40
|
|
|
protected $max; |
41
|
|
|
/** @var string */ |
42
|
|
|
protected $min; |
43
|
|
|
/** @var Carbon */ |
44
|
|
|
private $lastHitDate; |
45
|
|
|
/** @var Carbon */ |
46
|
|
|
private $payDate; |
47
|
|
|
/** @var Carbon */ |
48
|
|
|
private $endOfPayDate; |
49
|
|
|
/** @var int */ |
50
|
|
|
private $transactionJournalId; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @return Carbon |
54
|
|
|
*/ |
55
|
|
|
public function getPayDate(): Carbon |
56
|
|
|
{ |
57
|
|
|
return $this->payDate; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return Carbon |
62
|
|
|
*/ |
63
|
|
|
public function getEndOfPayDate(): Carbon |
64
|
|
|
{ |
65
|
|
|
return $this->endOfPayDate; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @param Carbon $endOfPayDate |
70
|
|
|
*/ |
71
|
|
|
public function setEndOfPayDate(Carbon $endOfPayDate): void |
72
|
|
|
{ |
73
|
|
|
$this->endOfPayDate = $endOfPayDate; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* BillLine constructor. |
80
|
|
|
*/ |
81
|
|
|
public function __construct() |
82
|
|
|
{ |
83
|
|
|
$this->lastHitDate = new Carbon; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return string |
88
|
|
|
*/ |
89
|
|
|
public function getAmount(): string |
90
|
|
|
{ |
91
|
|
|
return $this->amount ?? '0'; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* @param string $amount |
96
|
|
|
*/ |
97
|
|
|
public function setAmount(string $amount) |
98
|
|
|
{ |
99
|
|
|
$this->amount = $amount; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @return BillModel |
104
|
|
|
*/ |
105
|
|
|
public function getBill(): BillModel |
106
|
|
|
{ |
107
|
|
|
return $this->bill; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @param BillModel $bill |
112
|
|
|
*/ |
113
|
|
|
public function setBill(BillModel $bill) |
114
|
|
|
{ |
115
|
|
|
$this->bill = $bill; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return Carbon |
120
|
|
|
*/ |
121
|
|
|
public function getLastHitDate(): Carbon |
122
|
|
|
{ |
123
|
|
|
return $this->lastHitDate; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param Carbon $lastHitDate |
128
|
|
|
*/ |
129
|
|
|
public function setLastHitDate(Carbon $lastHitDate) |
130
|
|
|
{ |
131
|
|
|
$this->lastHitDate = $lastHitDate; |
132
|
|
|
} |
133
|
|
|
|
134
|
|
|
/** |
135
|
|
|
* @return string |
136
|
|
|
*/ |
137
|
|
|
public function getMax(): string |
138
|
|
|
{ |
139
|
|
|
return $this->max; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @param string $max |
144
|
|
|
*/ |
145
|
|
|
public function setMax(string $max) |
146
|
|
|
{ |
147
|
|
|
$this->max = $max; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return string |
152
|
|
|
*/ |
153
|
|
|
public function getMin(): string |
154
|
|
|
{ |
155
|
|
|
return $this->min; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
/** |
159
|
|
|
* @param string $min |
160
|
|
|
*/ |
161
|
|
|
public function setMin(string $min) |
162
|
|
|
{ |
163
|
|
|
$this->min = $min; |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* @return int |
168
|
|
|
*/ |
169
|
|
|
public function getTransactionJournalId(): int |
170
|
|
|
{ |
171
|
|
|
return $this->transactionJournalId ?? 0; |
172
|
|
|
} |
173
|
|
|
|
174
|
|
|
/** |
175
|
|
|
* @param int $transactionJournalId |
176
|
|
|
*/ |
177
|
|
|
public function setTransactionJournalId(int $transactionJournalId) |
178
|
|
|
{ |
179
|
|
|
$this->transactionJournalId = $transactionJournalId; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @return bool |
184
|
|
|
*/ |
185
|
|
|
public function isActive(): bool |
186
|
|
|
{ |
187
|
|
|
return 1 === intval($this->bill->active); |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
/** |
191
|
|
|
* @return bool |
192
|
|
|
*/ |
193
|
|
|
public function isHit(): bool |
194
|
|
|
{ |
195
|
|
|
return $this->hit; |
196
|
|
|
} |
197
|
|
|
|
198
|
|
|
/** |
199
|
|
|
* @param bool $hit |
200
|
|
|
*/ |
201
|
|
|
public function setHit(bool $hit) |
202
|
|
|
{ |
203
|
|
|
$this->hit = $hit; |
204
|
|
|
} |
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* @param Carbon $payDate |
208
|
|
|
*/ |
209
|
|
|
public function setPayDate(Carbon $payDate): void |
210
|
|
|
{ |
211
|
|
|
$this->payDate = $payDate; |
212
|
|
|
} |
213
|
|
|
} |
214
|
|
|
|