mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Can sort and group bills.
This commit is contained in:
@@ -32,6 +32,7 @@ use FireflyIII\Models\Note;
|
||||
use FireflyIII\Models\Transaction;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use FireflyIII\Repositories\Journal\JournalRepositoryInterface;
|
||||
use FireflyIII\Repositories\ObjectGroup\CreatesObjectGroups;
|
||||
use FireflyIII\Services\Internal\Destroy\BillDestroyService;
|
||||
use FireflyIII\Services\Internal\Update\BillUpdateService;
|
||||
use FireflyIII\Support\CacheProperties;
|
||||
@@ -48,6 +49,7 @@ use Storage;
|
||||
*/
|
||||
class BillRepository implements BillRepositoryInterface
|
||||
{
|
||||
use CreatesObjectGroups;
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
@@ -730,4 +732,36 @@ class BillRepository implements BillRepositoryInterface
|
||||
$current++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setObjectGroup(Bill $bill, string $objectGroupTitle): Bill
|
||||
{
|
||||
$objectGroup = $this->findOrCreateObjectGroup($objectGroupTitle);
|
||||
if (null !== $objectGroup) {
|
||||
$bill->objectGroups()->sync([$objectGroup->id]);
|
||||
}
|
||||
|
||||
return $bill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function removeObjectGroup(Bill $bill): Bill
|
||||
{
|
||||
$bill->objectGroups()->sync([]);
|
||||
|
||||
return $bill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function setOrder(Bill $bill, int $order): void
|
||||
{
|
||||
$bill->order = $order;
|
||||
$bill->save();
|
||||
}
|
||||
}
|
||||
|
@@ -35,6 +35,21 @@ use Illuminate\Support\Collection;
|
||||
interface BillRepositoryInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
* @param string $objectGroupTitle
|
||||
*
|
||||
* @return Bill
|
||||
*/
|
||||
public function setObjectGroup(Bill $bill, string $objectGroupTitle): Bill;
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
*
|
||||
* @return Bill
|
||||
*/
|
||||
public function removeObjectGroup(Bill $bill): Bill;
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
*/
|
||||
@@ -45,6 +60,14 @@ interface BillRepositoryInterface
|
||||
*/
|
||||
public function correctOrder(): void;
|
||||
|
||||
/**
|
||||
* Set specific piggy bank to specific order.
|
||||
*
|
||||
* @param Bill $bill
|
||||
* @param int $order
|
||||
*/
|
||||
public function setOrder(Bill $bill, int $order): void;
|
||||
|
||||
/**
|
||||
* @param Bill $bill
|
||||
*
|
||||
|
Reference in New Issue
Block a user