mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-24 12:47:00 +00:00
Code clean up.
This commit is contained in:
@@ -18,7 +18,6 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace FireflyIII\Models;
|
||||
@@ -32,9 +31,7 @@ use Steam;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class PiggyBank
|
||||
*
|
||||
* @package FireflyIII\Models
|
||||
* Class PiggyBank.
|
||||
*/
|
||||
class PiggyBank extends Model
|
||||
{
|
||||
@@ -68,7 +65,7 @@ class PiggyBank extends Model
|
||||
*
|
||||
* @return PiggyBank
|
||||
*/
|
||||
public static function routeBinder(PiggyBank $value)
|
||||
public static function routeBinder(self $value)
|
||||
{
|
||||
if (auth()->check()) {
|
||||
if (intval($value->account->user_id) === auth()->user()->id) {
|
||||
@@ -87,19 +84,19 @@ class PiggyBank extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the PiggyBankRepetition that's currently relevant / active
|
||||
* Grabs the PiggyBankRepetition that's currently relevant / active.
|
||||
*
|
||||
* @returns PiggyBankRepetition
|
||||
*/
|
||||
public function currentRelevantRep(): PiggyBankRepetition
|
||||
{
|
||||
if (!is_null($this->currentRep)) {
|
||||
if (null !== $this->currentRep) {
|
||||
return $this->currentRep;
|
||||
}
|
||||
// repeating piggy banks are no longer supported.
|
||||
/** @var PiggyBankRepetition $rep */
|
||||
$rep = $this->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
|
||||
if (is_null($rep)) {
|
||||
if (null === $rep) {
|
||||
return new PiggyBankRepetition();
|
||||
}
|
||||
$this->currentRep = $rep;
|
||||
@@ -108,7 +105,6 @@ class PiggyBank extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $value
|
||||
*
|
||||
* @return string
|
||||
@@ -134,12 +130,12 @@ class PiggyBank extends Model
|
||||
$remainingAmount = bcsub($this->targetamount, $this->currentRelevantRep()->currentamount);
|
||||
|
||||
// more than 1 month to go and still need money to save:
|
||||
if ($diffInMonths > 0 && bccomp($remainingAmount, '0') === 1) {
|
||||
if ($diffInMonths > 0 && 1 === bccomp($remainingAmount, '0')) {
|
||||
$savePerMonth = bcdiv($remainingAmount, strval($diffInMonths));
|
||||
}
|
||||
|
||||
// less than 1 month to go but still need money to save:
|
||||
if ($diffInMonths === 0 && bccomp($remainingAmount, '0') === 1) {
|
||||
if (0 === $diffInMonths && 1 === bccomp($remainingAmount, '0')) {
|
||||
$savePerMonth = $remainingAmount;
|
||||
}
|
||||
}
|
||||
@@ -148,7 +144,6 @@ class PiggyBank extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param Carbon $date
|
||||
*
|
||||
* @return string
|
||||
@@ -156,7 +151,7 @@ class PiggyBank extends Model
|
||||
public function leftOnAccount(Carbon $date): string
|
||||
{
|
||||
$balance = Steam::balanceIgnoreVirtual($this->account, $date);
|
||||
/** @var PiggyBank $p */
|
||||
// @var PiggyBank $p
|
||||
foreach ($this->account->piggyBanks as $piggyBank) {
|
||||
$currentAmount = $piggyBank->currentRelevantRep()->currentamount ?? '0';
|
||||
|
||||
@@ -191,7 +186,6 @@ class PiggyBank extends Model
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $value
|
||||
*/
|
||||
public function setNameAttribute($value)
|
||||
|
||||
Reference in New Issue
Block a user