Files
firefly-iii/app/Helpers/Collection/Budget.php

194 lines
3.3 KiB
PHP
Raw Normal View History

2015-05-16 13:53:08 +02:00
<?php
/**
* Budget.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
2016-02-05 12:08:25 +01:00
declare(strict_types = 1);
2015-05-16 14:14:22 +02:00
namespace FireflyIII\Helpers\Collection;
2015-05-20 19:55:53 +02:00
2015-05-16 14:14:22 +02:00
use Illuminate\Support\Collection;
2015-05-16 13:53:08 +02:00
/**
2015-05-16 19:08:54 +02:00
*
2015-05-16 14:14:22 +02:00
* Class Budget
*
* @package FireflyIII\Helpers\Collection
2015-05-16 13:53:08 +02:00
*/
2015-05-16 14:14:22 +02:00
class Budget
{
/** @var Collection */
protected $budgetLines;
2015-05-24 08:00:40 +02:00
/** @var string */
protected $budgeted = '0';
/** @var string */
protected $left = '0';
/** @var string */
protected $overspent = '0';
/** @var string */
protected $spent = '0';
2015-05-16 14:14:22 +02:00
/**
*
*/
public function __construct()
{
$this->budgetLines = new Collection;
}
/**
* @param BudgetLine $budgetLine
*
* @return Budget
2015-05-16 14:14:22 +02:00
*/
public function addBudgetLine(BudgetLine $budgetLine): Budget
2015-05-16 14:14:22 +02:00
{
$this->budgetLines->push($budgetLine);
2016-08-26 08:21:31 +02:00
return $this;
2015-05-16 14:14:22 +02:00
}
/**
2016-02-05 09:25:15 +01:00
* @param string $add
*
* @return Budget
2015-05-16 14:14:22 +02:00
*/
public function addBudgeted(string $add): Budget
2015-05-16 14:14:22 +02:00
{
2015-05-24 08:00:40 +02:00
$this->budgeted = bcadd($this->budgeted, $add);
2016-08-26 08:21:31 +02:00
return $this;
2015-05-16 14:14:22 +02:00
}
/**
2016-02-05 09:25:15 +01:00
* @param string $add
*
* @return Budget
2015-05-16 14:14:22 +02:00
*/
public function addLeft(string $add): Budget
2015-05-16 14:14:22 +02:00
{
2015-05-24 08:00:40 +02:00
$this->left = bcadd($this->left, $add);
2016-08-26 08:21:31 +02:00
return $this;
2015-05-16 14:14:22 +02:00
}
/**
2016-02-05 09:25:15 +01:00
* @param string $add
*
* @return Budget
2015-05-16 14:14:22 +02:00
*/
public function addOverspent(string $add): Budget
2015-05-16 14:14:22 +02:00
{
2015-05-24 08:00:40 +02:00
$this->overspent = bcadd($this->overspent, $add);
2016-08-26 08:21:31 +02:00
return $this;
2015-05-16 14:14:22 +02:00
}
/**
2016-02-05 09:25:15 +01:00
* @param string $add
*
* @return Budget
2015-05-16 14:14:22 +02:00
*/
public function addSpent(string $add): Budget
2015-05-16 14:14:22 +02:00
{
2015-05-24 08:00:40 +02:00
$this->spent = bcadd($this->spent, $add);
2016-08-26 08:21:31 +02:00
return $this;
2015-05-16 14:14:22 +02:00
}
2015-05-20 19:55:53 +02:00
/**
* @return \Illuminate\Support\Collection
*/
2016-02-18 10:04:26 +01:00
public function getBudgetLines(): Collection
2015-05-20 19:55:53 +02:00
{
return $this->budgetLines;
}
2015-05-16 14:14:22 +02:00
/**
2015-05-24 08:00:40 +02:00
* @return string
2015-05-16 14:14:22 +02:00
*/
2016-02-18 10:04:26 +01:00
public function getBudgeted(): string
2015-05-16 14:14:22 +02:00
{
return $this->budgeted;
}
/**
2015-05-24 08:00:40 +02:00
* @param string $budgeted
*
* @return Budget
2015-05-16 14:14:22 +02:00
*/
public function setBudgeted(string $budgeted): Budget
2015-05-16 14:14:22 +02:00
{
$this->budgeted = $budgeted;
return $this;
2015-05-16 14:14:22 +02:00
}
/**
2015-05-24 08:00:40 +02:00
* @return string
2015-05-16 14:14:22 +02:00
*/
2016-02-18 10:04:26 +01:00
public function getLeft(): string
2015-05-16 14:14:22 +02:00
{
return $this->left;
}
/**
2015-05-24 08:00:40 +02:00
* @param string $left
*
* @return Budget
2015-05-16 14:14:22 +02:00
*/
public function setLeft(string $left): Budget
2015-05-16 14:14:22 +02:00
{
$this->left = $left;
return $this;
2015-05-16 14:14:22 +02:00
}
/**
2015-05-24 08:00:40 +02:00
* @return string
2015-05-16 14:14:22 +02:00
*/
2016-02-18 10:04:26 +01:00
public function getOverspent(): string
2015-05-16 14:14:22 +02:00
{
return $this->overspent;
}
/**
2015-05-24 08:00:40 +02:00
* @param string $overspent
*
* @return Budget
2015-05-16 14:14:22 +02:00
*/
public function setOverspent(string $overspent): Budget
2015-05-16 14:14:22 +02:00
{
2016-12-30 13:45:02 +01:00
$this->overspent = $overspent;
return $this;
2015-05-16 14:14:22 +02:00
}
/**
2015-05-24 08:00:40 +02:00
* @return string
2015-05-16 14:14:22 +02:00
*/
2016-02-18 10:04:26 +01:00
public function getSpent(): string
2015-05-16 14:14:22 +02:00
{
return $this->spent;
}
/**
2015-05-24 08:00:40 +02:00
* @param string $spent
*
* @return Budget
2015-05-16 14:14:22 +02:00
*/
public function setSpent(string $spent): Budget
2015-05-16 14:14:22 +02:00
{
2016-12-30 13:45:02 +01:00
$this->spent = $spent;
return $this;
2015-05-16 14:14:22 +02:00
}
2015-05-16 13:53:08 +02:00
2015-05-20 19:56:14 +02:00
}