2015-02-25 08:19:14 -06:00
|
|
|
<?php
|
2016-05-20 05:41:23 -05:00
|
|
|
/**
|
|
|
|
* BillRepositoryInterface.php
|
2019-10-01 23:37:26 -05:00
|
|
|
* Copyright (c) 2019 thegrumpydictator@gmail.com
|
2016-05-20 05:41:23 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-04 23:52:15 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2017-10-21 01:40:00 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 01:40:00 -05:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-01 23:37:26 -05:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 01:40:00 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2016-05-20 05:41:23 -05:00
|
|
|
*/
|
2017-04-09 00:44:22 -05:00
|
|
|
declare(strict_types=1);
|
2015-02-25 08:19:14 -06:00
|
|
|
|
|
|
|
namespace FireflyIII\Repositories\Bill;
|
|
|
|
|
2015-03-03 10:40:17 -06:00
|
|
|
use Carbon\Carbon;
|
2015-02-25 08:19:14 -06:00
|
|
|
use FireflyIII\Models\Bill;
|
2017-01-30 09:40:49 -06:00
|
|
|
use FireflyIII\User;
|
2018-02-06 11:11:33 -06:00
|
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
2015-04-05 11:20:06 -05:00
|
|
|
use Illuminate\Support\Collection;
|
2015-02-25 08:19:14 -06:00
|
|
|
|
|
|
|
/**
|
2017-11-15 05:25:49 -06:00
|
|
|
* Interface BillRepositoryInterface.
|
2015-02-25 08:19:14 -06:00
|
|
|
*/
|
2015-03-29 14:27:51 -05:00
|
|
|
interface BillRepositoryInterface
|
|
|
|
{
|
2019-09-23 10:11:01 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Bill $bill
|
|
|
|
*/
|
|
|
|
public function unlinkAll(Bill $bill): void;
|
|
|
|
|
2015-07-09 02:41:54 -05:00
|
|
|
/**
|
2016-01-20 08:21:27 -06:00
|
|
|
* @param Bill $bill
|
2015-12-26 02:39:35 -06:00
|
|
|
*
|
2016-02-06 11:59:48 -06:00
|
|
|
* @return bool
|
2015-12-26 02:39:35 -06:00
|
|
|
*/
|
2016-02-06 11:59:48 -06:00
|
|
|
public function destroy(Bill $bill): bool;
|
2015-12-26 02:39:35 -06:00
|
|
|
|
2016-07-05 01:57:45 -05:00
|
|
|
/**
|
2016-07-23 14:37:06 -05:00
|
|
|
* Find a bill by ID.
|
2016-07-05 01:57:45 -05:00
|
|
|
*
|
2016-07-23 14:37:06 -05:00
|
|
|
* @param int $billId
|
2016-07-05 01:57:45 -05:00
|
|
|
*
|
2018-02-16 08:19:19 -06:00
|
|
|
* @return Bill|null
|
2016-07-05 01:57:45 -05:00
|
|
|
*/
|
2018-02-16 08:19:19 -06:00
|
|
|
public function find(int $billId): ?Bill;
|
2016-07-05 01:57:45 -05:00
|
|
|
|
2019-03-17 11:05:16 -05:00
|
|
|
/**
|
|
|
|
* Find bill by parameters.
|
|
|
|
*
|
|
|
|
* @param int|null $billId
|
|
|
|
* @param string|null $billName
|
|
|
|
*
|
|
|
|
* @return Bill|null
|
|
|
|
*/
|
2019-03-31 06:36:49 -05:00
|
|
|
public function findBill(?int $billId, ?string $billName): ?Bill;
|
2019-03-17 11:05:16 -05:00
|
|
|
|
2016-04-01 06:07:19 -05:00
|
|
|
/**
|
2016-07-23 14:37:06 -05:00
|
|
|
* Find a bill by name.
|
2016-04-01 06:07:19 -05:00
|
|
|
*
|
2016-07-23 14:37:06 -05:00
|
|
|
* @param string $name
|
2016-04-01 06:07:19 -05:00
|
|
|
*
|
2018-02-16 08:19:19 -06:00
|
|
|
* @return Bill|null
|
2016-04-01 06:07:19 -05:00
|
|
|
*/
|
2018-02-16 08:19:19 -06:00
|
|
|
public function findByName(string $name): ?Bill;
|
2016-04-01 06:07:19 -05:00
|
|
|
|
2015-04-07 03:14:10 -05:00
|
|
|
/**
|
2015-12-27 10:29:41 -06:00
|
|
|
* @return Collection
|
2015-04-07 03:14:10 -05:00
|
|
|
*/
|
2016-02-06 11:59:48 -06:00
|
|
|
public function getActiveBills(): Collection;
|
2015-12-27 10:29:41 -06:00
|
|
|
|
2018-12-09 06:09:43 -06:00
|
|
|
/**
|
|
|
|
* Get all attachments.
|
|
|
|
*
|
|
|
|
* @param Bill $bill
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getAttachments(Bill $bill): Collection;
|
|
|
|
|
2015-04-05 11:20:06 -05:00
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2016-02-06 11:59:48 -06:00
|
|
|
public function getBills(): Collection;
|
2015-04-05 11:20:06 -05:00
|
|
|
|
2015-12-12 03:33:19 -06:00
|
|
|
/**
|
|
|
|
* Gets the bills which have some kind of relevance to the accounts mentioned.
|
|
|
|
*
|
|
|
|
* @param Collection $accounts
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2016-02-06 11:59:48 -06:00
|
|
|
public function getBillsForAccounts(Collection $accounts): Collection;
|
2015-12-12 03:33:19 -06:00
|
|
|
|
2016-01-20 08:21:27 -06:00
|
|
|
/**
|
|
|
|
* Get the total amount of money paid for the users active bills in the date range given.
|
|
|
|
*
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2016-02-06 11:59:48 -06:00
|
|
|
public function getBillsPaidInRange(Carbon $start, Carbon $end): string;
|
2016-01-20 08:21:27 -06:00
|
|
|
|
2018-08-27 22:21:23 -05:00
|
|
|
/**
|
|
|
|
* Get the total amount of money paid for the users active bills in the date range given,
|
|
|
|
* grouped per currency.
|
|
|
|
*
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getBillsPaidInRangePerCurrency(Carbon $start, Carbon $end): array;
|
|
|
|
|
2016-01-20 08:21:27 -06:00
|
|
|
/**
|
|
|
|
* Get the total amount of money due for the users active bills in the date range given.
|
|
|
|
*
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2016-02-06 11:59:48 -06:00
|
|
|
public function getBillsUnpaidInRange(Carbon $start, Carbon $end): string;
|
2016-01-20 08:21:27 -06:00
|
|
|
|
2018-08-27 22:21:23 -05:00
|
|
|
/**
|
|
|
|
* Get the total amount of money due for the users active bills in the date range given.
|
|
|
|
*
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getBillsUnpaidInRangePerCurrency(Carbon $start, Carbon $end): array;
|
|
|
|
|
2018-05-07 13:35:14 -05:00
|
|
|
/**
|
|
|
|
* Get all bills with these ID's.
|
|
|
|
*
|
|
|
|
* @param array $billIds
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getByIds(array $billIds): Collection;
|
|
|
|
|
2018-04-29 00:46:03 -05:00
|
|
|
/**
|
|
|
|
* Get text or return empty string.
|
|
|
|
*
|
|
|
|
* @param Bill $bill
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getNoteText(Bill $bill): string;
|
|
|
|
|
2016-07-23 14:37:06 -05:00
|
|
|
/**
|
2016-10-23 07:56:05 -05:00
|
|
|
* @param Bill $bill
|
2016-07-23 14:37:06 -05:00
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
2016-10-23 07:56:05 -05:00
|
|
|
public function getOverallAverage(Bill $bill): string;
|
|
|
|
|
2018-02-06 12:49:16 -06:00
|
|
|
/**
|
|
|
|
* @param int $size
|
|
|
|
*
|
|
|
|
* @return LengthAwarePaginator
|
|
|
|
*/
|
|
|
|
public function getPaginator(int $size): LengthAwarePaginator;
|
|
|
|
|
2016-10-23 07:56:05 -05:00
|
|
|
/**
|
|
|
|
* @param Bill $bill
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getPaidDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection;
|
2016-07-23 14:37:06 -05:00
|
|
|
|
2016-10-21 06:20:51 -05:00
|
|
|
/**
|
|
|
|
* Between start and end, tells you on which date(s) the bill is expected to hit.
|
|
|
|
*
|
|
|
|
* @param Bill $bill
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getPayDatesInRange(Bill $bill, Carbon $start, Carbon $end): Collection;
|
|
|
|
|
2018-04-14 02:59:04 -05:00
|
|
|
/**
|
|
|
|
* Return all rules for one bill
|
|
|
|
*
|
|
|
|
* @param Bill $bill
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function getRulesForBill(Bill $bill): Collection;
|
|
|
|
|
2018-04-08 10:36:37 -05:00
|
|
|
/**
|
|
|
|
* Return all rules related to the bills in the collection, in an associative array:
|
|
|
|
* 5= billid
|
|
|
|
*
|
|
|
|
* 5 => [['id' => 1, 'title' => 'Some rule'],['id' => 2, 'title' => 'Some other rule']]
|
|
|
|
*
|
|
|
|
* @param Collection $collection
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function getRulesForBills(Collection $collection): array;
|
|
|
|
|
2016-07-23 14:37:06 -05:00
|
|
|
/**
|
|
|
|
* @param Bill $bill
|
|
|
|
* @param Carbon $date
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getYearAverage(Bill $bill, Carbon $date): string;
|
|
|
|
|
2018-04-14 02:59:04 -05:00
|
|
|
/**
|
|
|
|
* Link a set of journals to a bill.
|
|
|
|
*
|
|
|
|
* @param Bill $bill
|
2019-07-21 10:15:06 -05:00
|
|
|
* @param array $transactions
|
2018-04-14 02:59:04 -05:00
|
|
|
*/
|
2019-07-21 10:15:06 -05:00
|
|
|
public function linkCollectionToBill(Bill $bill, array $transactions): void;
|
2018-04-14 02:59:04 -05:00
|
|
|
|
2016-10-20 23:26:12 -05:00
|
|
|
/**
|
|
|
|
* Given a bill and a date, this method will tell you at which moment this bill expects its next
|
|
|
|
* transaction. Whether or not it is there already, is not relevant.
|
|
|
|
*
|
|
|
|
* @param Bill $bill
|
|
|
|
* @param Carbon $date
|
|
|
|
*
|
|
|
|
* @return \Carbon\Carbon
|
|
|
|
*/
|
|
|
|
public function nextDateMatch(Bill $bill, Carbon $date): Carbon;
|
|
|
|
|
2015-02-25 08:19:14 -06:00
|
|
|
/**
|
2016-10-20 14:40:45 -05:00
|
|
|
* @param Bill $bill
|
|
|
|
* @param Carbon $date
|
2015-02-25 08:19:14 -06:00
|
|
|
*
|
2015-05-26 13:59:16 -05:00
|
|
|
* @return \Carbon\Carbon
|
2015-02-25 08:19:14 -06:00
|
|
|
*/
|
2016-10-20 14:40:45 -05:00
|
|
|
public function nextExpectedMatch(Bill $bill, Carbon $date): Carbon;
|
2015-02-25 08:19:14 -06:00
|
|
|
|
2019-03-02 07:12:09 -06:00
|
|
|
/**
|
|
|
|
* @param string $query
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
|
|
|
public function searchBill(string $query): Collection;
|
|
|
|
|
2017-01-30 09:46:30 -06:00
|
|
|
/**
|
|
|
|
* @param User $user
|
|
|
|
*/
|
|
|
|
public function setUser(User $user);
|
|
|
|
|
2015-04-05 11:20:06 -05:00
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
*
|
2018-04-03 12:12:59 -05:00
|
|
|
* @return Bill|null
|
2015-04-05 11:20:06 -05:00
|
|
|
*/
|
2018-04-03 12:12:59 -05:00
|
|
|
public function store(array $data): ?Bill;
|
2015-04-05 11:20:06 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Bill $bill
|
|
|
|
* @param array $data
|
|
|
|
*
|
2016-02-06 11:59:48 -06:00
|
|
|
* @return Bill
|
2015-04-05 11:20:06 -05:00
|
|
|
*/
|
2016-02-06 11:59:48 -06:00
|
|
|
public function update(Bill $bill, array $data): Bill;
|
2015-03-29 01:14:32 -05:00
|
|
|
}
|