mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-12-12 01:42:32 +00:00
Move code to repository.
This commit is contained in:
@@ -163,6 +163,24 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
|
||||
return new PiggyBank();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current amount saved in piggy bank.
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentAmount(PiggyBank $piggyBank): string
|
||||
{
|
||||
/** @var PiggyBankRepetition $rep */
|
||||
$rep = $piggyBank->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
|
||||
if (null === $rep) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
return strval($rep->currentamount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
|
||||
@@ -102,6 +102,15 @@ interface PiggyBankRepositoryInterface
|
||||
*/
|
||||
public function find(int $piggyBankid): PiggyBank;
|
||||
|
||||
/**
|
||||
* Get current amount saved in piggy bank.
|
||||
*
|
||||
* @param PiggyBank $piggyBank
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getCurrentAmount(PiggyBank $piggyBank): string;
|
||||
|
||||
/**
|
||||
* Get all events.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user