2015-02-25 15:19:14 +01:00
|
|
|
<?php
|
2016-05-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
* BillRepositoryInterface.php
|
|
|
|
* Copyright (C) 2016 thegrumpydictator@gmail.com
|
|
|
|
*
|
2016-10-05 06:52:15 +02:00
|
|
|
* 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.
|
2016-05-20 12:41:23 +02:00
|
|
|
*/
|
|
|
|
|
2016-02-05 12:08:25 +01:00
|
|
|
declare(strict_types = 1);
|
2015-02-25 15:19:14 +01:00
|
|
|
|
|
|
|
namespace FireflyIII\Repositories\Bill;
|
|
|
|
|
2015-03-03 17:40:17 +01:00
|
|
|
use Carbon\Carbon;
|
2015-02-25 15:19:14 +01:00
|
|
|
use FireflyIII\Models\Bill;
|
|
|
|
use FireflyIII\Models\TransactionJournal;
|
2016-04-21 10:23:19 +02:00
|
|
|
use Illuminate\Pagination\LengthAwarePaginator;
|
2015-04-05 18:20:06 +02:00
|
|
|
use Illuminate\Support\Collection;
|
2015-02-25 15:19:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Interface BillRepositoryInterface
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Repositories\Bill
|
|
|
|
*/
|
2015-03-29 21:27:51 +02:00
|
|
|
interface BillRepositoryInterface
|
|
|
|
{
|
2015-02-25 15:19:14 +01:00
|
|
|
|
2015-07-09 09:41:54 +02:00
|
|
|
/**
|
2016-01-20 15:21:27 +01:00
|
|
|
* @param Bill $bill
|
2015-12-26 09:39:35 +01:00
|
|
|
*
|
2016-02-06 18:59:48 +01:00
|
|
|
* @return bool
|
2015-12-26 09:39:35 +01:00
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function destroy(Bill $bill): bool;
|
2015-12-26 09:39:35 +01:00
|
|
|
|
2016-07-05 08:57:45 +02:00
|
|
|
/**
|
2016-07-23 21:37:06 +02:00
|
|
|
* Find a bill by ID.
|
2016-07-05 08:57:45 +02:00
|
|
|
*
|
2016-07-23 21:37:06 +02:00
|
|
|
* @param int $billId
|
2016-07-05 08:57:45 +02:00
|
|
|
*
|
2016-07-23 21:37:06 +02:00
|
|
|
* @return Bill
|
2016-07-05 08:57:45 +02:00
|
|
|
*/
|
2016-07-23 21:37:06 +02:00
|
|
|
public function find(int $billId) : Bill;
|
2016-07-05 08:57:45 +02:00
|
|
|
|
2016-04-01 13:07:19 +02:00
|
|
|
/**
|
2016-07-23 21:37:06 +02:00
|
|
|
* Find a bill by name.
|
2016-04-01 13:07:19 +02:00
|
|
|
*
|
2016-07-23 21:37:06 +02:00
|
|
|
* @param string $name
|
2016-04-01 13:07:19 +02:00
|
|
|
*
|
|
|
|
* @return Bill
|
|
|
|
*/
|
2016-07-23 21:37:06 +02:00
|
|
|
public function findByName(string $name) : Bill;
|
2016-04-01 13:07:19 +02:00
|
|
|
|
2015-04-07 10:14:10 +02:00
|
|
|
/**
|
2015-12-27 17:29:41 +01:00
|
|
|
* @return Collection
|
2015-04-07 10:14:10 +02:00
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function getActiveBills(): Collection;
|
2015-12-27 17:29:41 +01:00
|
|
|
|
2016-01-01 21:07:15 +01:00
|
|
|
/**
|
|
|
|
* Returns all journals connected to these bills in the given range. Amount paid
|
|
|
|
* is stored in "journalAmount" as a negative number.
|
|
|
|
*
|
|
|
|
* @param Collection $bills
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function getAllJournalsInRange(Collection $bills, Carbon $start, Carbon $end): Collection;
|
2016-01-01 21:07:15 +01:00
|
|
|
|
2015-04-05 18:20:06 +02:00
|
|
|
/**
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function getBills(): Collection;
|
2015-04-05 18:20:06 +02:00
|
|
|
|
2015-12-12 10:33:19 +01:00
|
|
|
/**
|
|
|
|
* Gets the bills which have some kind of relevance to the accounts mentioned.
|
|
|
|
*
|
|
|
|
* @param Collection $accounts
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function getBillsForAccounts(Collection $accounts): Collection;
|
2015-12-12 10:33:19 +01:00
|
|
|
|
2016-01-20 15:21:27 +01: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 18:59:48 +01:00
|
|
|
public function getBillsPaidInRange(Carbon $start, Carbon $end): string;
|
2016-01-20 15:21:27 +01: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 18:59:48 +01:00
|
|
|
public function getBillsUnpaidInRange(Carbon $start, Carbon $end): string;
|
2016-01-20 15:21:27 +01:00
|
|
|
|
2015-04-05 18:20:06 +02:00
|
|
|
/**
|
|
|
|
* @param Bill $bill
|
|
|
|
*
|
2016-04-21 10:23:19 +02:00
|
|
|
* @param int $page
|
|
|
|
* @param int $pageSize
|
|
|
|
*
|
|
|
|
* @return LengthAwarePaginator
|
2015-04-05 18:20:06 +02:00
|
|
|
*/
|
2016-04-21 10:23:19 +02:00
|
|
|
public function getJournals(Bill $bill, int $page, int $pageSize = 50): LengthAwarePaginator;
|
2015-04-05 18:20:06 +02:00
|
|
|
|
2015-04-07 10:14:10 +02:00
|
|
|
/**
|
|
|
|
* Get all journals that were recorded on this bill between these dates.
|
|
|
|
*
|
|
|
|
* @param Bill $bill
|
|
|
|
* @param Carbon $start
|
|
|
|
* @param Carbon $end
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function getJournalsInRange(Bill $bill, Carbon $start, Carbon $end): Collection;
|
2015-04-07 10:14:10 +02:00
|
|
|
|
2016-07-23 21:37:06 +02:00
|
|
|
/**
|
|
|
|
* @param $bill
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getOverallAverage($bill): string;
|
|
|
|
|
2016-10-21 13:20:51 +02: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;
|
|
|
|
|
2015-04-05 18:20:06 +02:00
|
|
|
/**
|
|
|
|
* @param Bill $bill
|
|
|
|
*
|
|
|
|
* @return Collection
|
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function getPossiblyRelatedJournals(Bill $bill): Collection;
|
2015-02-25 15:19:14 +01:00
|
|
|
|
2016-07-23 21:37:06 +02:00
|
|
|
/**
|
|
|
|
* @param Bill $bill
|
|
|
|
* @param Carbon $date
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function getYearAverage(Bill $bill, Carbon $date): string;
|
|
|
|
|
2015-02-25 15:19:14 +01:00
|
|
|
/**
|
2015-04-05 18:20:06 +02:00
|
|
|
* @param Bill $bill
|
2015-02-25 15:19:14 +01:00
|
|
|
*
|
2016-02-06 18:59:48 +01:00
|
|
|
* @return \Carbon\Carbon
|
2015-02-25 15:19:14 +01:00
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function lastFoundMatch(Bill $bill): Carbon;
|
2015-02-25 15:19:14 +01:00
|
|
|
|
2015-04-07 10:14:10 +02:00
|
|
|
|
2016-10-21 06:26:12 +02: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 15:19:14 +01:00
|
|
|
/**
|
2016-10-20 21:40:45 +02:00
|
|
|
* @param Bill $bill
|
|
|
|
* @param Carbon $date
|
2015-02-25 15:19:14 +01:00
|
|
|
*
|
2015-05-26 20:59:16 +02:00
|
|
|
* @return \Carbon\Carbon
|
2015-02-25 15:19:14 +01:00
|
|
|
*/
|
2016-10-20 21:40:45 +02:00
|
|
|
public function nextExpectedMatch(Bill $bill, Carbon $date): Carbon;
|
2015-02-25 15:19:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Bill $bill
|
|
|
|
* @param TransactionJournal $journal
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function scan(Bill $bill, TransactionJournal $journal): bool;
|
2015-02-25 15:19:14 +01:00
|
|
|
|
2015-04-05 18:20:06 +02:00
|
|
|
/**
|
|
|
|
* @param array $data
|
|
|
|
*
|
|
|
|
* @return Bill
|
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function store(array $data): Bill;
|
2015-04-05 18:20:06 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Bill $bill
|
|
|
|
* @param array $data
|
|
|
|
*
|
2016-02-06 18:59:48 +01:00
|
|
|
* @return Bill
|
2015-04-05 18:20:06 +02:00
|
|
|
*/
|
2016-02-06 18:59:48 +01:00
|
|
|
public function update(Bill $bill, array $data): Bill;
|
2015-04-05 18:20:06 +02:00
|
|
|
|
2015-03-29 08:14:32 +02:00
|
|
|
}
|