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

157 lines
2.7 KiB
PHP
Raw Normal View History

2015-05-16 06:53:08 -05:00
<?php
2015-05-16 07:14:22 -05:00
namespace FireflyIII\Helpers\Collection;
2015-05-20 12:55:53 -05:00
2015-05-16 07:14:22 -05:00
use Illuminate\Support\Collection;
2015-05-16 06:53:08 -05:00
/**
2015-05-16 12:08:54 -05:00
* @codeCoverageIgnore
*
2015-05-16 07:14:22 -05:00
* Class Budget
*
* @package FireflyIII\Helpers\Collection
2015-05-16 06:53:08 -05:00
*/
2015-05-16 07:14:22 -05:00
class Budget
{
/** @var Collection */
protected $budgetLines;
2015-05-24 01:00:40 -05:00
/** @var string */
protected $budgeted = '0';
/** @var string */
protected $left = '0';
/** @var string */
protected $overspent = '0';
/** @var string */
protected $spent = '0';
2015-05-16 07:14:22 -05:00
/**
*
*/
public function __construct()
{
$this->budgetLines = new Collection;
}
/**
* @param BudgetLine $budgetLine
*/
public function addBudgetLine(BudgetLine $budgetLine)
{
$this->budgetLines->push($budgetLine);
}
/**
* @param float $add
*/
public function addBudgeted($add)
{
2015-05-24 01:00:40 -05:00
$add = strval(round($add, 2));
bcscale(2);
$this->budgeted = bcadd($this->budgeted, $add);
2015-05-16 07:14:22 -05:00
}
/**
* @param float $add
*/
public function addLeft($add)
{
2015-05-24 01:00:40 -05:00
$add = strval(round($add, 2));
bcscale(2);
$this->left = bcadd($this->left, $add);
2015-05-16 07:14:22 -05:00
}
/**
* @param float $add
*/
public function addOverspent($add)
{
2015-05-24 01:00:40 -05:00
$add = strval(round($add, 2));
bcscale(2);
$this->overspent = bcadd($this->overspent, $add);
2015-05-16 07:14:22 -05:00
}
/**
* @param float $add
*/
public function addSpent($add)
{
2015-05-24 01:00:40 -05:00
$add = strval(round($add, 2));
bcscale(2);
$this->spent = bcadd($this->spent, $add);
2015-05-16 07:14:22 -05:00
}
2015-05-20 12:55:53 -05:00
/**
* @return \Illuminate\Support\Collection
*/
public function getBudgetLines()
{
return $this->budgetLines;
}
2015-05-16 07:14:22 -05:00
/**
2015-05-24 01:00:40 -05:00
* @return string
2015-05-16 07:14:22 -05:00
*/
public function getBudgeted()
{
return $this->budgeted;
}
/**
2015-05-24 01:00:40 -05:00
* @param string $budgeted
2015-05-16 07:14:22 -05:00
*/
public function setBudgeted($budgeted)
{
$this->budgeted = $budgeted;
}
/**
2015-05-24 01:00:40 -05:00
* @return string
2015-05-16 07:14:22 -05:00
*/
public function getLeft()
{
return $this->left;
}
/**
2015-05-24 01:00:40 -05:00
* @param string $left
2015-05-16 07:14:22 -05:00
*/
public function setLeft($left)
{
$this->left = $left;
}
/**
2015-05-24 01:00:40 -05:00
* @return string
2015-05-16 07:14:22 -05:00
*/
public function getOverspent()
{
return $this->overspent;
}
/**
2015-05-24 01:00:40 -05:00
* @param string $overspent
2015-05-16 07:14:22 -05:00
*/
public function setOverspent($overspent)
{
2015-05-24 01:00:40 -05:00
$this->overspent = strval(round($overspent, 2));
2015-05-16 07:14:22 -05:00
}
/**
2015-05-24 01:00:40 -05:00
* @return string
2015-05-16 07:14:22 -05:00
*/
public function getSpent()
{
return $this->spent;
}
/**
2015-05-24 01:00:40 -05:00
* @param string $spent
2015-05-16 07:14:22 -05:00
*/
public function setSpent($spent)
{
2015-05-24 01:00:40 -05:00
$this->spent = strval(round($spent, 2));
2015-05-16 07:14:22 -05:00
}
2015-05-16 06:53:08 -05:00
2015-05-20 12:56:14 -05:00
}