2015-05-17 10:54:13 -05:00
|
|
|
<?php
|
2016-05-20 05:27:31 -05:00
|
|
|
/**
|
|
|
|
* BillLine.php
|
2017-10-21 01:40:00 -05:00
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
2016-05-20 05:27:31 -05:00
|
|
|
*
|
2017-10-21 01:40:00 -05:00
|
|
|
* This file is part of Firefly III.
|
2016-10-04 23:52:15 -05:00
|
|
|
*
|
2017-10-21 01:40:00 -05:00
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 07:41:58 -06:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2016-05-20 05:27:31 -05:00
|
|
|
*/
|
2017-04-09 00:44:22 -05:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2015-05-17 10:54:13 -05:00
|
|
|
namespace FireflyIII\Helpers\Collection;
|
|
|
|
|
2016-11-20 05:08:43 -06:00
|
|
|
use Carbon\Carbon;
|
2015-05-17 10:54:13 -05:00
|
|
|
use FireflyIII\Models\Bill as BillModel;
|
|
|
|
|
|
|
|
/**
|
2017-11-15 05:25:49 -06:00
|
|
|
* Class BillLine.
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
|
|
|
class BillLine
|
|
|
|
{
|
2017-11-15 05:25:49 -06:00
|
|
|
/** @var string */
|
2015-05-17 10:54:13 -05:00
|
|
|
protected $amount;
|
2017-11-15 05:25:49 -06:00
|
|
|
/** @var BillModel */
|
2015-05-17 10:54:13 -05:00
|
|
|
protected $bill;
|
2017-11-15 05:25:49 -06:00
|
|
|
/** @var bool */
|
2015-05-17 10:54:13 -05:00
|
|
|
protected $hit;
|
2017-11-15 05:25:49 -06:00
|
|
|
/** @var string */
|
2015-05-17 10:54:13 -05:00
|
|
|
protected $max;
|
2017-11-15 05:25:49 -06:00
|
|
|
/** @var string */
|
2015-05-17 10:54:13 -05:00
|
|
|
protected $min;
|
2017-11-15 05:25:49 -06:00
|
|
|
/** @var Carbon */
|
2017-12-22 11:32:43 -06:00
|
|
|
private $endOfPayDate;
|
|
|
|
/** @var Carbon */
|
2016-11-20 05:08:43 -06:00
|
|
|
private $lastHitDate;
|
2017-12-02 00:10:36 -06:00
|
|
|
/** @var Carbon */
|
|
|
|
private $payDate;
|
2017-11-15 05:25:49 -06:00
|
|
|
/** @var int */
|
2016-02-06 13:17:55 -06:00
|
|
|
private $transactionJournalId;
|
|
|
|
|
2016-11-20 05:08:43 -06:00
|
|
|
/**
|
|
|
|
* BillLine constructor.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->lastHitDate = new Carbon;
|
|
|
|
}
|
|
|
|
|
2015-05-17 10:54:13 -05:00
|
|
|
/**
|
2015-06-14 01:22:02 -05:00
|
|
|
* @return string
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
2016-02-18 03:04:26 -06:00
|
|
|
public function getAmount(): string
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
2016-02-18 03:06:34 -06:00
|
|
|
return $this->amount ?? '0';
|
2015-05-17 10:54:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-06-14 01:22:02 -05:00
|
|
|
* @param string $amount
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
2018-07-07 14:17:46 -05:00
|
|
|
public function setAmount(string $amount): void
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
|
|
|
$this->amount = $amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return BillModel
|
|
|
|
*/
|
2016-02-18 03:04:26 -06:00
|
|
|
public function getBill(): BillModel
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
|
|
|
return $this->bill;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param BillModel $bill
|
|
|
|
*/
|
2018-07-07 14:17:46 -05:00
|
|
|
public function setBill(BillModel $bill): void
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
|
|
|
$this->bill = $bill;
|
|
|
|
}
|
|
|
|
|
2017-12-22 11:32:43 -06:00
|
|
|
/**
|
|
|
|
* @return Carbon
|
|
|
|
*/
|
|
|
|
public function getEndOfPayDate(): Carbon
|
|
|
|
{
|
|
|
|
return $this->endOfPayDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Carbon $endOfPayDate
|
|
|
|
*/
|
|
|
|
public function setEndOfPayDate(Carbon $endOfPayDate): void
|
|
|
|
{
|
|
|
|
$this->endOfPayDate = $endOfPayDate;
|
|
|
|
}
|
|
|
|
|
2016-12-14 11:59:12 -06:00
|
|
|
/**
|
|
|
|
* @return Carbon
|
|
|
|
*/
|
|
|
|
public function getLastHitDate(): Carbon
|
|
|
|
{
|
|
|
|
return $this->lastHitDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Carbon $lastHitDate
|
|
|
|
*/
|
2018-07-07 14:17:46 -05:00
|
|
|
public function setLastHitDate(Carbon $lastHitDate): void
|
2016-12-14 11:59:12 -06:00
|
|
|
{
|
|
|
|
$this->lastHitDate = $lastHitDate;
|
|
|
|
}
|
|
|
|
|
2015-05-17 10:54:13 -05:00
|
|
|
/**
|
2015-06-14 01:22:02 -05:00
|
|
|
* @return string
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
2016-02-18 03:04:26 -06:00
|
|
|
public function getMax(): string
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
|
|
|
return $this->max;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-06-14 01:22:02 -05:00
|
|
|
* @param string $max
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
2018-07-07 14:17:46 -05:00
|
|
|
public function setMax(string $max): void
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
|
|
|
$this->max = $max;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-06-14 01:22:02 -05:00
|
|
|
* @return string
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
2016-02-18 03:04:26 -06:00
|
|
|
public function getMin(): string
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
|
|
|
return $this->min;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2015-06-14 01:22:02 -05:00
|
|
|
* @param string $min
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
2018-07-07 14:17:46 -05:00
|
|
|
public function setMin(string $min): void
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
|
|
|
$this->min = $min;
|
|
|
|
}
|
|
|
|
|
2017-12-22 11:32:43 -06:00
|
|
|
/**
|
|
|
|
* @return Carbon
|
|
|
|
*/
|
|
|
|
public function getPayDate(): Carbon
|
|
|
|
{
|
|
|
|
return $this->payDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Carbon $payDate
|
|
|
|
*/
|
|
|
|
public function setPayDate(Carbon $payDate): void
|
|
|
|
{
|
|
|
|
$this->payDate = $payDate;
|
|
|
|
}
|
|
|
|
|
2016-02-06 13:17:55 -06:00
|
|
|
/**
|
|
|
|
* @return int
|
|
|
|
*/
|
|
|
|
public function getTransactionJournalId(): int
|
|
|
|
{
|
|
|
|
return $this->transactionJournalId ?? 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param int $transactionJournalId
|
|
|
|
*/
|
2018-07-07 14:17:46 -05:00
|
|
|
public function setTransactionJournalId(int $transactionJournalId): void
|
2016-02-06 13:17:55 -06:00
|
|
|
{
|
|
|
|
$this->transactionJournalId = $transactionJournalId;
|
|
|
|
}
|
|
|
|
|
2015-05-17 10:54:13 -05:00
|
|
|
/**
|
2016-04-06 02:27:45 -05:00
|
|
|
* @return bool
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
2016-02-18 03:04:26 -06:00
|
|
|
public function isActive(): bool
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
2018-04-02 07:42:07 -05:00
|
|
|
return 1 === (int)$this->bill->active;
|
2015-05-17 10:54:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-04-06 02:27:45 -05:00
|
|
|
* @return bool
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
2016-02-18 03:04:26 -06:00
|
|
|
public function isHit(): bool
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
|
|
|
return $this->hit;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2016-02-05 02:25:15 -06:00
|
|
|
* @param bool $hit
|
2015-05-17 10:54:13 -05:00
|
|
|
*/
|
2018-07-07 14:17:46 -05:00
|
|
|
public function setHit(bool $hit): void
|
2015-05-17 10:54:13 -05:00
|
|
|
{
|
|
|
|
$this->hit = $hit;
|
|
|
|
}
|
2015-05-20 12:56:14 -05:00
|
|
|
}
|