firefly-iii/app/Support/Twig/PiggyBank.php
Joris de Vries a0e66b913b Show suggested monthly savings for a piggybank
If a piggybank has both a target date and a target amount, show how much money needs to be added to the piggybank each month to achieve both targets.

Strings are currently hard-coded because I want to gauge the reaction to this :)
2017-02-24 22:00:49 +01:00

61 lines
1.2 KiB
PHP

<?php
/**
* PiggyBank.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.
*/
declare(strict_types = 1);
namespace FireflyIII\Support\Twig;
use FireflyIII\Models\PiggyBank as PB;
use Twig_Extension;
use Twig_SimpleFunction;
/**
*
* Class PiggyBank
*
* @package FireflyIII\Support\Twig
*/
class PiggyBank extends Twig_Extension
{
/**
*
*/
public function getFunctions(): array
{
$functions = [];
$functions[] = new Twig_SimpleFunction(
'currentRelevantRepAmount', function (PB $piggyBank) {
return $piggyBank->currentRelevantRep()->currentamount;
}
);
$functions[] = new Twig_SimpleFunction(
'suggestedMonthlyAmount', function (PB $piggyBank) {
return $piggyBank->getSuggestedMonthlyAmount();
}
);
return $functions;
}
/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName(): string
{
return 'FireflyIII\Support\Twig\PiggyBank';
}
}