2015-02-25 19:32:33 +01:00
|
|
|
<?php
|
2016-05-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
* PiggyBankRepositoryInterface.php
|
2017-10-21 08:40:00 +02:00
|
|
|
* Copyright (c) 2017 thegrumpydictator@gmail.com
|
2016-05-20 12:41:23 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* This file is part of Firefly III.
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2017-10-21 08:40:00 +02:00
|
|
|
* Firefly III is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Firefly III is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2017-12-17 14:44:05 +01:00
|
|
|
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
|
2016-05-20 12:41:23 +02:00
|
|
|
*/
|
2017-04-09 07:44:22 +02:00
|
|
|
declare(strict_types=1);
|
2015-02-25 19:32:33 +01:00
|
|
|
|
|
|
|
namespace FireflyIII\Repositories\PiggyBank;
|
|
|
|
|
2017-04-28 07:51:09 +02:00
|
|
|
use Carbon\Carbon;
|
2015-02-25 19:32:33 +01:00
|
|
|
use FireflyIII\Models\PiggyBank;
|
2016-04-06 09:27:45 +02:00
|
|
|
use FireflyIII\Models\PiggyBankEvent;
|
2017-04-28 07:51:09 +02:00
|
|
|
use FireflyIII\Models\PiggyBankRepetition;
|
|
|
|
use FireflyIII\Models\TransactionJournal;
|
2017-01-30 16:40:49 +01:00
|
|
|
use FireflyIII\User;
|
2015-02-27 11:02:08 +01:00
|
|
|
use Illuminate\Support\Collection;
|
2015-02-25 19:32:33 +01:00
|
|
|
|
|
|
|
/**
|
2017-11-15 12:25:49 +01:00
|
|
|
* Interface PiggyBankRepositoryInterface.
|
2015-02-25 19:32:33 +01:00
|
|
|
*/
|
2015-03-06 15:12:07 +01:00
|
|
|
interface PiggyBankRepositoryInterface
|
|
|
|
{
|
2017-03-22 17:02:15 +01:00
|
|
|
/**
|
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
* @param string $amount
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function addAmount(PiggyBank $piggyBank, string $amount): bool;
|
|
|
|
|
2017-04-28 07:51:09 +02:00
|
|
|
/**
|
|
|
|
* @param PiggyBankRepetition $repetition
|
|
|
|
* @param string $amount
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function addAmountToRepetition(PiggyBankRepetition $repetition, string $amount): string;
|
|
|
|
|
2017-03-22 17:02:15 +01:00
|
|
|
/**
|
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
* @param string $amount
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function canAddAmount(PiggyBank $piggyBank, string $amount): bool;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
* @param string $amount
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function canRemoveAmount(PiggyBank $piggyBank, string $amount): bool;
|
|
|
|
|
2015-04-20 21:57:20 +02:00
|
|
|
/**
|
2016-05-01 07:09:58 +02:00
|
|
|
* Create a new event.
|
|
|
|
*
|
2015-04-20 21:57:20 +02:00
|
|
|
* @param PiggyBank $piggyBank
|
2016-02-05 09:25:15 +01:00
|
|
|
* @param string $amount
|
2015-04-20 21:57:20 +02:00
|
|
|
*
|
2016-04-06 09:27:45 +02:00
|
|
|
* @return PiggyBankEvent
|
2015-04-20 21:57:20 +02:00
|
|
|
*/
|
2016-04-06 09:27:45 +02:00
|
|
|
public function createEvent(PiggyBank $piggyBank, string $amount): PiggyBankEvent;
|
2015-04-20 21:57:20 +02:00
|
|
|
|
2017-04-28 07:51:09 +02:00
|
|
|
/**
|
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
* @param string $amount
|
|
|
|
* @param TransactionJournal $journal
|
|
|
|
*
|
|
|
|
* @return PiggyBankEvent
|
|
|
|
*/
|
|
|
|
public function createEventWithJournal(PiggyBank $piggyBank, string $amount, TransactionJournal $journal): PiggyBankEvent;
|
|
|
|
|
2015-04-20 21:57:20 +02:00
|
|
|
/**
|
2016-05-01 07:09:58 +02:00
|
|
|
* Destroy piggy bank.
|
|
|
|
*
|
2015-04-20 21:57:20 +02:00
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2016-04-06 09:27:45 +02:00
|
|
|
public function destroy(PiggyBank $piggyBank): bool;
|
2015-04-20 21:57:20 +02:00
|
|
|
|
2016-05-17 15:19:07 +02:00
|
|
|
/**
|
|
|
|
* @param int $piggyBankid
|
|
|
|
*
|
|
|
|
* @return PiggyBank
|
|
|
|
*/
|
|
|
|
public function find(int $piggyBankid): PiggyBank;
|
|
|
|
|
2018-02-18 10:31:15 +01:00
|
|
|
/**
|
|
|
|
* Find by name or return NULL.
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
*
|
|
|
|
* @return PiggyBank|null
|
|
|
|
*/
|
|
|
|
public function findByName(string $name): ?PiggyBank;
|
|
|
|
|
2018-02-17 10:47:32 +01:00
|
|
|
/**
|
|
|
|
* Get current amount saved in piggy bank.
|
|
|
|
*
|
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getCurrentAmount(PiggyBank $piggyBank): string;
|
|
|
|
|
2015-04-07 17:51:22 +02:00
|
|
|
/**
|
2016-05-01 07:09:58 +02:00
|
|
|
* Get all events.
|
2015-04-07 17:51:22 +02:00
|
|
|
*
|
2015-04-20 21:57:20 +02:00
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
*
|
2015-05-25 19:58:13 +02:00
|
|
|
* @return Collection
|
2015-04-20 21:57:20 +02:00
|
|
|
*/
|
2016-12-04 18:02:19 +01:00
|
|
|
public function getEvents(PiggyBank $piggyBank): Collection;
|
2015-05-25 19:58:13 +02:00
|
|
|
|
2017-04-28 07:51:09 +02:00
|
|
|
/**
|
|
|
|
* Used for connecting to a piggy bank.
|
|
|
|
*
|
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
* @param PiggyBankRepetition $repetition
|
|
|
|
* @param TransactionJournal $journal
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getExactAmount(PiggyBank $piggyBank, PiggyBankRepetition $repetition, TransactionJournal $journal): string;
|
|
|
|
|
2016-01-24 20:38:58 +01:00
|
|
|
/**
|
2016-05-01 07:09:58 +02:00
|
|
|
* Highest order of all piggy banks.
|
|
|
|
*
|
2016-01-24 20:38:58 +01:00
|
|
|
* @return int
|
|
|
|
*/
|
2016-04-06 09:27:45 +02:00
|
|
|
public function getMaxOrder(): int;
|
2016-01-24 20:38:58 +01:00
|
|
|
|
2015-05-25 19:58:13 +02:00
|
|
|
/**
|
2016-05-01 07:09:58 +02:00
|
|
|
* Return all piggy banks.
|
|
|
|
*
|
2015-05-25 19:58:13 +02:00
|
|
|
* @return Collection
|
|
|
|
*/
|
2016-12-04 18:02:19 +01:00
|
|
|
public function getPiggyBanks(): Collection;
|
2015-04-20 21:57:20 +02:00
|
|
|
|
2016-05-15 12:08:41 +02:00
|
|
|
/**
|
|
|
|
* Also add amount in name.
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2016-12-04 18:02:19 +01:00
|
|
|
public function getPiggyBanksWithAmount(): Collection;
|
2016-05-15 12:08:41 +02:00
|
|
|
|
2017-04-28 07:51:09 +02:00
|
|
|
/**
|
2018-04-21 23:48:54 +02:00
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
*
|
|
|
|
* @return PiggyBankRepetition|null
|
|
|
|
*/
|
|
|
|
public function getRepetition(PiggyBank $piggyBank): ?PiggyBankRepetition;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get for piggy account what is left to put in piggies.
|
|
|
|
*
|
2017-04-28 07:51:09 +02:00
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
* @param Carbon $date
|
|
|
|
*
|
2018-04-21 23:48:54 +02:00
|
|
|
* @return string
|
2017-04-28 07:51:09 +02:00
|
|
|
*/
|
2018-04-21 23:48:54 +02:00
|
|
|
public function leftOnAccount(PiggyBank $piggyBank, Carbon $date): string;
|
2017-04-28 07:51:09 +02:00
|
|
|
|
2017-03-22 17:02:15 +01:00
|
|
|
/**
|
|
|
|
* @param PiggyBank $piggyBank
|
|
|
|
* @param string $amount
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function removeAmount(PiggyBank $piggyBank, string $amount): bool;
|
|
|
|
|
2015-03-15 18:00:33 +01:00
|
|
|
/**
|
|
|
|
* Set all piggy banks to order 0.
|
2015-03-29 07:51:56 +02:00
|
|
|
*
|
2016-04-06 09:27:45 +02:00
|
|
|
* @return bool
|
2015-03-15 18:00:33 +01:00
|
|
|
*/
|
2016-04-06 09:27:45 +02:00
|
|
|
public function reset(): bool;
|
2015-03-15 18:00:33 +01:00
|
|
|
|
|
|
|
/**
|
2016-05-01 07:09:58 +02:00
|
|
|
* Set specific piggy bank to specific order.
|
2015-03-15 18:00:33 +01:00
|
|
|
*
|
2015-07-09 06:13:39 +02:00
|
|
|
* @param int $piggyBankId
|
2015-03-15 18:00:33 +01:00
|
|
|
* @param int $order
|
|
|
|
*
|
2016-04-06 09:27:45 +02:00
|
|
|
* @return bool
|
2015-03-15 18:00:33 +01:00
|
|
|
*/
|
2016-04-06 09:27:45 +02:00
|
|
|
public function setOrder(int $piggyBankId, int $order): bool;
|
2015-03-15 18:00:33 +01:00
|
|
|
|
2017-01-30 16:40:49 +01:00
|
|
|
/**
|
|
|
|
* @param User $user
|
|
|
|
*/
|
|
|
|
public function setUser(User $user);
|
2015-03-07 09:21:06 +01:00
|
|
|
|
2015-03-06 15:12:07 +01:00
|
|
|
/**
|
2016-05-01 07:09:58 +02:00
|
|
|
* Store new piggy bank.
|
|
|
|
*
|
2015-03-06 15:12:07 +01:00
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @return PiggyBank
|
|
|
|
*/
|
2016-04-06 09:27:45 +02:00
|
|
|
public function store(array $data): PiggyBank;
|
2015-03-06 15:12:07 +01:00
|
|
|
|
|
|
|
/**
|
2016-05-01 07:09:58 +02:00
|
|
|
* Update existing piggy bank.
|
2016-05-15 12:08:41 +02:00
|
|
|
*
|
2015-05-05 10:23:01 +02:00
|
|
|
* @param PiggyBank $piggyBank
|
2015-03-06 15:12:07 +01:00
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @return PiggyBank
|
|
|
|
*/
|
2016-04-06 09:27:45 +02:00
|
|
|
public function update(PiggyBank $piggyBank, array $data): PiggyBank;
|
2015-03-29 08:14:32 +02:00
|
|
|
}
|